graphql 15.10.3 → 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 -1
- 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
|
@@ -69,7 +69,7 @@ function ValuesOfCorrectTypeRule(context) {
|
|
|
69
69
|
var fieldType = context.getInputType();
|
|
70
70
|
|
|
71
71
|
if (!fieldType && (0, _definition.isInputObjectType)(parentType)) {
|
|
72
|
-
var suggestions = (0, _suggestionList.default)(node.name.value, Object.keys(parentType.getFields()));
|
|
72
|
+
var suggestions = context.hideSuggestions ? [] : (0, _suggestionList.default)(node.name.value, Object.keys(parentType.getFields()));
|
|
73
73
|
context.reportError(new _GraphQLError.GraphQLError("Field \"".concat(node.name.value, "\" is not defined by type \"").concat(parentType.name, "\".") + (0, _didYouMean.default)(suggestions), node));
|
|
74
74
|
}
|
|
75
75
|
},
|
|
@@ -77,7 +77,7 @@ function ValuesOfCorrectTypeRule(context) {
|
|
|
77
77
|
var type = context.getInputType();
|
|
78
78
|
|
|
79
79
|
if ((0, _definition.isNonNullType)(type)) {
|
|
80
|
-
context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat((0, _inspect.default)(type), "\", found ").concat((0, _printer.
|
|
80
|
+
context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat((0, _inspect.default)(type), "\", found ").concat((0, _printer.printForError)(node), "."), node));
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
EnumValue: function EnumValue(node) {
|
|
@@ -115,21 +115,21 @@ function isValidValueNode(context, node) {
|
|
|
115
115
|
|
|
116
116
|
if (!(0, _definition.isLeafType)(type)) {
|
|
117
117
|
var typeStr = (0, _inspect.default)(locationType);
|
|
118
|
-
context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(typeStr, "\", found ").concat((0, _printer.
|
|
118
|
+
context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(typeStr, "\", found ").concat((0, _printer.printForError)(node), "."), node));
|
|
119
119
|
return;
|
|
120
120
|
} // Scalars and Enums determine if a literal value is valid via parseLiteral(),
|
|
121
121
|
// which may throw or return an invalid value to indicate failure.
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
try {
|
|
125
|
-
var parseResult = type.parseLiteral(node, undefined
|
|
125
|
+
var parseResult = (0, _definition.isEnumType)(type) ? type.parseLiteral(node, undefined, context.hideSuggestions) : type.parseLiteral(node, undefined
|
|
126
126
|
/* variables */
|
|
127
127
|
);
|
|
128
128
|
|
|
129
129
|
if (parseResult === undefined) {
|
|
130
130
|
var _typeStr = (0, _inspect.default)(locationType);
|
|
131
131
|
|
|
132
|
-
context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(_typeStr, "\", found ").concat((0, _printer.
|
|
132
|
+
context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(_typeStr, "\", found ").concat((0, _printer.printForError)(node), "."), node));
|
|
133
133
|
}
|
|
134
134
|
} catch (error) {
|
|
135
135
|
var _typeStr2 = (0, _inspect.default)(locationType);
|
|
@@ -137,7 +137,7 @@ function isValidValueNode(context, node) {
|
|
|
137
137
|
if (error instanceof _GraphQLError.GraphQLError) {
|
|
138
138
|
context.reportError(error);
|
|
139
139
|
} else {
|
|
140
|
-
context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(_typeStr2, "\", found ").concat((0, _printer.
|
|
140
|
+
context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(_typeStr2, "\", found ").concat((0, _printer.printForError)(node), "; ") + error.message, node, undefined, undefined, undefined, error));
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -10,11 +10,12 @@ import { GraphQLError } from '../../error/GraphQLError';
|
|
|
10
10
|
|
|
11
11
|
import type { ValueNode } from '../../language/ast';
|
|
12
12
|
import type { ASTVisitor } from '../../language/visitor';
|
|
13
|
-
import { print } from '../../language/printer';
|
|
13
|
+
import { printForError as print } from '../../language/printer';
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
isLeafType,
|
|
17
17
|
isInputObjectType,
|
|
18
|
+
isEnumType,
|
|
18
19
|
isListType,
|
|
19
20
|
isNonNullType,
|
|
20
21
|
isRequiredInputField,
|
|
@@ -68,10 +69,12 @@ export function ValuesOfCorrectTypeRule(
|
|
|
68
69
|
const parentType = getNamedType(context.getParentInputType());
|
|
69
70
|
const fieldType = context.getInputType();
|
|
70
71
|
if (!fieldType && isInputObjectType(parentType)) {
|
|
71
|
-
const suggestions =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
const suggestions = context.hideSuggestions
|
|
73
|
+
? []
|
|
74
|
+
: suggestionList(
|
|
75
|
+
node.name.value,
|
|
76
|
+
Object.keys(parentType.getFields()),
|
|
77
|
+
);
|
|
75
78
|
context.reportError(
|
|
76
79
|
new GraphQLError(
|
|
77
80
|
`Field "${node.name.value}" is not defined by type "${parentType.name}".` +
|
|
@@ -127,7 +130,9 @@ function isValidValueNode(context: ValidationContext, node: ValueNode): void {
|
|
|
127
130
|
// Scalars and Enums determine if a literal value is valid via parseLiteral(),
|
|
128
131
|
// which may throw or return an invalid value to indicate failure.
|
|
129
132
|
try {
|
|
130
|
-
const parseResult = type
|
|
133
|
+
const parseResult = isEnumType(type)
|
|
134
|
+
? type.parseLiteral(node, undefined, context.hideSuggestions)
|
|
135
|
+
: type.parseLiteral(node, undefined /* variables */);
|
|
131
136
|
if (parseResult === undefined) {
|
|
132
137
|
const typeStr = inspect(locationType);
|
|
133
138
|
context.reportError(
|
|
@@ -4,8 +4,8 @@ import inspect from "../../jsutils/inspect.mjs";
|
|
|
4
4
|
import didYouMean from "../../jsutils/didYouMean.mjs";
|
|
5
5
|
import suggestionList from "../../jsutils/suggestionList.mjs";
|
|
6
6
|
import { GraphQLError } from "../../error/GraphQLError.mjs";
|
|
7
|
-
import { print } from "../../language/printer.mjs";
|
|
8
|
-
import { isLeafType, isInputObjectType, isListType, isNonNullType, isRequiredInputField, getNullableType, getNamedType } from "../../type/definition.mjs";
|
|
7
|
+
import { printForError as print } from "../../language/printer.mjs";
|
|
8
|
+
import { isLeafType, isInputObjectType, isEnumType, isListType, isNonNullType, isRequiredInputField, getNullableType, getNamedType } from "../../type/definition.mjs";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Value literals of correct type
|
|
@@ -53,7 +53,7 @@ export function ValuesOfCorrectTypeRule(context) {
|
|
|
53
53
|
var fieldType = context.getInputType();
|
|
54
54
|
|
|
55
55
|
if (!fieldType && isInputObjectType(parentType)) {
|
|
56
|
-
var suggestions = suggestionList(node.name.value, Object.keys(parentType.getFields()));
|
|
56
|
+
var suggestions = context.hideSuggestions ? [] : suggestionList(node.name.value, Object.keys(parentType.getFields()));
|
|
57
57
|
context.reportError(new GraphQLError("Field \"".concat(node.name.value, "\" is not defined by type \"").concat(parentType.name, "\".") + didYouMean(suggestions), node));
|
|
58
58
|
}
|
|
59
59
|
},
|
|
@@ -105,7 +105,7 @@ function isValidValueNode(context, node) {
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
try {
|
|
108
|
-
var parseResult = type.parseLiteral(node, undefined
|
|
108
|
+
var parseResult = isEnumType(type) ? type.parseLiteral(node, undefined, context.hideSuggestions) : type.parseLiteral(node, undefined
|
|
109
109
|
/* variables */
|
|
110
110
|
);
|
|
111
111
|
|
package/validation/validate.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export function validate(
|
|
|
31
31
|
documentAST: DocumentNode,
|
|
32
32
|
rules?: ReadonlyArray<ValidationRule>,
|
|
33
33
|
typeInfo?: TypeInfo,
|
|
34
|
-
options?: { maxErrors?: number },
|
|
34
|
+
options?: { maxErrors?: number; hideSuggestions?: boolean | null },
|
|
35
35
|
): ReadonlyArray<GraphQLError>;
|
|
36
36
|
|
|
37
37
|
/**
|
package/validation/validate.js
CHANGED
|
@@ -20,6 +20,8 @@ var _TypeInfo = require("../utilities/TypeInfo.js");
|
|
|
20
20
|
|
|
21
21
|
var _specifiedRules = require("./specifiedRules.js");
|
|
22
22
|
|
|
23
|
+
var _validationAbortedError = require("./validationAbortedError.js");
|
|
24
|
+
|
|
23
25
|
var _ValidationContext = require("./ValidationContext.js");
|
|
24
26
|
|
|
25
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -58,7 +60,7 @@ function validate(schema, documentAST) {
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
errors.push(error);
|
|
61
|
-
}); // This uses a specialized visitor which runs multiple visitors in parallel,
|
|
63
|
+
}, options.hideSuggestions); // This uses a specialized visitor which runs multiple visitors in parallel,
|
|
62
64
|
// while maintaining the visitor skip and break API.
|
|
63
65
|
|
|
64
66
|
var visitor = (0, _visitor.visitInParallel)(rules.map(function (rule) {
|
|
@@ -68,7 +70,9 @@ function validate(schema, documentAST) {
|
|
|
68
70
|
try {
|
|
69
71
|
(0, _visitor.visit)(documentAST, (0, _TypeInfo.visitWithTypeInfo)(typeInfo, visitor));
|
|
70
72
|
} catch (e) {
|
|
71
|
-
if (e
|
|
73
|
+
if (e === _validationAbortedError.validationAbortedError) {
|
|
74
|
+
errors.push(_validationAbortedError.validationAbortedError);
|
|
75
|
+
} else if (e !== abortObj) {
|
|
72
76
|
throw e;
|
|
73
77
|
}
|
|
74
78
|
}
|
|
@@ -13,6 +13,7 @@ import { TypeInfo, visitWithTypeInfo } from '../utilities/TypeInfo';
|
|
|
13
13
|
|
|
14
14
|
import type { SDLValidationRule, ValidationRule } from './ValidationContext';
|
|
15
15
|
import { specifiedRules, specifiedSDLRules } from './specifiedRules';
|
|
16
|
+
import { validationAbortedError } from './validationAbortedError';
|
|
16
17
|
import { SDLValidationContext, ValidationContext } from './ValidationContext';
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -36,7 +37,9 @@ export function validate(
|
|
|
36
37
|
documentAST: DocumentNode,
|
|
37
38
|
rules: $ReadOnlyArray<ValidationRule> = specifiedRules,
|
|
38
39
|
typeInfo: TypeInfo = new TypeInfo(schema),
|
|
39
|
-
options: {| maxErrors?: number |} = {
|
|
40
|
+
options: $ReadOnly<{| maxErrors?: number, hideSuggestions?: ?boolean |}> = {
|
|
41
|
+
maxErrors: undefined,
|
|
42
|
+
},
|
|
40
43
|
): $ReadOnlyArray<GraphQLError> {
|
|
41
44
|
devAssert(documentAST, 'Must provide document.');
|
|
42
45
|
// If the schema used for validation is invalid, throw an error.
|
|
@@ -59,6 +62,7 @@ export function validate(
|
|
|
59
62
|
}
|
|
60
63
|
errors.push(error);
|
|
61
64
|
},
|
|
65
|
+
options.hideSuggestions,
|
|
62
66
|
);
|
|
63
67
|
|
|
64
68
|
// This uses a specialized visitor which runs multiple visitors in parallel,
|
|
@@ -69,7 +73,9 @@ export function validate(
|
|
|
69
73
|
try {
|
|
70
74
|
visit(documentAST, visitWithTypeInfo(typeInfo, visitor));
|
|
71
75
|
} catch (e) {
|
|
72
|
-
if (e
|
|
76
|
+
if (e === validationAbortedError) {
|
|
77
|
+
errors.push(validationAbortedError);
|
|
78
|
+
} else if (e !== abortObj) {
|
|
73
79
|
throw e;
|
|
74
80
|
}
|
|
75
81
|
}
|
package/validation/validate.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { visit, visitInParallel } from "../language/visitor.mjs";
|
|
|
4
4
|
import { assertValidSchema } from "../type/validate.mjs";
|
|
5
5
|
import { TypeInfo, visitWithTypeInfo } from "../utilities/TypeInfo.mjs";
|
|
6
6
|
import { specifiedRules, specifiedSDLRules } from "./specifiedRules.mjs";
|
|
7
|
+
import { validationAbortedError } from "./validationAbortedError.mjs";
|
|
7
8
|
import { SDLValidationContext, ValidationContext } from "./ValidationContext.mjs";
|
|
8
9
|
/**
|
|
9
10
|
* Implements the "Validation" section of the spec.
|
|
@@ -40,7 +41,7 @@ export function validate(schema, documentAST) {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
errors.push(error);
|
|
43
|
-
}); // This uses a specialized visitor which runs multiple visitors in parallel,
|
|
44
|
+
}, options.hideSuggestions); // This uses a specialized visitor which runs multiple visitors in parallel,
|
|
44
45
|
// while maintaining the visitor skip and break API.
|
|
45
46
|
|
|
46
47
|
var visitor = visitInParallel(rules.map(function (rule) {
|
|
@@ -50,7 +51,9 @@ export function validate(schema, documentAST) {
|
|
|
50
51
|
try {
|
|
51
52
|
visit(documentAST, visitWithTypeInfo(typeInfo, visitor));
|
|
52
53
|
} catch (e) {
|
|
53
|
-
if (e
|
|
54
|
+
if (e === validationAbortedError) {
|
|
55
|
+
errors.push(validationAbortedError);
|
|
56
|
+
} else if (e !== abortObj) {
|
|
54
57
|
throw e;
|
|
55
58
|
}
|
|
56
59
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validationAbortedError = void 0;
|
|
7
|
+
|
|
8
|
+
var _GraphQLError = require("../error/GraphQLError.js");
|
|
9
|
+
|
|
10
|
+
/** @internal */
|
|
11
|
+
var validationAbortedError = new _GraphQLError.GraphQLError('Validation aborted.');
|
|
12
|
+
exports.validationAbortedError = validationAbortedError;
|
package/version.js
CHANGED
|
@@ -13,7 +13,7 @@ exports.versionInfo = exports.version = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* A string containing the version of the GraphQL.js library
|
|
15
15
|
*/
|
|
16
|
-
var version = '15.
|
|
16
|
+
var version = '15.11.0';
|
|
17
17
|
/**
|
|
18
18
|
* An object containing the components of the GraphQL.js version string
|
|
19
19
|
*/
|
|
@@ -21,8 +21,8 @@ var version = '15.10.3';
|
|
|
21
21
|
exports.version = version;
|
|
22
22
|
var versionInfo = Object.freeze({
|
|
23
23
|
major: 15,
|
|
24
|
-
minor:
|
|
25
|
-
patch:
|
|
24
|
+
minor: 11,
|
|
25
|
+
patch: 0,
|
|
26
26
|
preReleaseTag: null
|
|
27
27
|
});
|
|
28
28
|
exports.versionInfo = versionInfo;
|
package/version.js.flow
CHANGED
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* A string containing the version of the GraphQL.js library
|
|
9
9
|
*/
|
|
10
|
-
export const version = '15.
|
|
10
|
+
export const version = '15.11.0';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* An object containing the components of the GraphQL.js version string
|
|
14
14
|
*/
|
|
15
15
|
export const versionInfo = Object.freeze({
|
|
16
16
|
major: 15,
|
|
17
|
-
minor:
|
|
18
|
-
patch:
|
|
17
|
+
minor: 11,
|
|
18
|
+
patch: 0,
|
|
19
19
|
preReleaseTag: null,
|
|
20
20
|
});
|
package/version.mjs
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* A string containing the version of the GraphQL.js library
|
|
8
8
|
*/
|
|
9
|
-
export var version = '15.
|
|
9
|
+
export var version = '15.11.0';
|
|
10
10
|
/**
|
|
11
11
|
* An object containing the components of the GraphQL.js version string
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
export var versionInfo = Object.freeze({
|
|
15
15
|
major: 15,
|
|
16
|
-
minor:
|
|
17
|
-
patch:
|
|
16
|
+
minor: 11,
|
|
17
|
+
patch: 0,
|
|
18
18
|
preReleaseTag: null
|
|
19
19
|
});
|