graphql 15.10.2 → 15.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/error/GraphQLError.js +7 -6
- package/error/GraphQLError.js.flow +3 -3
- package/error/GraphQLError.mjs +8 -7
- package/execution/execute.d.ts +2 -0
- package/execution/execute.js +33 -12
- package/execution/execute.js.flow +32 -11
- package/execution/execute.mjs +33 -12
- package/execution/values.d.ts +1 -1
- package/execution/values.js +5 -5
- package/execution/values.js.flow +5 -2
- package/execution/values.mjs +4 -4
- package/graphql.d.ts +1 -0
- package/graphql.js +4 -1
- package/graphql.js.flow +5 -1
- package/graphql.mjs +4 -1
- package/jsutils/SetMap.js +56 -0
- package/jsutils/SetMap.js.flow +39 -0
- package/jsutils/SetMap.mjs +47 -0
- package/language/lexer.js +21 -2
- package/language/lexer.js.flow +24 -2
- package/language/lexer.mjs +21 -2
- package/language/location.d.ts +5 -0
- package/language/location.js +64 -0
- package/language/location.js.flow +39 -0
- package/language/location.mjs +62 -0
- package/language/parser.js +34 -19
- package/language/parser.js.flow +54 -10
- package/language/parser.mjs +34 -19
- package/language/printer.d.ts +7 -0
- package/language/printer.js +251 -118
- package/language/printer.js.flow +345 -141
- package/language/printer.mjs +246 -116
- package/language/reducer.js +99 -0
- package/language/reducer.js.flow +89 -0
- package/language/reducer.mjs +89 -0
- package/package.json +1 -4
- package/subscription/subscribe.d.ts +2 -0
- package/subscription/subscribe.js +4 -3
- package/subscription/subscribe.js.flow +6 -0
- package/subscription/subscribe.mjs +4 -3
- package/type/definition.d.ts +2 -1
- package/type/definition.js +8 -8
- package/type/definition.js.flow +13 -7
- package/type/definition.mjs +7 -7
- package/type/scalars.js +5 -5
- package/type/scalars.js.flow +1 -1
- package/type/scalars.mjs +1 -1
- package/utilities/buildASTSchema.js +3 -0
- package/utilities/buildASTSchema.js.flow +3 -0
- package/utilities/buildASTSchema.mjs +3 -0
- package/utilities/coerceInputValue.d.ts +1 -0
- package/utilities/coerceInputValue.js +9 -8
- package/utilities/coerceInputValue.js.flow +42 -9
- package/utilities/coerceInputValue.mjs +10 -9
- package/utilities/findBreakingChanges.js +3 -23
- package/utilities/findBreakingChanges.js.flow +2 -15
- package/utilities/findBreakingChanges.mjs +2 -21
- package/utilities/sortValueNode.js +52 -0
- package/utilities/sortValueNode.js.flow +42 -0
- package/utilities/sortValueNode.mjs +42 -0
- package/utilities/valueFromAST.js +2 -2
- package/utilities/valueFromAST.js.flow +8 -2
- package/utilities/valueFromAST.mjs +2 -2
- package/validation/ValidationContext.d.ts +8 -0
- package/validation/ValidationContext.js +82 -24
- package/validation/ValidationContext.js.flow +70 -21
- package/validation/ValidationContext.mjs +80 -24
- package/validation/rules/FieldsOnCorrectTypeRule.js +2 -2
- package/validation/rules/FieldsOnCorrectTypeRule.js.flow +8 -2
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +2 -2
- package/validation/rules/KnownArgumentNamesRule.js +8 -9
- package/validation/rules/KnownArgumentNamesRule.js.flow +16 -6
- package/validation/rules/KnownArgumentNamesRule.mjs +8 -9
- package/validation/rules/KnownTypeNamesRule.js +1 -1
- package/validation/rules/KnownTypeNamesRule.js.flow +6 -4
- package/validation/rules/KnownTypeNamesRule.mjs +1 -1
- package/validation/rules/MaxIntrospectionDepthRule.js +37 -17
- package/validation/rules/MaxIntrospectionDepthRule.js.flow +46 -15
- package/validation/rules/MaxIntrospectionDepthRule.mjs +37 -17
- package/validation/rules/NoUnusedFragmentsRule.js +6 -13
- package/validation/rules/NoUnusedFragmentsRule.js.flow +6 -10
- package/validation/rules/NoUnusedFragmentsRule.mjs +6 -13
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +402 -208
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js.flow +566 -330
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +400 -206
- package/validation/rules/ValuesOfCorrectTypeRule.js +6 -6
- package/validation/rules/ValuesOfCorrectTypeRule.js.flow +11 -6
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +4 -4
- package/validation/validate.d.ts +1 -1
- package/validation/validate.js +6 -2
- package/validation/validate.js.flow +8 -2
- package/validation/validate.mjs +5 -2
- package/validation/validationAbortedError.d.ts +4 -0
- package/validation/validationAbortedError.js +12 -0
- package/validation/validationAbortedError.js.flow +7 -0
- package/validation/validationAbortedError.mjs +4 -0
- package/version.js +3 -3
- package/version.js.flow +3 -3
- package/version.mjs +3 -3
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
import inspect from '../jsutils/inspect';
|
|
3
|
+
|
|
4
|
+
import type { ASTNode } from './ast';
|
|
5
|
+
import { QueryDocumentKeys } from './visitor';
|
|
6
|
+
|
|
7
|
+
// Internal reduction frames hold either an AST node or an array of its children.
|
|
8
|
+
type Frame = {
|
|
9
|
+
parent: any,
|
|
10
|
+
keys: ?$ReadOnlyArray<string>,
|
|
11
|
+
results: any,
|
|
12
|
+
index: number,
|
|
13
|
+
...
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Reduces children before their parents without changing the input AST.
|
|
18
|
+
* Returned values are not revisited.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export function reduce(
|
|
22
|
+
root: ASTNode,
|
|
23
|
+
reducer: { [key: string]: ?(node: any, key: string | number) => any, ... },
|
|
24
|
+
): any {
|
|
25
|
+
const stack: Array<Frame> = [];
|
|
26
|
+
let frame: Frame = {
|
|
27
|
+
parent: [root],
|
|
28
|
+
keys: undefined,
|
|
29
|
+
results: [],
|
|
30
|
+
index: -1,
|
|
31
|
+
};
|
|
32
|
+
let node;
|
|
33
|
+
do {
|
|
34
|
+
let kind;
|
|
35
|
+
frame.index++;
|
|
36
|
+
const keys = frame.keys;
|
|
37
|
+
const length = keys == null ? frame.parent.length : keys.length;
|
|
38
|
+
if (frame.index === length) {
|
|
39
|
+
node = frame.results;
|
|
40
|
+
kind = keys == null ? undefined : node.kind;
|
|
41
|
+
frame = stack.pop();
|
|
42
|
+
} else {
|
|
43
|
+
node =
|
|
44
|
+
keys == null
|
|
45
|
+
? frame.parent[frame.index]
|
|
46
|
+
: frame.parent[keys[frame.index]];
|
|
47
|
+
if (node == null && stack.length !== 0) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (Array.isArray(node)) {
|
|
51
|
+
if (node.length !== 0) {
|
|
52
|
+
stack.push(frame);
|
|
53
|
+
frame = { parent: node, keys: undefined, results: [], index: -1 };
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
const parent = node;
|
|
58
|
+
kind = parent?.kind;
|
|
59
|
+
const childKeys =
|
|
60
|
+
typeof kind === 'string' ? QueryDocumentKeys[kind] : undefined;
|
|
61
|
+
if (!Array.isArray(childKeys)) {
|
|
62
|
+
throw new Error(`Invalid AST Node: ${inspect(node)}.`);
|
|
63
|
+
}
|
|
64
|
+
if (childKeys.length !== 0) {
|
|
65
|
+
stack.push(frame);
|
|
66
|
+
frame = {
|
|
67
|
+
parent,
|
|
68
|
+
keys: childKeys,
|
|
69
|
+
results: { ...parent },
|
|
70
|
+
index: -1,
|
|
71
|
+
};
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (kind !== undefined) {
|
|
77
|
+
node = reducer[kind]?.(
|
|
78
|
+
node,
|
|
79
|
+
frame.keys == null ? frame.index : frame.keys[frame.index],
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (frame.keys == null) {
|
|
83
|
+
frame.results.push(node);
|
|
84
|
+
} else {
|
|
85
|
+
frame.results[frame.keys[frame.index]] = node;
|
|
86
|
+
}
|
|
87
|
+
} while (stack.length !== 0);
|
|
88
|
+
return node;
|
|
89
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
import inspect from "../jsutils/inspect.mjs";
|
|
8
|
+
import { QueryDocumentKeys } from "./visitor.mjs"; // Internal reduction frames hold either an AST node or an array of its children.
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Reduces children before their parents without changing the input AST.
|
|
12
|
+
* Returned values are not revisited.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export function reduce(root, reducer) {
|
|
16
|
+
var stack = [];
|
|
17
|
+
var frame = {
|
|
18
|
+
parent: [root],
|
|
19
|
+
keys: undefined,
|
|
20
|
+
results: [],
|
|
21
|
+
index: -1
|
|
22
|
+
};
|
|
23
|
+
var node;
|
|
24
|
+
|
|
25
|
+
do {
|
|
26
|
+
var kind = void 0;
|
|
27
|
+
frame.index++;
|
|
28
|
+
var keys = frame.keys;
|
|
29
|
+
var length = keys == null ? frame.parent.length : keys.length;
|
|
30
|
+
|
|
31
|
+
if (frame.index === length) {
|
|
32
|
+
node = frame.results;
|
|
33
|
+
kind = keys == null ? undefined : node.kind;
|
|
34
|
+
frame = stack.pop();
|
|
35
|
+
} else {
|
|
36
|
+
node = keys == null ? frame.parent[frame.index] : frame.parent[keys[frame.index]];
|
|
37
|
+
|
|
38
|
+
if (node == null && stack.length !== 0) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (Array.isArray(node)) {
|
|
43
|
+
if (node.length !== 0) {
|
|
44
|
+
stack.push(frame);
|
|
45
|
+
frame = {
|
|
46
|
+
parent: node,
|
|
47
|
+
keys: undefined,
|
|
48
|
+
results: [],
|
|
49
|
+
index: -1
|
|
50
|
+
};
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
var parent = node;
|
|
55
|
+
kind = parent === null || parent === void 0 ? void 0 : parent.kind;
|
|
56
|
+
var childKeys = typeof kind === 'string' ? QueryDocumentKeys[kind] : undefined;
|
|
57
|
+
|
|
58
|
+
if (!Array.isArray(childKeys)) {
|
|
59
|
+
throw new Error("Invalid AST Node: ".concat(inspect(node), "."));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (childKeys.length !== 0) {
|
|
63
|
+
stack.push(frame);
|
|
64
|
+
frame = {
|
|
65
|
+
parent: parent,
|
|
66
|
+
keys: childKeys,
|
|
67
|
+
results: _objectSpread({}, parent),
|
|
68
|
+
index: -1
|
|
69
|
+
};
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (kind !== undefined) {
|
|
76
|
+
var _reducer$kind;
|
|
77
|
+
|
|
78
|
+
node = (_reducer$kind = reducer[kind]) === null || _reducer$kind === void 0 ? void 0 : _reducer$kind.call(reducer, node, frame.keys == null ? frame.index : frame.keys[frame.index]);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (frame.keys == null) {
|
|
82
|
+
frame.results.push(node);
|
|
83
|
+
} else {
|
|
84
|
+
frame.results[frame.keys[frame.index]] = node;
|
|
85
|
+
}
|
|
86
|
+
} while (stack.length !== 0);
|
|
87
|
+
|
|
88
|
+
return node;
|
|
89
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphql",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.11.0",
|
|
4
4
|
"description": "A Query Language and Runtime which can target any service.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index",
|
|
@@ -21,8 +21,5 @@
|
|
|
21
21
|
],
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">= 10.x"
|
|
24
|
-
},
|
|
25
|
-
"publishConfig": {
|
|
26
|
-
"tag": "15.x.x"
|
|
27
24
|
}
|
|
28
25
|
}
|
|
@@ -6,6 +6,7 @@ import { GraphQLSchema } from '../type/schema';
|
|
|
6
6
|
import { GraphQLFieldResolver } from '../type/definition';
|
|
7
7
|
|
|
8
8
|
export interface SubscriptionArgs {
|
|
9
|
+
hideSuggestions?: Maybe<boolean>;
|
|
9
10
|
schema: GraphQLSchema;
|
|
10
11
|
document: DocumentNode;
|
|
11
12
|
rootValue?: any;
|
|
@@ -77,4 +78,5 @@ export function createSourceEventStream(
|
|
|
77
78
|
variableValues?: { [key: string]: any },
|
|
78
79
|
operationName?: Maybe<string>,
|
|
79
80
|
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
|
|
81
|
+
hideSuggestions?: Maybe<boolean>,
|
|
80
82
|
): Promise<AsyncIterable<any> | ExecutionResult>;
|
|
@@ -66,7 +66,7 @@ function subscribeImpl(args) {
|
|
|
66
66
|
operationName = args.operationName,
|
|
67
67
|
fieldResolver = args.fieldResolver,
|
|
68
68
|
subscribeFieldResolver = args.subscribeFieldResolver;
|
|
69
|
-
var sourcePromise = createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver); // For each payload yielded from a subscription, map it over the normal
|
|
69
|
+
var sourcePromise = createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver, args.hideSuggestions); // For each payload yielded from a subscription, map it over the normal
|
|
70
70
|
// GraphQL `execute` function, with `payload` as the rootValue.
|
|
71
71
|
// This implements the "MapSourceToResponseEvent" algorithm described in
|
|
72
72
|
// the GraphQL specification. The `execute` function provides the
|
|
@@ -75,6 +75,7 @@ function subscribeImpl(args) {
|
|
|
75
75
|
|
|
76
76
|
var mapSourceToResponse = function mapSourceToResponse(payload) {
|
|
77
77
|
return (0, _execute.execute)({
|
|
78
|
+
hideSuggestions: args.hideSuggestions,
|
|
78
79
|
schema: schema,
|
|
79
80
|
document: document,
|
|
80
81
|
rootValue: payload,
|
|
@@ -123,14 +124,14 @@ function subscribeImpl(args) {
|
|
|
123
124
|
*/
|
|
124
125
|
|
|
125
126
|
|
|
126
|
-
function createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver) {
|
|
127
|
+
function createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, hideSuggestions) {
|
|
127
128
|
// If arguments are missing or incorrectly typed, this is an internal
|
|
128
129
|
// developer mistake which should throw an early error.
|
|
129
130
|
(0, _execute.assertValidExecutionArguments)(schema, document, variableValues);
|
|
130
131
|
return new Promise(function (resolve) {
|
|
131
132
|
// If a valid context cannot be created due to incorrect arguments,
|
|
132
133
|
// this will throw an error.
|
|
133
|
-
var exeContext = (0, _execute.buildExecutionContext)(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver);
|
|
134
|
+
var exeContext = (0, _execute.buildExecutionContext)(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, undefined, hideSuggestions);
|
|
134
135
|
resolve( // Return early errors if execution context failed.
|
|
135
136
|
Array.isArray(exeContext) ? {
|
|
136
137
|
errors: exeContext
|
|
@@ -27,6 +27,7 @@ import { getOperationRootType } from '../utilities/getOperationRootType';
|
|
|
27
27
|
import mapAsyncIterator from './mapAsyncIterator';
|
|
28
28
|
|
|
29
29
|
export type SubscriptionArgs = {|
|
|
30
|
+
hideSuggestions?: ?boolean,
|
|
30
31
|
schema: GraphQLSchema,
|
|
31
32
|
document: DocumentNode,
|
|
32
33
|
rootValue?: mixed,
|
|
@@ -133,6 +134,7 @@ function subscribeImpl(
|
|
|
133
134
|
variableValues,
|
|
134
135
|
operationName,
|
|
135
136
|
subscribeFieldResolver,
|
|
137
|
+
args.hideSuggestions,
|
|
136
138
|
);
|
|
137
139
|
|
|
138
140
|
// For each payload yielded from a subscription, map it over the normal
|
|
@@ -143,6 +145,7 @@ function subscribeImpl(
|
|
|
143
145
|
// "ExecuteQuery" algorithm, for which `execute` is also used.
|
|
144
146
|
const mapSourceToResponse = (payload) =>
|
|
145
147
|
execute({
|
|
148
|
+
hideSuggestions: args.hideSuggestions,
|
|
146
149
|
schema,
|
|
147
150
|
document,
|
|
148
151
|
rootValue: payload,
|
|
@@ -202,6 +205,7 @@ export function createSourceEventStream(
|
|
|
202
205
|
variableValues?: ?{ +[variable: string]: mixed, ... },
|
|
203
206
|
operationName?: ?string,
|
|
204
207
|
fieldResolver?: ?GraphQLFieldResolver<any, any>,
|
|
208
|
+
hideSuggestions?: ?boolean,
|
|
205
209
|
): Promise<AsyncIterable<mixed> | ExecutionResult> {
|
|
206
210
|
// If arguments are missing or incorrectly typed, this is an internal
|
|
207
211
|
// developer mistake which should throw an early error.
|
|
@@ -218,6 +222,8 @@ export function createSourceEventStream(
|
|
|
218
222
|
variableValues,
|
|
219
223
|
operationName,
|
|
220
224
|
fieldResolver,
|
|
225
|
+
undefined,
|
|
226
|
+
hideSuggestions,
|
|
221
227
|
);
|
|
222
228
|
|
|
223
229
|
resolve(
|
|
@@ -46,7 +46,7 @@ function subscribeImpl(args) {
|
|
|
46
46
|
operationName = args.operationName,
|
|
47
47
|
fieldResolver = args.fieldResolver,
|
|
48
48
|
subscribeFieldResolver = args.subscribeFieldResolver;
|
|
49
|
-
var sourcePromise = createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver); // For each payload yielded from a subscription, map it over the normal
|
|
49
|
+
var sourcePromise = createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver, args.hideSuggestions); // For each payload yielded from a subscription, map it over the normal
|
|
50
50
|
// GraphQL `execute` function, with `payload` as the rootValue.
|
|
51
51
|
// This implements the "MapSourceToResponseEvent" algorithm described in
|
|
52
52
|
// the GraphQL specification. The `execute` function provides the
|
|
@@ -55,6 +55,7 @@ function subscribeImpl(args) {
|
|
|
55
55
|
|
|
56
56
|
var mapSourceToResponse = function mapSourceToResponse(payload) {
|
|
57
57
|
return execute({
|
|
58
|
+
hideSuggestions: args.hideSuggestions,
|
|
58
59
|
schema: schema,
|
|
59
60
|
document: document,
|
|
60
61
|
rootValue: payload,
|
|
@@ -103,14 +104,14 @@ function subscribeImpl(args) {
|
|
|
103
104
|
*/
|
|
104
105
|
|
|
105
106
|
|
|
106
|
-
export function createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver) {
|
|
107
|
+
export function createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, hideSuggestions) {
|
|
107
108
|
// If arguments are missing or incorrectly typed, this is an internal
|
|
108
109
|
// developer mistake which should throw an early error.
|
|
109
110
|
assertValidExecutionArguments(schema, document, variableValues);
|
|
110
111
|
return new Promise(function (resolve) {
|
|
111
112
|
// If a valid context cannot be created due to incorrect arguments,
|
|
112
113
|
// this will throw an error.
|
|
113
|
-
var exeContext = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver);
|
|
114
|
+
var exeContext = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, undefined, hideSuggestions);
|
|
114
115
|
resolve( // Return early errors if execution context failed.
|
|
115
116
|
Array.isArray(exeContext) ? {
|
|
116
117
|
errors: exeContext
|
package/type/definition.d.ts
CHANGED
|
@@ -787,10 +787,11 @@ export class GraphQLEnumType {
|
|
|
787
787
|
getValues(): Array<GraphQLEnumValue>;
|
|
788
788
|
getValue(name: string): Maybe<GraphQLEnumValue>;
|
|
789
789
|
serialize(value: any): Maybe<string>;
|
|
790
|
-
parseValue(value: any): Maybe<any>;
|
|
790
|
+
parseValue(value: any, hideSuggestions?: Maybe<boolean>): Maybe<any>;
|
|
791
791
|
parseLiteral(
|
|
792
792
|
valueNode: ValueNode,
|
|
793
793
|
_variables: Maybe<{ [key: string]: any }>,
|
|
794
|
+
hideSuggestions?: Maybe<boolean>,
|
|
794
795
|
): Maybe<any>;
|
|
795
796
|
|
|
796
797
|
toConfig(): GraphQLEnumTypeConfig & {
|
package/type/definition.js
CHANGED
|
@@ -1006,38 +1006,38 @@ var GraphQLEnumType
|
|
|
1006
1006
|
return enumValue.name;
|
|
1007
1007
|
};
|
|
1008
1008
|
|
|
1009
|
-
_proto5.parseValue = function parseValue(inputValue)
|
|
1009
|
+
_proto5.parseValue = function parseValue(inputValue, hideSuggestions)
|
|
1010
1010
|
/* T */
|
|
1011
1011
|
{
|
|
1012
1012
|
if (typeof inputValue !== 'string') {
|
|
1013
1013
|
var valueStr = (0, _inspect.default)(inputValue);
|
|
1014
|
-
throw new _GraphQLError.GraphQLError("Enum \"".concat(this.name, "\" cannot represent non-string value: ").concat(valueStr, ".") + didYouMeanEnumValue(this, valueStr));
|
|
1014
|
+
throw new _GraphQLError.GraphQLError("Enum \"".concat(this.name, "\" cannot represent non-string value: ").concat(valueStr, ".") + (hideSuggestions === true ? '' : didYouMeanEnumValue(this, valueStr)));
|
|
1015
1015
|
}
|
|
1016
1016
|
|
|
1017
1017
|
var enumValue = this.getValue(inputValue);
|
|
1018
1018
|
|
|
1019
1019
|
if (enumValue == null) {
|
|
1020
|
-
throw new _GraphQLError.GraphQLError("Value \"".concat(inputValue, "\" does not exist in \"").concat(this.name, "\" enum.") + didYouMeanEnumValue(this, inputValue));
|
|
1020
|
+
throw new _GraphQLError.GraphQLError("Value \"".concat(inputValue, "\" does not exist in \"").concat(this.name, "\" enum.") + (hideSuggestions === true ? '' : didYouMeanEnumValue(this, inputValue)));
|
|
1021
1021
|
}
|
|
1022
1022
|
|
|
1023
1023
|
return enumValue.value;
|
|
1024
1024
|
};
|
|
1025
1025
|
|
|
1026
|
-
_proto5.parseLiteral = function parseLiteral(valueNode, _variables)
|
|
1026
|
+
_proto5.parseLiteral = function parseLiteral(valueNode, _variables, hideSuggestions)
|
|
1027
1027
|
/* T */
|
|
1028
1028
|
{
|
|
1029
1029
|
// Note: variables will be resolved to a value before calling this function.
|
|
1030
1030
|
if (valueNode.kind !== _kinds.Kind.ENUM) {
|
|
1031
|
-
var valueStr = (0, _printer.
|
|
1032
|
-
throw new _GraphQLError.GraphQLError("Enum \"".concat(this.name, "\" cannot represent non-enum value: ").concat(valueStr, ".") + didYouMeanEnumValue(this, valueStr), valueNode);
|
|
1031
|
+
var valueStr = (0, _printer.printForError)(valueNode);
|
|
1032
|
+
throw new _GraphQLError.GraphQLError("Enum \"".concat(this.name, "\" cannot represent non-enum value: ").concat(valueStr, ".") + (hideSuggestions === true ? '' : didYouMeanEnumValue(this, valueStr)), valueNode);
|
|
1033
1033
|
}
|
|
1034
1034
|
|
|
1035
1035
|
var enumValue = this.getValue(valueNode.value);
|
|
1036
1036
|
|
|
1037
1037
|
if (enumValue == null) {
|
|
1038
|
-
var _valueStr = (0, _printer.
|
|
1038
|
+
var _valueStr = (0, _printer.printForError)(valueNode);
|
|
1039
1039
|
|
|
1040
|
-
throw new _GraphQLError.GraphQLError("Value \"".concat(_valueStr, "\" does not exist in \"").concat(this.name, "\" enum.") + didYouMeanEnumValue(this, _valueStr), valueNode);
|
|
1040
|
+
throw new _GraphQLError.GraphQLError("Value \"".concat(_valueStr, "\" does not exist in \"").concat(this.name, "\" enum.") + (hideSuggestions === true ? '' : didYouMeanEnumValue(this, _valueStr)), valueNode);
|
|
1041
1041
|
}
|
|
1042
1042
|
|
|
1043
1043
|
return enumValue.value;
|
package/type/definition.js.flow
CHANGED
|
@@ -25,7 +25,7 @@ import suggestionList from '../jsutils/suggestionList';
|
|
|
25
25
|
import { GraphQLError } from '../error/GraphQLError';
|
|
26
26
|
|
|
27
27
|
import { Kind } from '../language/kinds';
|
|
28
|
-
import { print } from '../language/printer';
|
|
28
|
+
import { printForError as print } from '../language/printer';
|
|
29
29
|
import type {
|
|
30
30
|
ScalarTypeDefinitionNode,
|
|
31
31
|
ObjectTypeDefinitionNode,
|
|
@@ -1344,12 +1344,12 @@ export class GraphQLEnumType /* <T> */ {
|
|
|
1344
1344
|
return enumValue.name;
|
|
1345
1345
|
}
|
|
1346
1346
|
|
|
1347
|
-
parseValue(inputValue: mixed): ?any /* T */ {
|
|
1347
|
+
parseValue(inputValue: mixed, hideSuggestions?: ?boolean): ?any /* T */ {
|
|
1348
1348
|
if (typeof inputValue !== 'string') {
|
|
1349
1349
|
const valueStr = inspect(inputValue);
|
|
1350
1350
|
throw new GraphQLError(
|
|
1351
1351
|
`Enum "${this.name}" cannot represent non-string value: ${valueStr}.` +
|
|
1352
|
-
didYouMeanEnumValue(this, valueStr),
|
|
1352
|
+
(hideSuggestions === true ? '' : didYouMeanEnumValue(this, valueStr)),
|
|
1353
1353
|
);
|
|
1354
1354
|
}
|
|
1355
1355
|
|
|
@@ -1357,19 +1357,25 @@ export class GraphQLEnumType /* <T> */ {
|
|
|
1357
1357
|
if (enumValue == null) {
|
|
1358
1358
|
throw new GraphQLError(
|
|
1359
1359
|
`Value "${inputValue}" does not exist in "${this.name}" enum.` +
|
|
1360
|
-
|
|
1360
|
+
(hideSuggestions === true
|
|
1361
|
+
? ''
|
|
1362
|
+
: didYouMeanEnumValue(this, inputValue)),
|
|
1361
1363
|
);
|
|
1362
1364
|
}
|
|
1363
1365
|
return enumValue.value;
|
|
1364
1366
|
}
|
|
1365
1367
|
|
|
1366
|
-
parseLiteral(
|
|
1368
|
+
parseLiteral(
|
|
1369
|
+
valueNode: ValueNode,
|
|
1370
|
+
_variables: ?ObjMap<mixed>,
|
|
1371
|
+
hideSuggestions?: ?boolean,
|
|
1372
|
+
): ?any /* T */ {
|
|
1367
1373
|
// Note: variables will be resolved to a value before calling this function.
|
|
1368
1374
|
if (valueNode.kind !== Kind.ENUM) {
|
|
1369
1375
|
const valueStr = print(valueNode);
|
|
1370
1376
|
throw new GraphQLError(
|
|
1371
1377
|
`Enum "${this.name}" cannot represent non-enum value: ${valueStr}.` +
|
|
1372
|
-
didYouMeanEnumValue(this, valueStr),
|
|
1378
|
+
(hideSuggestions === true ? '' : didYouMeanEnumValue(this, valueStr)),
|
|
1373
1379
|
valueNode,
|
|
1374
1380
|
);
|
|
1375
1381
|
}
|
|
@@ -1379,7 +1385,7 @@ export class GraphQLEnumType /* <T> */ {
|
|
|
1379
1385
|
const valueStr = print(valueNode);
|
|
1380
1386
|
throw new GraphQLError(
|
|
1381
1387
|
`Value "${valueStr}" does not exist in "${this.name}" enum.` +
|
|
1382
|
-
didYouMeanEnumValue(this, valueStr),
|
|
1388
|
+
(hideSuggestions === true ? '' : didYouMeanEnumValue(this, valueStr)),
|
|
1383
1389
|
valueNode,
|
|
1384
1390
|
);
|
|
1385
1391
|
}
|
package/type/definition.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import defineInspect from "../jsutils/defineInspect.mjs";
|
|
|
18
18
|
import suggestionList from "../jsutils/suggestionList.mjs";
|
|
19
19
|
import { GraphQLError } from "../error/GraphQLError.mjs";
|
|
20
20
|
import { Kind } from "../language/kinds.mjs";
|
|
21
|
-
import { print } from "../language/printer.mjs";
|
|
21
|
+
import { printForError as print } from "../language/printer.mjs";
|
|
22
22
|
import { valueFromASTUntyped } from "../utilities/valueFromASTUntyped.mjs";
|
|
23
23
|
export function isType(type) {
|
|
24
24
|
return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isInputObjectType(type) || isListType(type) || isNonNullType(type);
|
|
@@ -891,30 +891,30 @@ export var GraphQLEnumType
|
|
|
891
891
|
return enumValue.name;
|
|
892
892
|
};
|
|
893
893
|
|
|
894
|
-
_proto5.parseValue = function parseValue(inputValue)
|
|
894
|
+
_proto5.parseValue = function parseValue(inputValue, hideSuggestions)
|
|
895
895
|
/* T */
|
|
896
896
|
{
|
|
897
897
|
if (typeof inputValue !== 'string') {
|
|
898
898
|
var valueStr = inspect(inputValue);
|
|
899
|
-
throw new GraphQLError("Enum \"".concat(this.name, "\" cannot represent non-string value: ").concat(valueStr, ".") + didYouMeanEnumValue(this, valueStr));
|
|
899
|
+
throw new GraphQLError("Enum \"".concat(this.name, "\" cannot represent non-string value: ").concat(valueStr, ".") + (hideSuggestions === true ? '' : didYouMeanEnumValue(this, valueStr)));
|
|
900
900
|
}
|
|
901
901
|
|
|
902
902
|
var enumValue = this.getValue(inputValue);
|
|
903
903
|
|
|
904
904
|
if (enumValue == null) {
|
|
905
|
-
throw new GraphQLError("Value \"".concat(inputValue, "\" does not exist in \"").concat(this.name, "\" enum.") + didYouMeanEnumValue(this, inputValue));
|
|
905
|
+
throw new GraphQLError("Value \"".concat(inputValue, "\" does not exist in \"").concat(this.name, "\" enum.") + (hideSuggestions === true ? '' : didYouMeanEnumValue(this, inputValue)));
|
|
906
906
|
}
|
|
907
907
|
|
|
908
908
|
return enumValue.value;
|
|
909
909
|
};
|
|
910
910
|
|
|
911
|
-
_proto5.parseLiteral = function parseLiteral(valueNode, _variables)
|
|
911
|
+
_proto5.parseLiteral = function parseLiteral(valueNode, _variables, hideSuggestions)
|
|
912
912
|
/* T */
|
|
913
913
|
{
|
|
914
914
|
// Note: variables will be resolved to a value before calling this function.
|
|
915
915
|
if (valueNode.kind !== Kind.ENUM) {
|
|
916
916
|
var valueStr = print(valueNode);
|
|
917
|
-
throw new GraphQLError("Enum \"".concat(this.name, "\" cannot represent non-enum value: ").concat(valueStr, ".") + didYouMeanEnumValue(this, valueStr), valueNode);
|
|
917
|
+
throw new GraphQLError("Enum \"".concat(this.name, "\" cannot represent non-enum value: ").concat(valueStr, ".") + (hideSuggestions === true ? '' : didYouMeanEnumValue(this, valueStr)), valueNode);
|
|
918
918
|
}
|
|
919
919
|
|
|
920
920
|
var enumValue = this.getValue(valueNode.value);
|
|
@@ -922,7 +922,7 @@ export var GraphQLEnumType
|
|
|
922
922
|
if (enumValue == null) {
|
|
923
923
|
var _valueStr = print(valueNode);
|
|
924
924
|
|
|
925
|
-
throw new GraphQLError("Value \"".concat(_valueStr, "\" does not exist in \"").concat(this.name, "\" enum.") + didYouMeanEnumValue(this, _valueStr), valueNode);
|
|
925
|
+
throw new GraphQLError("Value \"".concat(_valueStr, "\" does not exist in \"").concat(this.name, "\" enum.") + (hideSuggestions === true ? '' : didYouMeanEnumValue(this, _valueStr)), valueNode);
|
|
926
926
|
}
|
|
927
927
|
|
|
928
928
|
return enumValue.value;
|
package/type/scalars.js
CHANGED
|
@@ -75,7 +75,7 @@ var GraphQLInt = new _definition.GraphQLScalarType({
|
|
|
75
75
|
parseValue: coerceInt,
|
|
76
76
|
parseLiteral: function parseLiteral(valueNode) {
|
|
77
77
|
if (valueNode.kind !== _kinds.Kind.INT) {
|
|
78
|
-
throw new _GraphQLError.GraphQLError("Int cannot represent non-integer value: ".concat((0, _printer.
|
|
78
|
+
throw new _GraphQLError.GraphQLError("Int cannot represent non-integer value: ".concat((0, _printer.printForError)(valueNode)), valueNode);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
var num = parseInt(valueNode.value, 10);
|
|
@@ -124,7 +124,7 @@ var GraphQLFloat = new _definition.GraphQLScalarType({
|
|
|
124
124
|
parseValue: coerceFloat,
|
|
125
125
|
parseLiteral: function parseLiteral(valueNode) {
|
|
126
126
|
if (valueNode.kind !== _kinds.Kind.FLOAT && valueNode.kind !== _kinds.Kind.INT) {
|
|
127
|
-
throw new _GraphQLError.GraphQLError("Float cannot represent non numeric value: ".concat((0, _printer.
|
|
127
|
+
throw new _GraphQLError.GraphQLError("Float cannot represent non numeric value: ".concat((0, _printer.printForError)(valueNode)), valueNode);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
return parseFloat(valueNode.value);
|
|
@@ -188,7 +188,7 @@ var GraphQLString = new _definition.GraphQLScalarType({
|
|
|
188
188
|
parseValue: coerceString,
|
|
189
189
|
parseLiteral: function parseLiteral(valueNode) {
|
|
190
190
|
if (valueNode.kind !== _kinds.Kind.STRING) {
|
|
191
|
-
throw new _GraphQLError.GraphQLError("String cannot represent a non string value: ".concat((0, _printer.
|
|
191
|
+
throw new _GraphQLError.GraphQLError("String cannot represent a non string value: ".concat((0, _printer.printForError)(valueNode)), valueNode);
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
return valueNode.value;
|
|
@@ -225,7 +225,7 @@ var GraphQLBoolean = new _definition.GraphQLScalarType({
|
|
|
225
225
|
parseValue: coerceBoolean,
|
|
226
226
|
parseLiteral: function parseLiteral(valueNode) {
|
|
227
227
|
if (valueNode.kind !== _kinds.Kind.BOOLEAN) {
|
|
228
|
-
throw new _GraphQLError.GraphQLError("Boolean cannot represent a non boolean value: ".concat((0, _printer.
|
|
228
|
+
throw new _GraphQLError.GraphQLError("Boolean cannot represent a non boolean value: ".concat((0, _printer.printForError)(valueNode)), valueNode);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
return valueNode.value;
|
|
@@ -266,7 +266,7 @@ var GraphQLID = new _definition.GraphQLScalarType({
|
|
|
266
266
|
parseValue: coerceID,
|
|
267
267
|
parseLiteral: function parseLiteral(valueNode) {
|
|
268
268
|
if (valueNode.kind !== _kinds.Kind.STRING && valueNode.kind !== _kinds.Kind.INT) {
|
|
269
|
-
throw new _GraphQLError.GraphQLError('ID cannot represent a non-string and non-integer value: ' + (0, _printer.
|
|
269
|
+
throw new _GraphQLError.GraphQLError('ID cannot represent a non-string and non-integer value: ' + (0, _printer.printForError)(valueNode), valueNode);
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
return valueNode.value;
|
package/type/scalars.js.flow
CHANGED
|
@@ -6,7 +6,7 @@ import inspect from '../jsutils/inspect';
|
|
|
6
6
|
import isObjectLike from '../jsutils/isObjectLike';
|
|
7
7
|
|
|
8
8
|
import { Kind } from '../language/kinds';
|
|
9
|
-
import { print } from '../language/printer';
|
|
9
|
+
import { printForError as print } from '../language/printer';
|
|
10
10
|
|
|
11
11
|
import { GraphQLError } from '../error/GraphQLError';
|
|
12
12
|
|
package/type/scalars.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import isInteger from "../polyfills/isInteger.mjs";
|
|
|
3
3
|
import inspect from "../jsutils/inspect.mjs";
|
|
4
4
|
import isObjectLike from "../jsutils/isObjectLike.mjs";
|
|
5
5
|
import { Kind } from "../language/kinds.mjs";
|
|
6
|
-
import { print } from "../language/printer.mjs";
|
|
6
|
+
import { printForError as print } from "../language/printer.mjs";
|
|
7
7
|
import { GraphQLError } from "../error/GraphQLError.mjs";
|
|
8
8
|
import { GraphQLScalarType } from "./definition.mjs"; // As per the GraphQL Spec, Integers are only treated as valid when a valid
|
|
9
9
|
// 32-bit signed integer, providing the broadest support across platforms.
|
|
@@ -105,6 +105,9 @@ function buildASTSchema(documentAST, options) {
|
|
|
105
105
|
function buildSchema(source, options) {
|
|
106
106
|
var document = (0, _parser.parse)(source, {
|
|
107
107
|
noLocation: options === null || options === void 0 ? void 0 : options.noLocation,
|
|
108
|
+
maxLexicalTokens: options === null || options === void 0 ? void 0 : options.maxLexicalTokens,
|
|
109
|
+
maxComments: options === null || options === void 0 ? void 0 : options.maxComments,
|
|
110
|
+
maxSourceLength: options === null || options === void 0 ? void 0 : options.maxSourceLength,
|
|
108
111
|
allowLegacySDLEmptyFields: options === null || options === void 0 ? void 0 : options.allowLegacySDLEmptyFields,
|
|
109
112
|
allowLegacySDLImplementsInterfaces: options === null || options === void 0 ? void 0 : options.allowLegacySDLImplementsInterfaces,
|
|
110
113
|
experimentalFragmentVariables: options === null || options === void 0 ? void 0 : options.experimentalFragmentVariables
|
|
@@ -115,6 +115,9 @@ export function buildSchema(
|
|
|
115
115
|
): GraphQLSchema {
|
|
116
116
|
const document = parse(source, {
|
|
117
117
|
noLocation: options?.noLocation,
|
|
118
|
+
maxLexicalTokens: options?.maxLexicalTokens,
|
|
119
|
+
maxComments: options?.maxComments,
|
|
120
|
+
maxSourceLength: options?.maxSourceLength,
|
|
118
121
|
allowLegacySDLEmptyFields: options?.allowLegacySDLEmptyFields,
|
|
119
122
|
allowLegacySDLImplementsInterfaces:
|
|
120
123
|
options?.allowLegacySDLImplementsInterfaces,
|
|
@@ -88,6 +88,9 @@ export function buildASTSchema(documentAST, options) {
|
|
|
88
88
|
export function buildSchema(source, options) {
|
|
89
89
|
var document = parse(source, {
|
|
90
90
|
noLocation: options === null || options === void 0 ? void 0 : options.noLocation,
|
|
91
|
+
maxLexicalTokens: options === null || options === void 0 ? void 0 : options.maxLexicalTokens,
|
|
92
|
+
maxComments: options === null || options === void 0 ? void 0 : options.maxComments,
|
|
93
|
+
maxSourceLength: options === null || options === void 0 ? void 0 : options.maxSourceLength,
|
|
91
94
|
allowLegacySDLEmptyFields: options === null || options === void 0 ? void 0 : options.allowLegacySDLEmptyFields,
|
|
92
95
|
allowLegacySDLImplementsInterfaces: options === null || options === void 0 ? void 0 : options.allowLegacySDLImplementsInterfaces,
|
|
93
96
|
experimentalFragmentVariables: options === null || options === void 0 ? void 0 : options.experimentalFragmentVariables
|