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
package/error/GraphQLError.js
CHANGED
|
@@ -106,7 +106,7 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
106
106
|
* Extension fields to add to the formatted error.
|
|
107
107
|
*/
|
|
108
108
|
function GraphQLError(message, nodes, source, positions, path, originalError, extensions) {
|
|
109
|
-
var _nodeLocations, _nodeLocations2
|
|
109
|
+
var _nodeLocations, _nodeLocations2;
|
|
110
110
|
|
|
111
111
|
var _this;
|
|
112
112
|
|
|
@@ -136,11 +136,12 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
136
136
|
_this.positions = positions !== null && positions !== void 0 ? positions : (_nodeLocations2 = nodeLocations) === null || _nodeLocations2 === void 0 ? void 0 : _nodeLocations2.map(function (loc) {
|
|
137
137
|
return loc.start;
|
|
138
138
|
});
|
|
139
|
-
_this.locations = positions && source ? positions.map(function (
|
|
140
|
-
return
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
_this.locations = positions && source ? (0, _location.getLocations)(positions.map(function (start) {
|
|
140
|
+
return {
|
|
141
|
+
source: source,
|
|
142
|
+
start: start
|
|
143
|
+
};
|
|
144
|
+
})) : nodeLocations && (0, _location.getLocations)(nodeLocations);
|
|
144
145
|
_this.path = path !== null && path !== void 0 ? path : undefined;
|
|
145
146
|
var originalExtensions = originalError === null || originalError === void 0 ? void 0 : originalError.extensions;
|
|
146
147
|
|
|
@@ -6,7 +6,7 @@ import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols';
|
|
|
6
6
|
import type { ASTNode } from '../language/ast';
|
|
7
7
|
import type { Source } from '../language/source';
|
|
8
8
|
import type { SourceLocation } from '../language/location';
|
|
9
|
-
import {
|
|
9
|
+
import { getLocations } from '../language/location';
|
|
10
10
|
import { printLocation, printSourceLocation } from '../language/printLocation';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -99,8 +99,8 @@ export class GraphQLError extends Error {
|
|
|
99
99
|
|
|
100
100
|
this.locations =
|
|
101
101
|
positions && source
|
|
102
|
-
? positions.map((
|
|
103
|
-
: nodeLocations
|
|
102
|
+
? getLocations(positions.map((start) => ({ source, start })))
|
|
103
|
+
: nodeLocations && getLocations(nodeLocations);
|
|
104
104
|
|
|
105
105
|
this.path = path ?? undefined;
|
|
106
106
|
|
package/error/GraphQLError.mjs
CHANGED
|
@@ -35,7 +35,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
35
35
|
import devAssert from "../jsutils/devAssert.mjs";
|
|
36
36
|
import isObjectLike from "../jsutils/isObjectLike.mjs";
|
|
37
37
|
import { SYMBOL_TO_STRING_TAG } from "../polyfills/symbols.mjs";
|
|
38
|
-
import {
|
|
38
|
+
import { getLocations } from "../language/location.mjs";
|
|
39
39
|
import { printLocation, printSourceLocation } from "../language/printLocation.mjs";
|
|
40
40
|
/**
|
|
41
41
|
* A GraphQLError describes an Error found during the parse, validate, or
|
|
@@ -91,7 +91,7 @@ export var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
91
91
|
* Extension fields to add to the formatted error.
|
|
92
92
|
*/
|
|
93
93
|
function GraphQLError(message, nodes, source, positions, path, originalError, extensions) {
|
|
94
|
-
var _nodeLocations, _nodeLocations2
|
|
94
|
+
var _nodeLocations, _nodeLocations2;
|
|
95
95
|
|
|
96
96
|
var _this;
|
|
97
97
|
|
|
@@ -121,11 +121,12 @@ export var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
121
121
|
_this.positions = positions !== null && positions !== void 0 ? positions : (_nodeLocations2 = nodeLocations) === null || _nodeLocations2 === void 0 ? void 0 : _nodeLocations2.map(function (loc) {
|
|
122
122
|
return loc.start;
|
|
123
123
|
});
|
|
124
|
-
_this.locations = positions && source ? positions.map(function (
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
_this.locations = positions && source ? getLocations(positions.map(function (start) {
|
|
125
|
+
return {
|
|
126
|
+
source: source,
|
|
127
|
+
start: start
|
|
128
|
+
};
|
|
129
|
+
})) : nodeLocations && getLocations(nodeLocations);
|
|
129
130
|
_this.path = path !== null && path !== void 0 ? path : undefined;
|
|
130
131
|
var originalExtensions = originalError === null || originalError === void 0 ? void 0 : originalError.extensions;
|
|
131
132
|
|
package/execution/execute.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export interface FormattedExecutionResult<
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export interface ExecutionArgs {
|
|
70
|
+
hideSuggestions?: Maybe<boolean>;
|
|
70
71
|
schema: GraphQLSchema;
|
|
71
72
|
document: DocumentNode;
|
|
72
73
|
rootValue?: any;
|
|
@@ -133,6 +134,7 @@ export function buildExecutionContext(
|
|
|
133
134
|
operationName: Maybe<string>,
|
|
134
135
|
fieldResolver: Maybe<GraphQLFieldResolver<any, any>>,
|
|
135
136
|
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
|
|
137
|
+
hideSuggestions?: Maybe<boolean>,
|
|
136
138
|
): ReadonlyArray<GraphQLError> | ExecutionContext;
|
|
137
139
|
|
|
138
140
|
/**
|
package/execution/execute.js
CHANGED
|
@@ -98,7 +98,7 @@ function executeImpl(args) {
|
|
|
98
98
|
assertValidExecutionArguments(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments,
|
|
99
99
|
// a "Response" with only errors is returned.
|
|
100
100
|
|
|
101
|
-
var exeContext = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver); // Return early errors if execution context failed.
|
|
101
|
+
var exeContext = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver, args.hideSuggestions); // Return early errors if execution context failed.
|
|
102
102
|
|
|
103
103
|
if (Array.isArray(exeContext)) {
|
|
104
104
|
return {
|
|
@@ -161,7 +161,7 @@ function assertValidExecutionArguments(schema, document, rawVariableValues) {
|
|
|
161
161
|
*/
|
|
162
162
|
|
|
163
163
|
|
|
164
|
-
function buildExecutionContext(schema, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver) {
|
|
164
|
+
function buildExecutionContext(schema, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver, hideSuggestions) {
|
|
165
165
|
var _definition$name, _operation$variableDe;
|
|
166
166
|
|
|
167
167
|
var operation;
|
|
@@ -201,7 +201,8 @@ function buildExecutionContext(schema, document, rootValue, contextValue, rawVar
|
|
|
201
201
|
|
|
202
202
|
var variableDefinitions = (_operation$variableDe = operation.variableDefinitions) !== null && _operation$variableDe !== void 0 ? _operation$variableDe : [];
|
|
203
203
|
var coercedVariableValues = (0, _values.getVariableValues)(schema, variableDefinitions, rawVariableValues !== null && rawVariableValues !== void 0 ? rawVariableValues : {}, {
|
|
204
|
-
maxErrors: 50
|
|
204
|
+
maxErrors: 50,
|
|
205
|
+
hideSuggestions: hideSuggestions
|
|
205
206
|
});
|
|
206
207
|
|
|
207
208
|
if (coercedVariableValues.errors) {
|
|
@@ -803,18 +804,38 @@ var defaultTypeResolver = function defaultTypeResolver(value, contextValue, info
|
|
|
803
804
|
var possibleTypes = info.schema.getPossibleTypes(abstractType);
|
|
804
805
|
var promisedIsTypeOfResults = [];
|
|
805
806
|
|
|
806
|
-
|
|
807
|
-
var
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
807
|
+
try {
|
|
808
|
+
for (var i = 0; i < possibleTypes.length; i++) {
|
|
809
|
+
var type = possibleTypes[i];
|
|
810
|
+
|
|
811
|
+
if (type.isTypeOf) {
|
|
812
|
+
var isTypeOfResult = type.isTypeOf(value, contextValue, info);
|
|
813
|
+
|
|
814
|
+
if ((0, _isPromise.default)(isTypeOfResult)) {
|
|
815
|
+
promisedIsTypeOfResults[i] = isTypeOfResult;
|
|
816
|
+
} else if (isTypeOfResult) {
|
|
817
|
+
if (promisedIsTypeOfResults.length) {
|
|
818
|
+
Promise.all(promisedIsTypeOfResults).catch(function () {
|
|
819
|
+
/* Ignore unused results. */
|
|
820
|
+
});
|
|
821
|
+
}
|
|
811
822
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
} else if (isTypeOfResult) {
|
|
815
|
-
return type.name;
|
|
823
|
+
return type.name;
|
|
824
|
+
}
|
|
816
825
|
}
|
|
817
826
|
}
|
|
827
|
+
} catch (error) {
|
|
828
|
+
if (promisedIsTypeOfResults.length) {
|
|
829
|
+
return Promise.all(promisedIsTypeOfResults.map(function (promise) {
|
|
830
|
+
return Promise.resolve(promise).catch(function () {
|
|
831
|
+
return undefined;
|
|
832
|
+
});
|
|
833
|
+
})).then(function () {
|
|
834
|
+
throw error;
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
throw error;
|
|
818
839
|
}
|
|
819
840
|
|
|
820
841
|
if (promisedIsTypeOfResults.length) {
|
|
@@ -126,6 +126,7 @@ export type FormattedExecutionResult = {|
|
|
|
126
126
|
|};
|
|
127
127
|
|
|
128
128
|
export type ExecutionArgs = {|
|
|
129
|
+
hideSuggestions?: ?boolean,
|
|
129
130
|
schema: GraphQLSchema,
|
|
130
131
|
document: DocumentNode,
|
|
131
132
|
rootValue?: mixed,
|
|
@@ -231,6 +232,7 @@ function executeImpl(args: ExecutionArgs): PromiseOrValue<ExecutionResult> {
|
|
|
231
232
|
operationName,
|
|
232
233
|
fieldResolver,
|
|
233
234
|
typeResolver,
|
|
235
|
+
args.hideSuggestions,
|
|
234
236
|
);
|
|
235
237
|
|
|
236
238
|
// Return early errors if execution context failed.
|
|
@@ -305,6 +307,7 @@ export function buildExecutionContext(
|
|
|
305
307
|
operationName: ?string,
|
|
306
308
|
fieldResolver: ?GraphQLFieldResolver<mixed, mixed>,
|
|
307
309
|
typeResolver?: ?GraphQLTypeResolver<mixed, mixed>,
|
|
310
|
+
hideSuggestions?: ?boolean,
|
|
308
311
|
): $ReadOnlyArray<GraphQLError> | ExecutionContext {
|
|
309
312
|
let operation: OperationDefinitionNode | void;
|
|
310
313
|
const fragments: ObjMap<FragmentDefinitionNode> = Object.create(null);
|
|
@@ -344,7 +347,7 @@ export function buildExecutionContext(
|
|
|
344
347
|
schema,
|
|
345
348
|
variableDefinitions,
|
|
346
349
|
rawVariableValues ?? {},
|
|
347
|
-
{ maxErrors: 50 },
|
|
350
|
+
{ maxErrors: 50, hideSuggestions },
|
|
348
351
|
);
|
|
349
352
|
|
|
350
353
|
if (coercedVariableValues.errors) {
|
|
@@ -1178,18 +1181,36 @@ export const defaultTypeResolver: GraphQLTypeResolver<mixed, mixed> = function (
|
|
|
1178
1181
|
const possibleTypes = info.schema.getPossibleTypes(abstractType);
|
|
1179
1182
|
const promisedIsTypeOfResults = [];
|
|
1180
1183
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1184
|
+
try {
|
|
1185
|
+
for (let i = 0; i < possibleTypes.length; i++) {
|
|
1186
|
+
const type = possibleTypes[i];
|
|
1187
|
+
|
|
1188
|
+
if (type.isTypeOf) {
|
|
1189
|
+
const isTypeOfResult = type.isTypeOf(value, contextValue, info);
|
|
1190
|
+
|
|
1191
|
+
if (isPromise(isTypeOfResult)) {
|
|
1192
|
+
promisedIsTypeOfResults[i] = isTypeOfResult;
|
|
1193
|
+
} else if (isTypeOfResult) {
|
|
1194
|
+
if (promisedIsTypeOfResults.length) {
|
|
1195
|
+
Promise.all(promisedIsTypeOfResults).catch(() => {
|
|
1196
|
+
/* Ignore unused results. */
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
return type.name;
|
|
1200
|
+
}
|
|
1191
1201
|
}
|
|
1192
1202
|
}
|
|
1203
|
+
} catch (error) {
|
|
1204
|
+
if (promisedIsTypeOfResults.length) {
|
|
1205
|
+
return Promise.all(
|
|
1206
|
+
promisedIsTypeOfResults.map((promise) =>
|
|
1207
|
+
Promise.resolve(promise).catch(() => undefined),
|
|
1208
|
+
),
|
|
1209
|
+
).then(() => {
|
|
1210
|
+
throw error;
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
throw error;
|
|
1193
1214
|
}
|
|
1194
1215
|
|
|
1195
1216
|
if (promisedIsTypeOfResults.length) {
|
package/execution/execute.mjs
CHANGED
|
@@ -88,7 +88,7 @@ function executeImpl(args) {
|
|
|
88
88
|
assertValidExecutionArguments(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments,
|
|
89
89
|
// a "Response" with only errors is returned.
|
|
90
90
|
|
|
91
|
-
var exeContext = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver); // Return early errors if execution context failed.
|
|
91
|
+
var exeContext = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver, args.hideSuggestions); // Return early errors if execution context failed.
|
|
92
92
|
|
|
93
93
|
if (Array.isArray(exeContext)) {
|
|
94
94
|
return {
|
|
@@ -150,7 +150,7 @@ export function assertValidExecutionArguments(schema, document, rawVariableValue
|
|
|
150
150
|
* @internal
|
|
151
151
|
*/
|
|
152
152
|
|
|
153
|
-
export function buildExecutionContext(schema, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver) {
|
|
153
|
+
export function buildExecutionContext(schema, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver, hideSuggestions) {
|
|
154
154
|
var _definition$name, _operation$variableDe;
|
|
155
155
|
|
|
156
156
|
var operation;
|
|
@@ -190,7 +190,8 @@ export function buildExecutionContext(schema, document, rootValue, contextValue,
|
|
|
190
190
|
|
|
191
191
|
var variableDefinitions = (_operation$variableDe = operation.variableDefinitions) !== null && _operation$variableDe !== void 0 ? _operation$variableDe : [];
|
|
192
192
|
var coercedVariableValues = getVariableValues(schema, variableDefinitions, rawVariableValues !== null && rawVariableValues !== void 0 ? rawVariableValues : {}, {
|
|
193
|
-
maxErrors: 50
|
|
193
|
+
maxErrors: 50,
|
|
194
|
+
hideSuggestions: hideSuggestions
|
|
194
195
|
});
|
|
195
196
|
|
|
196
197
|
if (coercedVariableValues.errors) {
|
|
@@ -790,18 +791,38 @@ export var defaultTypeResolver = function defaultTypeResolver(value, contextValu
|
|
|
790
791
|
var possibleTypes = info.schema.getPossibleTypes(abstractType);
|
|
791
792
|
var promisedIsTypeOfResults = [];
|
|
792
793
|
|
|
793
|
-
|
|
794
|
-
var
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
794
|
+
try {
|
|
795
|
+
for (var i = 0; i < possibleTypes.length; i++) {
|
|
796
|
+
var type = possibleTypes[i];
|
|
797
|
+
|
|
798
|
+
if (type.isTypeOf) {
|
|
799
|
+
var isTypeOfResult = type.isTypeOf(value, contextValue, info);
|
|
800
|
+
|
|
801
|
+
if (isPromise(isTypeOfResult)) {
|
|
802
|
+
promisedIsTypeOfResults[i] = isTypeOfResult;
|
|
803
|
+
} else if (isTypeOfResult) {
|
|
804
|
+
if (promisedIsTypeOfResults.length) {
|
|
805
|
+
Promise.all(promisedIsTypeOfResults).catch(function () {
|
|
806
|
+
/* Ignore unused results. */
|
|
807
|
+
});
|
|
808
|
+
}
|
|
798
809
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
} else if (isTypeOfResult) {
|
|
802
|
-
return type.name;
|
|
810
|
+
return type.name;
|
|
811
|
+
}
|
|
803
812
|
}
|
|
804
813
|
}
|
|
814
|
+
} catch (error) {
|
|
815
|
+
if (promisedIsTypeOfResults.length) {
|
|
816
|
+
return Promise.all(promisedIsTypeOfResults.map(function (promise) {
|
|
817
|
+
return Promise.resolve(promise).catch(function () {
|
|
818
|
+
return undefined;
|
|
819
|
+
});
|
|
820
|
+
})).then(function () {
|
|
821
|
+
throw error;
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
throw error;
|
|
805
826
|
}
|
|
806
827
|
|
|
807
828
|
if (promisedIsTypeOfResults.length) {
|
package/execution/values.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export function getVariableValues(
|
|
|
28
28
|
schema: GraphQLSchema,
|
|
29
29
|
varDefNodes: ReadonlyArray<VariableDefinitionNode>,
|
|
30
30
|
inputs: { [key: string]: any },
|
|
31
|
-
options?: { maxErrors?: number },
|
|
31
|
+
options?: { maxErrors?: number; hideSuggestions?: boolean | null },
|
|
32
32
|
): CoercedVariableValues;
|
|
33
33
|
|
|
34
34
|
/**
|
package/execution/values.js
CHANGED
|
@@ -59,7 +59,7 @@ function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
errors.push(error);
|
|
62
|
-
});
|
|
62
|
+
}, options === null || options === void 0 ? void 0 : options.hideSuggestions);
|
|
63
63
|
|
|
64
64
|
if (errors.length === 0) {
|
|
65
65
|
return {
|
|
@@ -75,7 +75,7 @@ function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
78
|
+
function coerceVariableValues(schema, varDefNodes, inputs, onError, hideSuggestions) {
|
|
79
79
|
var coercedValues = Object.create(null);
|
|
80
80
|
|
|
81
81
|
var _loop = function _loop(_i2) {
|
|
@@ -86,7 +86,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
86
86
|
if (!(0, _definition.isInputType)(varType)) {
|
|
87
87
|
// Must use input types for variables. This should be caught during
|
|
88
88
|
// validation, however is checked again here for safety.
|
|
89
|
-
var varTypeStr = (0, _printer.
|
|
89
|
+
var varTypeStr = (0, _printer.printForError)(varDefNode.type);
|
|
90
90
|
onError(new _GraphQLError.GraphQLError("Variable \"$".concat(varName, "\" expected value of type \"").concat(varTypeStr, "\" which cannot be used as an input type."), varDefNode.type));
|
|
91
91
|
return "continue";
|
|
92
92
|
}
|
|
@@ -120,7 +120,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
onError(new _GraphQLError.GraphQLError(prefix + '; ' + error.message, varDefNode, undefined, undefined, undefined, error.originalError));
|
|
123
|
-
});
|
|
123
|
+
}, hideSuggestions);
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
for (var _i2 = 0; _i2 < varDefNodes.length; _i2++) {
|
|
@@ -198,7 +198,7 @@ function getArgumentValues(def, node, variableValues) {
|
|
|
198
198
|
// Note: ValuesOfCorrectTypeRule validation should catch this before
|
|
199
199
|
// execution. This is a runtime check to ensure execution does not
|
|
200
200
|
// continue with an invalid argument value.
|
|
201
|
-
throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat((0, _printer.
|
|
201
|
+
throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat((0, _printer.printForError)(valueNode), "."), valueNode);
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
coercedValues[name] = coercedValue;
|
package/execution/values.js.flow
CHANGED
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
VariableDefinitionNode,
|
|
15
15
|
} from '../language/ast';
|
|
16
16
|
import { Kind } from '../language/kinds';
|
|
17
|
-
import { print } from '../language/printer';
|
|
17
|
+
import { printForError as print } from '../language/printer';
|
|
18
18
|
|
|
19
19
|
import type { GraphQLSchema } from '../type/schema';
|
|
20
20
|
import type { GraphQLField } from '../type/definition';
|
|
@@ -44,7 +44,7 @@ export function getVariableValues(
|
|
|
44
44
|
schema: GraphQLSchema,
|
|
45
45
|
varDefNodes: $ReadOnlyArray<VariableDefinitionNode>,
|
|
46
46
|
inputs: { +[variable: string]: mixed, ... },
|
|
47
|
-
options?: {| maxErrors?: number |},
|
|
47
|
+
options?: {| maxErrors?: number, hideSuggestions?: ?boolean |},
|
|
48
48
|
): CoercedVariableValues {
|
|
49
49
|
const errors = [];
|
|
50
50
|
const maxErrors = options?.maxErrors;
|
|
@@ -61,6 +61,7 @@ export function getVariableValues(
|
|
|
61
61
|
}
|
|
62
62
|
errors.push(error);
|
|
63
63
|
},
|
|
64
|
+
options?.hideSuggestions,
|
|
64
65
|
);
|
|
65
66
|
|
|
66
67
|
if (errors.length === 0) {
|
|
@@ -78,6 +79,7 @@ function coerceVariableValues(
|
|
|
78
79
|
varDefNodes: $ReadOnlyArray<VariableDefinitionNode>,
|
|
79
80
|
inputs: { +[variable: string]: mixed, ... },
|
|
80
81
|
onError: (GraphQLError) => void,
|
|
82
|
+
hideSuggestions?: ?boolean,
|
|
81
83
|
): { [variable: string]: mixed, ... } {
|
|
82
84
|
const coercedValues = Object.create(null);
|
|
83
85
|
for (const varDefNode of varDefNodes) {
|
|
@@ -143,6 +145,7 @@ function coerceVariableValues(
|
|
|
143
145
|
),
|
|
144
146
|
);
|
|
145
147
|
},
|
|
148
|
+
hideSuggestions,
|
|
146
149
|
);
|
|
147
150
|
}
|
|
148
151
|
|
package/execution/values.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import inspect from "../jsutils/inspect.mjs";
|
|
|
10
10
|
import printPathArray from "../jsutils/printPathArray.mjs";
|
|
11
11
|
import { GraphQLError } from "../error/GraphQLError.mjs";
|
|
12
12
|
import { Kind } from "../language/kinds.mjs";
|
|
13
|
-
import { print } from "../language/printer.mjs";
|
|
13
|
+
import { printForError as print } from "../language/printer.mjs";
|
|
14
14
|
import { isInputType, isNonNullType } from "../type/definition.mjs";
|
|
15
15
|
import { typeFromAST } from "../utilities/typeFromAST.mjs";
|
|
16
16
|
import { valueFromAST } from "../utilities/valueFromAST.mjs";
|
|
@@ -38,7 +38,7 @@ export function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
errors.push(error);
|
|
41
|
-
});
|
|
41
|
+
}, options === null || options === void 0 ? void 0 : options.hideSuggestions);
|
|
42
42
|
|
|
43
43
|
if (errors.length === 0) {
|
|
44
44
|
return {
|
|
@@ -54,7 +54,7 @@ export function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
57
|
+
function coerceVariableValues(schema, varDefNodes, inputs, onError, hideSuggestions) {
|
|
58
58
|
var coercedValues = Object.create(null);
|
|
59
59
|
|
|
60
60
|
var _loop = function _loop(_i2) {
|
|
@@ -99,7 +99,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
onError(new GraphQLError(prefix + '; ' + error.message, varDefNode, undefined, undefined, undefined, error.originalError));
|
|
102
|
-
});
|
|
102
|
+
}, hideSuggestions);
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
for (var _i2 = 0; _i2 < varDefNodes.length; _i2++) {
|
package/graphql.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ import { ExecutionResult } from './execution/execute';
|
|
|
41
41
|
* value or method on the source value with the field's name).
|
|
42
42
|
*/
|
|
43
43
|
export interface GraphQLArgs {
|
|
44
|
+
hideSuggestions?: Maybe<boolean>;
|
|
44
45
|
schema: GraphQLSchema;
|
|
45
46
|
source: string | Source;
|
|
46
47
|
rootValue?: any;
|
package/graphql.js
CHANGED
|
@@ -96,7 +96,9 @@ function graphqlImpl(args) {
|
|
|
96
96
|
} // Validate
|
|
97
97
|
|
|
98
98
|
|
|
99
|
-
var validationErrors = (0, _validate.validate)(schema, document
|
|
99
|
+
var validationErrors = (0, _validate.validate)(schema, document, undefined, undefined, {
|
|
100
|
+
hideSuggestions: args.hideSuggestions
|
|
101
|
+
});
|
|
100
102
|
|
|
101
103
|
if (validationErrors.length > 0) {
|
|
102
104
|
return {
|
|
@@ -106,6 +108,7 @@ function graphqlImpl(args) {
|
|
|
106
108
|
|
|
107
109
|
|
|
108
110
|
return (0, _execute.execute)({
|
|
111
|
+
hideSuggestions: args.hideSuggestions,
|
|
109
112
|
schema: schema,
|
|
110
113
|
document: document,
|
|
111
114
|
rootValue: rootValue,
|
package/graphql.js.flow
CHANGED
|
@@ -57,6 +57,7 @@ import { execute } from './execution/execute';
|
|
|
57
57
|
* `__typename` field or alternatively calls the `isTypeOf` method).
|
|
58
58
|
*/
|
|
59
59
|
export type GraphQLArgs = {|
|
|
60
|
+
hideSuggestions?: ?boolean,
|
|
60
61
|
schema: GraphQLSchema,
|
|
61
62
|
source: string | Source,
|
|
62
63
|
rootValue?: mixed,
|
|
@@ -188,13 +189,16 @@ function graphqlImpl(args: GraphQLArgs): PromiseOrValue<ExecutionResult> {
|
|
|
188
189
|
}
|
|
189
190
|
|
|
190
191
|
// Validate
|
|
191
|
-
const validationErrors = validate(schema, document
|
|
192
|
+
const validationErrors = validate(schema, document, undefined, undefined, {
|
|
193
|
+
hideSuggestions: args.hideSuggestions,
|
|
194
|
+
});
|
|
192
195
|
if (validationErrors.length > 0) {
|
|
193
196
|
return { errors: validationErrors };
|
|
194
197
|
}
|
|
195
198
|
|
|
196
199
|
// Execute
|
|
197
200
|
return execute({
|
|
201
|
+
hideSuggestions: args.hideSuggestions,
|
|
198
202
|
schema,
|
|
199
203
|
document,
|
|
200
204
|
rootValue,
|
package/graphql.mjs
CHANGED
|
@@ -120,7 +120,9 @@ function graphqlImpl(args) {
|
|
|
120
120
|
} // Validate
|
|
121
121
|
|
|
122
122
|
|
|
123
|
-
var validationErrors = validate(schema, document
|
|
123
|
+
var validationErrors = validate(schema, document, undefined, undefined, {
|
|
124
|
+
hideSuggestions: args.hideSuggestions
|
|
125
|
+
});
|
|
124
126
|
|
|
125
127
|
if (validationErrors.length > 0) {
|
|
126
128
|
return {
|
|
@@ -130,6 +132,7 @@ function graphqlImpl(args) {
|
|
|
130
132
|
|
|
131
133
|
|
|
132
134
|
return execute({
|
|
135
|
+
hideSuggestions: args.hideSuggestions,
|
|
133
136
|
schema: schema,
|
|
134
137
|
document: document,
|
|
135
138
|
rootValue: rootValue,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SetMap = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Maps an order-independent set of member identities to a value.
|
|
10
|
+
* Each member receives a map-local ID; sorted IDs form the exact key.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
var SetMap = /*#__PURE__*/function () {
|
|
14
|
+
function SetMap() {
|
|
15
|
+
this._entries = new Map();
|
|
16
|
+
this._memberIds = new Map();
|
|
17
|
+
this._nextMemberId = 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var _proto = SetMap.prototype;
|
|
21
|
+
|
|
22
|
+
_proto.get = function get(members) {
|
|
23
|
+
return this._entries.get(this._key(members));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
_proto.set = function set(members, value) {
|
|
27
|
+
this._entries.set(this._key(members), value);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
_proto._key = function _key(members) {
|
|
31
|
+
var ids = [];
|
|
32
|
+
|
|
33
|
+
for (var _i2 = 0, _Array$from2 = Array.from(members); _i2 < _Array$from2.length; _i2++) {
|
|
34
|
+
var member = _Array$from2[_i2];
|
|
35
|
+
|
|
36
|
+
var id = this._memberIds.get(member);
|
|
37
|
+
|
|
38
|
+
if (id === undefined) {
|
|
39
|
+
id = this._nextMemberId++;
|
|
40
|
+
|
|
41
|
+
this._memberIds.set(member, id);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ids.push(id);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ids.sort(function (id1, id2) {
|
|
48
|
+
return id1 - id2;
|
|
49
|
+
});
|
|
50
|
+
return ids.join(',');
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return SetMap;
|
|
54
|
+
}();
|
|
55
|
+
|
|
56
|
+
exports.SetMap = SetMap;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
/**
|
|
3
|
+
* Maps an order-independent set of member identities to a value.
|
|
4
|
+
* Each member receives a map-local ID; sorted IDs form the exact key.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export class SetMap<T, V> {
|
|
8
|
+
_entries: Map<string, V>;
|
|
9
|
+
_memberIds: Map<T, number>;
|
|
10
|
+
_nextMemberId: number;
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
this._entries = new Map();
|
|
14
|
+
this._memberIds = new Map();
|
|
15
|
+
this._nextMemberId = 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get(members: $ReadOnlySet<T>): V | void {
|
|
19
|
+
return this._entries.get(this._key(members));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
set(members: $ReadOnlySet<T>, value: V): void {
|
|
23
|
+
this._entries.set(this._key(members), value);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_key(members: $ReadOnlySet<T>): string {
|
|
27
|
+
const ids: Array<number> = [];
|
|
28
|
+
for (const member of Array.from(members)) {
|
|
29
|
+
let id = this._memberIds.get(member);
|
|
30
|
+
if (id === undefined) {
|
|
31
|
+
id = this._nextMemberId++;
|
|
32
|
+
this._memberIds.set(member, id);
|
|
33
|
+
}
|
|
34
|
+
ids.push(id);
|
|
35
|
+
}
|
|
36
|
+
ids.sort((id1, id2) => id1 - id2);
|
|
37
|
+
return ids.join(',');
|
|
38
|
+
}
|
|
39
|
+
}
|