graphql 16.14.2 → 16.15.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.d.ts +5 -1
- package/error/GraphQLError.js +12 -7
- package/error/GraphQLError.mjs +13 -6
- package/error/locatedError.d.ts +6 -4
- package/error/locatedError.js +6 -4
- package/error/locatedError.mjs +6 -4
- package/execution/collectFields.d.ts +1 -0
- package/execution/collectFields.js +9 -0
- package/execution/collectFields.mjs +9 -0
- package/execution/execute.d.ts +9 -10
- package/execution/execute.js +44 -29
- package/execution/execute.mjs +44 -29
- package/execution/mapAsyncIterator.js +12 -11
- package/execution/mapAsyncIterator.mjs +12 -11
- package/execution/subscribe.d.ts +5 -2
- package/execution/subscribe.js +5 -2
- package/execution/subscribe.mjs +5 -2
- package/execution/values.d.ts +43 -21
- package/execution/values.js +52 -24
- package/execution/values.mjs +51 -23
- package/graphql.d.ts +8 -14
- package/graphql.js +16 -15
- package/graphql.mjs +11 -15
- package/jsutils/SetMap.d.ts +14 -0
- package/jsutils/SetMap.js +48 -0
- package/jsutils/SetMap.mjs +39 -0
- package/jsutils/isIterableObject.d.ts +2 -0
- package/jsutils/isIterableObject.js +2 -0
- package/jsutils/isIterableObject.mjs +2 -0
- package/jsutils/keyMap.d.ts +2 -0
- package/jsutils/keyMap.js +2 -0
- package/jsutils/keyMap.mjs +2 -0
- package/jsutils/keyValMap.d.ts +3 -3
- package/jsutils/keyValMap.js +3 -3
- package/jsutils/keyValMap.mjs +3 -3
- package/language/ast.d.ts +2 -6
- package/language/ast.js +2 -6
- package/language/ast.mjs +2 -6
- package/language/lexer.d.ts +6 -0
- package/language/lexer.js +22 -0
- package/language/lexer.mjs +22 -0
- package/language/location.d.ts +8 -3
- package/language/location.js +57 -17
- package/language/location.mjs +56 -16
- package/language/parser.d.ts +27 -13
- package/language/parser.js +31 -9
- package/language/parser.mjs +31 -9
- package/language/predicates.d.ts +10 -3
- package/language/predicates.js +10 -3
- package/language/predicates.mjs +10 -3
- package/language/printLocation.d.ts +2 -6
- package/language/printLocation.js +2 -6
- package/language/printLocation.mjs +2 -6
- package/language/printer.d.ts +22 -3
- package/language/printer.js +394 -308
- package/language/printer.mjs +394 -308
- package/language/reducer.d.ts +32 -0
- package/language/reducer.js +95 -0
- package/language/reducer.mjs +86 -0
- package/language/source.d.ts +4 -5
- package/language/source.js +4 -5
- package/language/source.mjs +4 -5
- package/language/visitor.d.ts +16 -10
- package/language/visitor.js +15 -7
- package/language/visitor.mjs +15 -7
- package/package.json +1 -4
- package/type/definition.d.ts +170 -102
- package/type/definition.js +169 -96
- package/type/definition.mjs +168 -95
- package/type/directives.d.ts +12 -6
- package/type/directives.js +12 -6
- package/type/directives.mjs +12 -6
- package/type/scalars.js +8 -11
- package/type/scalars.mjs +1 -1
- package/type/schema.d.ts +36 -11
- package/type/schema.js +35 -10
- package/type/schema.mjs +35 -10
- package/type/validate.d.ts +1 -3
- package/type/validate.js +1 -3
- package/type/validate.mjs +1 -3
- package/utilities/TypeInfo.d.ts +15 -11
- package/utilities/TypeInfo.js +15 -11
- package/utilities/TypeInfo.mjs +15 -11
- package/utilities/assertValidName.d.ts +1 -1
- package/utilities/assertValidName.js +1 -1
- package/utilities/assertValidName.mjs +1 -1
- package/utilities/astFromValue.d.ts +3 -1
- package/utilities/astFromValue.js +3 -1
- package/utilities/astFromValue.mjs +3 -1
- package/utilities/buildASTSchema.d.ts +8 -8
- package/utilities/buildASTSchema.js +9 -20
- package/utilities/buildASTSchema.mjs +9 -20
- package/utilities/buildClientSchema.d.ts +6 -2
- package/utilities/buildClientSchema.js +6 -2
- package/utilities/buildClientSchema.mjs +6 -2
- package/utilities/coerceInputValue.d.ts +9 -3
- package/utilities/coerceInputValue.js +60 -13
- package/utilities/coerceInputValue.mjs +58 -13
- package/utilities/concatAST.d.ts +4 -1
- package/utilities/concatAST.js +4 -1
- package/utilities/concatAST.mjs +4 -1
- package/utilities/extendSchema.d.ts +7 -4
- package/utilities/extendSchema.js +7 -4
- package/utilities/extendSchema.mjs +7 -4
- package/utilities/findBreakingChanges.d.ts +2 -2
- package/utilities/findBreakingChanges.js +2 -2
- package/utilities/findBreakingChanges.mjs +2 -2
- package/utilities/getIntrospectionQuery.d.ts +9 -9
- package/utilities/getIntrospectionQuery.js +8 -8
- package/utilities/getIntrospectionQuery.mjs +8 -8
- package/utilities/getOperationAST.d.ts +2 -2
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.d.ts +3 -1
- package/utilities/getOperationRootType.js +3 -1
- package/utilities/getOperationRootType.mjs +3 -1
- package/utilities/introspectionFromSchema.d.ts +12 -4
- package/utilities/introspectionFromSchema.js +12 -4
- package/utilities/introspectionFromSchema.mjs +12 -4
- package/utilities/lexicographicSortSchema.d.ts +17 -13
- package/utilities/lexicographicSortSchema.js +17 -13
- package/utilities/lexicographicSortSchema.mjs +17 -13
- package/utilities/printSchema.d.ts +7 -4
- package/utilities/printSchema.js +7 -4
- package/utilities/printSchema.mjs +7 -4
- package/utilities/resolveSchemaCoordinate.d.ts +9 -8
- package/utilities/resolveSchemaCoordinate.js +9 -8
- package/utilities/resolveSchemaCoordinate.mjs +9 -8
- package/utilities/separateOperations.d.ts +2 -2
- package/utilities/separateOperations.js +2 -2
- package/utilities/separateOperations.mjs +2 -2
- package/utilities/stripIgnoredCharacters.d.ts +19 -5
- package/utilities/stripIgnoredCharacters.js +19 -5
- package/utilities/stripIgnoredCharacters.mjs +19 -5
- package/utilities/typeComparators.d.ts +1 -5
- package/utilities/typeComparators.js +1 -5
- package/utilities/typeComparators.mjs +1 -5
- package/utilities/valueFromAST.js +4 -4
- package/utilities/valueFromAST.mjs +4 -4
- package/utilities/valueFromASTUntyped.d.ts +1 -3
- package/utilities/valueFromASTUntyped.js +1 -3
- package/utilities/valueFromASTUntyped.mjs +1 -3
- package/validation/ValidationContext.d.ts +22 -3
- package/validation/ValidationContext.js +84 -27
- package/validation/ValidationContext.mjs +82 -27
- package/validation/rules/ExecutableDefinitionsRule.d.ts +6 -4
- package/validation/rules/ExecutableDefinitionsRule.js +6 -4
- package/validation/rules/ExecutableDefinitionsRule.mjs +6 -4
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +4 -4
- package/validation/rules/FieldsOnCorrectTypeRule.js +10 -6
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +12 -6
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +6 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.js +6 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +6 -4
- package/validation/rules/KnownArgumentNamesRule.d.ts +4 -4
- package/validation/rules/KnownArgumentNamesRule.js +26 -17
- package/validation/rules/KnownArgumentNamesRule.mjs +21 -11
- package/validation/rules/KnownDirectivesRule.d.ts +1 -3
- package/validation/rules/KnownDirectivesRule.js +1 -3
- package/validation/rules/KnownDirectivesRule.mjs +1 -3
- package/validation/rules/KnownFragmentNamesRule.d.ts +4 -4
- package/validation/rules/KnownFragmentNamesRule.js +4 -4
- package/validation/rules/KnownFragmentNamesRule.mjs +4 -4
- package/validation/rules/KnownTypeNamesRule.d.ts +1 -3
- package/validation/rules/KnownTypeNamesRule.js +7 -7
- package/validation/rules/KnownTypeNamesRule.mjs +7 -7
- package/validation/rules/LoneAnonymousOperationRule.d.ts +6 -4
- package/validation/rules/LoneAnonymousOperationRule.js +6 -4
- package/validation/rules/LoneAnonymousOperationRule.mjs +6 -4
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +6 -4
- package/validation/rules/MaxIntrospectionDepthRule.js +44 -19
- package/validation/rules/MaxIntrospectionDepthRule.mjs +44 -19
- package/validation/rules/NoFragmentCyclesRule.d.ts +1 -3
- package/validation/rules/NoFragmentCyclesRule.js +1 -3
- package/validation/rules/NoFragmentCyclesRule.mjs +1 -3
- package/validation/rules/NoUndefinedVariablesRule.d.ts +4 -4
- package/validation/rules/NoUndefinedVariablesRule.js +4 -4
- package/validation/rules/NoUndefinedVariablesRule.mjs +4 -4
- package/validation/rules/NoUnusedFragmentsRule.d.ts +4 -4
- package/validation/rules/NoUnusedFragmentsRule.js +10 -14
- package/validation/rules/NoUnusedFragmentsRule.mjs +10 -14
- package/validation/rules/NoUnusedVariablesRule.d.ts +4 -4
- package/validation/rules/NoUnusedVariablesRule.js +4 -4
- package/validation/rules/NoUnusedVariablesRule.mjs +4 -4
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +8 -6
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +552 -354
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +545 -352
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +6 -4
- package/validation/rules/PossibleFragmentSpreadsRule.js +6 -4
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.js +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +6 -4
- package/validation/rules/ScalarLeafsRule.d.ts +1 -3
- package/validation/rules/ScalarLeafsRule.js +1 -3
- package/validation/rules/ScalarLeafsRule.mjs +1 -3
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +6 -4
- package/validation/rules/SingleFieldSubscriptionsRule.js +50 -9
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +50 -9
- package/validation/rules/UniqueArgumentNamesRule.d.ts +4 -4
- package/validation/rules/UniqueArgumentNamesRule.js +4 -4
- package/validation/rules/UniqueArgumentNamesRule.mjs +4 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +6 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.js +6 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +6 -4
- package/validation/rules/UniqueFragmentNamesRule.d.ts +4 -4
- package/validation/rules/UniqueFragmentNamesRule.js +4 -4
- package/validation/rules/UniqueFragmentNamesRule.mjs +4 -4
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +6 -4
- package/validation/rules/UniqueInputFieldNamesRule.js +6 -4
- package/validation/rules/UniqueInputFieldNamesRule.mjs +6 -4
- package/validation/rules/UniqueOperationNamesRule.d.ts +4 -4
- package/validation/rules/UniqueOperationNamesRule.js +4 -4
- package/validation/rules/UniqueOperationNamesRule.mjs +4 -4
- package/validation/rules/UniqueVariableNamesRule.d.ts +4 -4
- package/validation/rules/UniqueVariableNamesRule.js +4 -4
- package/validation/rules/UniqueVariableNamesRule.mjs +4 -4
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +4 -4
- package/validation/rules/ValuesOfCorrectTypeRule.js +29 -23
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +24 -14
- package/validation/rules/VariablesAreInputTypesRule.d.ts +6 -4
- package/validation/rules/VariablesAreInputTypesRule.js +6 -4
- package/validation/rules/VariablesAreInputTypesRule.mjs +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.js +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.mjs +6 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +4 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.js +4 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +4 -4
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +7 -5
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +7 -5
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +7 -5
- package/validation/validate.d.ts +2 -0
- package/validation/validate.js +14 -2
- package/validation/validate.mjs +13 -2
- package/validation/validationAbortedError.d.ts +3 -0
- package/validation/validationAbortedError.js +14 -0
- package/validation/validationAbortedError.mjs +4 -0
- package/version.js +3 -3
- package/version.mjs +3 -3
|
@@ -23,16 +23,16 @@ import type { ASTValidationContext } from '../ValidationContext';
|
|
|
23
23
|
* const invalidDocument = parse(`
|
|
24
24
|
* query Same { name } query Same { name }
|
|
25
25
|
* `);
|
|
26
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
26
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* UniqueOperationNamesRule,
|
|
28
|
+
* ]);
|
|
27
29
|
*
|
|
28
30
|
* invalidErrors.length; // => 1
|
|
29
31
|
*
|
|
30
32
|
* const validDocument = parse(`
|
|
31
33
|
* query One { name } query Two { name }
|
|
32
34
|
* `);
|
|
33
|
-
* const validErrors = validate(schema, validDocument, [UniqueOperationNamesRule]);
|
|
34
|
-
*
|
|
35
|
-
* validErrors; // => []
|
|
35
|
+
* const validErrors = validate(schema, validDocument, [UniqueOperationNamesRule]); // => []
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export declare function UniqueOperationNamesRule(
|
|
@@ -31,16 +31,16 @@ var _GraphQLError = require('../../error/GraphQLError.js');
|
|
|
31
31
|
* const invalidDocument = parse(`
|
|
32
32
|
* query Same { name } query Same { name }
|
|
33
33
|
* `);
|
|
34
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
34
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
35
|
+
* UniqueOperationNamesRule,
|
|
36
|
+
* ]);
|
|
35
37
|
*
|
|
36
38
|
* invalidErrors.length; // => 1
|
|
37
39
|
*
|
|
38
40
|
* const validDocument = parse(`
|
|
39
41
|
* query One { name } query Two { name }
|
|
40
42
|
* `);
|
|
41
|
-
* const validErrors = validate(schema, validDocument, [UniqueOperationNamesRule]);
|
|
42
|
-
*
|
|
43
|
-
* validErrors; // => []
|
|
43
|
+
* const validErrors = validate(schema, validDocument, [UniqueOperationNamesRule]); // => []
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
function UniqueOperationNamesRule(context) {
|
|
@@ -23,16 +23,16 @@ import { GraphQLError } from '../../error/GraphQLError.mjs';
|
|
|
23
23
|
* const invalidDocument = parse(`
|
|
24
24
|
* query Same { name } query Same { name }
|
|
25
25
|
* `);
|
|
26
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
26
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* UniqueOperationNamesRule,
|
|
28
|
+
* ]);
|
|
27
29
|
*
|
|
28
30
|
* invalidErrors.length; // => 1
|
|
29
31
|
*
|
|
30
32
|
* const validDocument = parse(`
|
|
31
33
|
* query One { name } query Two { name }
|
|
32
34
|
* `);
|
|
33
|
-
* const validErrors = validate(schema, validDocument, [UniqueOperationNamesRule]);
|
|
34
|
-
*
|
|
35
|
-
* validErrors; // => []
|
|
35
|
+
* const validErrors = validate(schema, validDocument, [UniqueOperationNamesRule]); // => []
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export function UniqueOperationNamesRule(context) {
|
|
@@ -21,16 +21,16 @@ import type { ASTValidationContext } from '../ValidationContext';
|
|
|
21
21
|
* const invalidDocument = parse(`
|
|
22
22
|
* query ($id: ID, $id: ID) { field(arg: $id) }
|
|
23
23
|
* `);
|
|
24
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
24
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
25
|
+
* UniqueVariableNamesRule,
|
|
26
|
+
* ]);
|
|
25
27
|
*
|
|
26
28
|
* invalidErrors.length; // => 1
|
|
27
29
|
*
|
|
28
30
|
* const validDocument = parse(`
|
|
29
31
|
* query ($id: ID) { field(arg: $id) }
|
|
30
32
|
* `);
|
|
31
|
-
* const validErrors = validate(schema, validDocument, [UniqueVariableNamesRule]);
|
|
32
|
-
*
|
|
33
|
-
* validErrors; // => []
|
|
33
|
+
* const validErrors = validate(schema, validDocument, [UniqueVariableNamesRule]); // => []
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
36
|
export declare function UniqueVariableNamesRule(
|
|
@@ -31,16 +31,16 @@ var _GraphQLError = require('../../error/GraphQLError.js');
|
|
|
31
31
|
* const invalidDocument = parse(`
|
|
32
32
|
* query ($id: ID, $id: ID) { field(arg: $id) }
|
|
33
33
|
* `);
|
|
34
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
34
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
35
|
+
* UniqueVariableNamesRule,
|
|
36
|
+
* ]);
|
|
35
37
|
*
|
|
36
38
|
* invalidErrors.length; // => 1
|
|
37
39
|
*
|
|
38
40
|
* const validDocument = parse(`
|
|
39
41
|
* query ($id: ID) { field(arg: $id) }
|
|
40
42
|
* `);
|
|
41
|
-
* const validErrors = validate(schema, validDocument, [UniqueVariableNamesRule]);
|
|
42
|
-
*
|
|
43
|
-
* validErrors; // => []
|
|
43
|
+
* const validErrors = validate(schema, validDocument, [UniqueVariableNamesRule]); // => []
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
function UniqueVariableNamesRule(context) {
|
|
@@ -22,16 +22,16 @@ import { GraphQLError } from '../../error/GraphQLError.mjs';
|
|
|
22
22
|
* const invalidDocument = parse(`
|
|
23
23
|
* query ($id: ID, $id: ID) { field(arg: $id) }
|
|
24
24
|
* `);
|
|
25
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
25
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
26
|
+
* UniqueVariableNamesRule,
|
|
27
|
+
* ]);
|
|
26
28
|
*
|
|
27
29
|
* invalidErrors.length; // => 1
|
|
28
30
|
*
|
|
29
31
|
* const validDocument = parse(`
|
|
30
32
|
* query ($id: ID) { field(arg: $id) }
|
|
31
33
|
* `);
|
|
32
|
-
* const validErrors = validate(schema, validDocument, [UniqueVariableNamesRule]);
|
|
33
|
-
*
|
|
34
|
-
* validErrors; // => []
|
|
34
|
+
* const validErrors = validate(schema, validDocument, [UniqueVariableNamesRule]); // => []
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
37
|
export function UniqueVariableNamesRule(context) {
|
|
@@ -24,16 +24,16 @@ import type { ValidationContext } from '../ValidationContext';
|
|
|
24
24
|
* const invalidDocument = parse(`
|
|
25
25
|
* { count(limit: "many") }
|
|
26
26
|
* `);
|
|
27
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
28
|
+
* ValuesOfCorrectTypeRule,
|
|
29
|
+
* ]);
|
|
28
30
|
*
|
|
29
31
|
* invalidErrors.length; // => 1
|
|
30
32
|
*
|
|
31
33
|
* const validDocument = parse(`
|
|
32
34
|
* { count(limit: 1) }
|
|
33
35
|
* `);
|
|
34
|
-
* const validErrors = validate(schema, validDocument, [ValuesOfCorrectTypeRule]);
|
|
35
|
-
*
|
|
36
|
-
* validErrors; // => []
|
|
36
|
+
* const validErrors = validate(schema, validDocument, [ValuesOfCorrectTypeRule]); // => []
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
export declare function ValuesOfCorrectTypeRule(
|
|
@@ -46,16 +46,16 @@ var _definition = require('../../type/definition.js');
|
|
|
46
46
|
* const invalidDocument = parse(`
|
|
47
47
|
* { count(limit: "many") }
|
|
48
48
|
* `);
|
|
49
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
49
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
50
|
+
* ValuesOfCorrectTypeRule,
|
|
51
|
+
* ]);
|
|
50
52
|
*
|
|
51
53
|
* invalidErrors.length; // => 1
|
|
52
54
|
*
|
|
53
55
|
* const validDocument = parse(`
|
|
54
56
|
* { count(limit: 1) }
|
|
55
57
|
* `);
|
|
56
|
-
* const validErrors = validate(schema, validDocument, [ValuesOfCorrectTypeRule]);
|
|
57
|
-
*
|
|
58
|
-
* validErrors; // => []
|
|
58
|
+
* const validErrors = validate(schema, validDocument, [ValuesOfCorrectTypeRule]); // => []
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
61
|
function ValuesOfCorrectTypeRule(context) {
|
|
@@ -114,10 +114,12 @@ function ValuesOfCorrectTypeRule(context) {
|
|
|
114
114
|
const fieldType = context.getInputType();
|
|
115
115
|
|
|
116
116
|
if (!fieldType && (0, _definition.isInputObjectType)(parentType)) {
|
|
117
|
-
const suggestions =
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
const suggestions = context.hideSuggestions
|
|
118
|
+
? []
|
|
119
|
+
: (0, _suggestionList.suggestionList)(
|
|
120
|
+
node.name.value,
|
|
121
|
+
Object.keys(parentType.getFields()),
|
|
122
|
+
);
|
|
121
123
|
context.reportError(
|
|
122
124
|
new _GraphQLError.GraphQLError(
|
|
123
125
|
`Field "${node.name.value}" is not defined by type "${parentType.name}".` +
|
|
@@ -138,7 +140,7 @@ function ValuesOfCorrectTypeRule(context) {
|
|
|
138
140
|
new _GraphQLError.GraphQLError(
|
|
139
141
|
`Expected value of type "${(0, _inspect.inspect)(
|
|
140
142
|
type,
|
|
141
|
-
)}", found ${(0, _printer.
|
|
143
|
+
)}", found ${(0, _printer.printForError)(node)}.`,
|
|
142
144
|
{
|
|
143
145
|
nodes: node,
|
|
144
146
|
},
|
|
@@ -180,9 +182,8 @@ function isValidValueNode(context, node) {
|
|
|
180
182
|
const typeStr = (0, _inspect.inspect)(locationType);
|
|
181
183
|
context.reportError(
|
|
182
184
|
new _GraphQLError.GraphQLError(
|
|
183
|
-
`Expected value of type "${typeStr}", found ${(0,
|
|
184
|
-
|
|
185
|
-
)}.`,
|
|
185
|
+
`Expected value of type "${typeStr}", found ${(0,
|
|
186
|
+
_printer.printForError)(node)}.`,
|
|
186
187
|
{
|
|
187
188
|
nodes: node,
|
|
188
189
|
},
|
|
@@ -193,19 +194,25 @@ function isValidValueNode(context, node) {
|
|
|
193
194
|
// which may throw or return an invalid value to indicate failure.
|
|
194
195
|
|
|
195
196
|
try {
|
|
196
|
-
const parseResult =
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
const parseResult = (0, _definition.isEnumType)(type)
|
|
198
|
+
? type.parseLiteral(
|
|
199
|
+
node,
|
|
200
|
+
undefined,
|
|
201
|
+
/* variables */
|
|
202
|
+
context.hideSuggestions,
|
|
203
|
+
)
|
|
204
|
+
: type.parseLiteral(
|
|
205
|
+
node,
|
|
206
|
+
undefined,
|
|
207
|
+
/* variables */
|
|
208
|
+
);
|
|
201
209
|
|
|
202
210
|
if (parseResult === undefined) {
|
|
203
211
|
const typeStr = (0, _inspect.inspect)(locationType);
|
|
204
212
|
context.reportError(
|
|
205
213
|
new _GraphQLError.GraphQLError(
|
|
206
|
-
`Expected value of type "${typeStr}", found ${(0,
|
|
207
|
-
|
|
208
|
-
)}.`,
|
|
214
|
+
`Expected value of type "${typeStr}", found ${(0,
|
|
215
|
+
_printer.printForError)(node)}.`,
|
|
209
216
|
{
|
|
210
217
|
nodes: node,
|
|
211
218
|
},
|
|
@@ -220,9 +227,8 @@ function isValidValueNode(context, node) {
|
|
|
220
227
|
} else {
|
|
221
228
|
context.reportError(
|
|
222
229
|
new _GraphQLError.GraphQLError(
|
|
223
|
-
`Expected value of type "${typeStr}", found ${(0,
|
|
224
|
-
|
|
225
|
-
)}; ` + error.message,
|
|
230
|
+
`Expected value of type "${typeStr}", found ${(0,
|
|
231
|
+
_printer.printForError)(node)}; ` + error.message,
|
|
226
232
|
{
|
|
227
233
|
nodes: node,
|
|
228
234
|
originalError: error,
|
|
@@ -5,10 +5,11 @@ import { keyMap } from '../../jsutils/keyMap.mjs';
|
|
|
5
5
|
import { suggestionList } from '../../jsutils/suggestionList.mjs';
|
|
6
6
|
import { GraphQLError } from '../../error/GraphQLError.mjs';
|
|
7
7
|
import { Kind } from '../../language/kinds.mjs';
|
|
8
|
-
import { print } from '../../language/printer.mjs';
|
|
8
|
+
import { printForError as print } from '../../language/printer.mjs';
|
|
9
9
|
import {
|
|
10
10
|
getNamedType,
|
|
11
11
|
getNullableType,
|
|
12
|
+
isEnumType,
|
|
12
13
|
isInputObjectType,
|
|
13
14
|
isLeafType,
|
|
14
15
|
isListType,
|
|
@@ -39,16 +40,16 @@ import {
|
|
|
39
40
|
* const invalidDocument = parse(`
|
|
40
41
|
* { count(limit: "many") }
|
|
41
42
|
* `);
|
|
42
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
43
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
44
|
+
* ValuesOfCorrectTypeRule,
|
|
45
|
+
* ]);
|
|
43
46
|
*
|
|
44
47
|
* invalidErrors.length; // => 1
|
|
45
48
|
*
|
|
46
49
|
* const validDocument = parse(`
|
|
47
50
|
* { count(limit: 1) }
|
|
48
51
|
* `);
|
|
49
|
-
* const validErrors = validate(schema, validDocument, [ValuesOfCorrectTypeRule]);
|
|
50
|
-
*
|
|
51
|
-
* validErrors; // => []
|
|
52
|
+
* const validErrors = validate(schema, validDocument, [ValuesOfCorrectTypeRule]); // => []
|
|
52
53
|
* ```
|
|
53
54
|
*/
|
|
54
55
|
export function ValuesOfCorrectTypeRule(context) {
|
|
@@ -100,10 +101,12 @@ export function ValuesOfCorrectTypeRule(context) {
|
|
|
100
101
|
const fieldType = context.getInputType();
|
|
101
102
|
|
|
102
103
|
if (!fieldType && isInputObjectType(parentType)) {
|
|
103
|
-
const suggestions =
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
const suggestions = context.hideSuggestions
|
|
105
|
+
? []
|
|
106
|
+
: suggestionList(
|
|
107
|
+
node.name.value,
|
|
108
|
+
Object.keys(parentType.getFields()),
|
|
109
|
+
);
|
|
107
110
|
context.reportError(
|
|
108
111
|
new GraphQLError(
|
|
109
112
|
`Field "${node.name.value}" is not defined by type "${parentType.name}".` +
|
|
@@ -175,11 +178,18 @@ function isValidValueNode(context, node) {
|
|
|
175
178
|
// which may throw or return an invalid value to indicate failure.
|
|
176
179
|
|
|
177
180
|
try {
|
|
178
|
-
const parseResult = type
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
const parseResult = isEnumType(type)
|
|
182
|
+
? type.parseLiteral(
|
|
183
|
+
node,
|
|
184
|
+
undefined,
|
|
185
|
+
/* variables */
|
|
186
|
+
context.hideSuggestions,
|
|
187
|
+
)
|
|
188
|
+
: type.parseLiteral(
|
|
189
|
+
node,
|
|
190
|
+
undefined,
|
|
191
|
+
/* variables */
|
|
192
|
+
);
|
|
183
193
|
|
|
184
194
|
if (parseResult === undefined) {
|
|
185
195
|
const typeStr = inspect(locationType);
|
|
@@ -28,16 +28,18 @@ import type { ValidationContext } from '../ValidationContext';
|
|
|
28
28
|
* const invalidDocument = parse(`
|
|
29
29
|
* query ($user: User) { field(arg: "1") }
|
|
30
30
|
* `);
|
|
31
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
31
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
32
|
+
* VariablesAreInputTypesRule,
|
|
33
|
+
* ]);
|
|
32
34
|
*
|
|
33
35
|
* invalidErrors.length; // => 1
|
|
34
36
|
*
|
|
35
37
|
* const validDocument = parse(`
|
|
36
38
|
* query ($id: ID) { field(arg: $id) }
|
|
37
39
|
* `);
|
|
38
|
-
* const validErrors = validate(schema, validDocument, [
|
|
39
|
-
*
|
|
40
|
-
*
|
|
40
|
+
* const validErrors = validate(schema, validDocument, [
|
|
41
|
+
* VariablesAreInputTypesRule,
|
|
42
|
+
* ]); // => []
|
|
41
43
|
* ```
|
|
42
44
|
*/
|
|
43
45
|
export declare function VariablesAreInputTypesRule(
|
|
@@ -42,16 +42,18 @@ var _typeFromAST = require('../../utilities/typeFromAST.js');
|
|
|
42
42
|
* const invalidDocument = parse(`
|
|
43
43
|
* query ($user: User) { field(arg: "1") }
|
|
44
44
|
* `);
|
|
45
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
45
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
46
|
+
* VariablesAreInputTypesRule,
|
|
47
|
+
* ]);
|
|
46
48
|
*
|
|
47
49
|
* invalidErrors.length; // => 1
|
|
48
50
|
*
|
|
49
51
|
* const validDocument = parse(`
|
|
50
52
|
* query ($id: ID) { field(arg: $id) }
|
|
51
53
|
* `);
|
|
52
|
-
* const validErrors = validate(schema, validDocument, [
|
|
53
|
-
*
|
|
54
|
-
*
|
|
54
|
+
* const validErrors = validate(schema, validDocument, [
|
|
55
|
+
* VariablesAreInputTypesRule,
|
|
56
|
+
* ]); // => []
|
|
55
57
|
* ```
|
|
56
58
|
*/
|
|
57
59
|
function VariablesAreInputTypesRule(context) {
|
|
@@ -31,16 +31,18 @@ import { typeFromAST } from '../../utilities/typeFromAST.mjs';
|
|
|
31
31
|
* const invalidDocument = parse(`
|
|
32
32
|
* query ($user: User) { field(arg: "1") }
|
|
33
33
|
* `);
|
|
34
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
34
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
35
|
+
* VariablesAreInputTypesRule,
|
|
36
|
+
* ]);
|
|
35
37
|
*
|
|
36
38
|
* invalidErrors.length; // => 1
|
|
37
39
|
*
|
|
38
40
|
* const validDocument = parse(`
|
|
39
41
|
* query ($id: ID) { field(arg: $id) }
|
|
40
42
|
* `);
|
|
41
|
-
* const validErrors = validate(schema, validDocument, [
|
|
42
|
-
*
|
|
43
|
-
*
|
|
43
|
+
* const validErrors = validate(schema, validDocument, [
|
|
44
|
+
* VariablesAreInputTypesRule,
|
|
45
|
+
* ]); // => []
|
|
44
46
|
* ```
|
|
45
47
|
*/
|
|
46
48
|
export function VariablesAreInputTypesRule(context) {
|
|
@@ -23,16 +23,18 @@ import type { ValidationContext } from '../ValidationContext';
|
|
|
23
23
|
* const invalidDocument = parse(`
|
|
24
24
|
* query ($id: String) { field(arg: $id) }
|
|
25
25
|
* `);
|
|
26
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
26
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* VariablesInAllowedPositionRule,
|
|
28
|
+
* ]);
|
|
27
29
|
*
|
|
28
30
|
* invalidErrors.length; // => 1
|
|
29
31
|
*
|
|
30
32
|
* const validDocument = parse(`
|
|
31
33
|
* query ($id: ID!) { field(arg: $id) }
|
|
32
34
|
* `);
|
|
33
|
-
* const validErrors = validate(schema, validDocument, [
|
|
34
|
-
*
|
|
35
|
-
*
|
|
35
|
+
* const validErrors = validate(schema, validDocument, [
|
|
36
|
+
* VariablesInAllowedPositionRule,
|
|
37
|
+
* ]); // => []
|
|
36
38
|
* ```
|
|
37
39
|
*/
|
|
38
40
|
export declare function VariablesInAllowedPositionRule(
|
|
@@ -41,16 +41,18 @@ var _typeFromAST = require('../../utilities/typeFromAST.js');
|
|
|
41
41
|
* const invalidDocument = parse(`
|
|
42
42
|
* query ($id: String) { field(arg: $id) }
|
|
43
43
|
* `);
|
|
44
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
44
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
45
|
+
* VariablesInAllowedPositionRule,
|
|
46
|
+
* ]);
|
|
45
47
|
*
|
|
46
48
|
* invalidErrors.length; // => 1
|
|
47
49
|
*
|
|
48
50
|
* const validDocument = parse(`
|
|
49
51
|
* query ($id: ID!) { field(arg: $id) }
|
|
50
52
|
* `);
|
|
51
|
-
* const validErrors = validate(schema, validDocument, [
|
|
52
|
-
*
|
|
53
|
-
*
|
|
53
|
+
* const validErrors = validate(schema, validDocument, [
|
|
54
|
+
* VariablesInAllowedPositionRule,
|
|
55
|
+
* ]); // => []
|
|
54
56
|
* ```
|
|
55
57
|
*/
|
|
56
58
|
function VariablesInAllowedPositionRule(context) {
|
|
@@ -32,16 +32,18 @@ import { typeFromAST } from '../../utilities/typeFromAST.mjs';
|
|
|
32
32
|
* const invalidDocument = parse(`
|
|
33
33
|
* query ($id: String) { field(arg: $id) }
|
|
34
34
|
* `);
|
|
35
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
35
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
36
|
+
* VariablesInAllowedPositionRule,
|
|
37
|
+
* ]);
|
|
36
38
|
*
|
|
37
39
|
* invalidErrors.length; // => 1
|
|
38
40
|
*
|
|
39
41
|
* const validDocument = parse(`
|
|
40
42
|
* query ($id: ID!) { field(arg: $id) }
|
|
41
43
|
* `);
|
|
42
|
-
* const validErrors = validate(schema, validDocument, [
|
|
43
|
-
*
|
|
44
|
-
*
|
|
44
|
+
* const validErrors = validate(schema, validDocument, [
|
|
45
|
+
* VariablesInAllowedPositionRule,
|
|
46
|
+
* ]); // => []
|
|
45
47
|
* ```
|
|
46
48
|
*/
|
|
47
49
|
export function VariablesInAllowedPositionRule(context) {
|
|
@@ -39,16 +39,16 @@ import type { ValidationContext } from '../../ValidationContext';
|
|
|
39
39
|
* const invalidDocument = parse(`
|
|
40
40
|
* { oldName }
|
|
41
41
|
* `);
|
|
42
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
42
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
43
|
+
* NoDeprecatedCustomRule,
|
|
44
|
+
* ]);
|
|
43
45
|
*
|
|
44
46
|
* invalidErrors.length; // => 1
|
|
45
47
|
*
|
|
46
48
|
* const validDocument = parse(`
|
|
47
49
|
* { name }
|
|
48
50
|
* `);
|
|
49
|
-
* const validErrors = validate(schema, validDocument, [NoDeprecatedCustomRule]);
|
|
50
|
-
*
|
|
51
|
-
* validErrors; // => []
|
|
51
|
+
* const validErrors = validate(schema, validDocument, [NoDeprecatedCustomRule]); // => []
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
export declare function NoDeprecatedCustomRule(
|
|
@@ -51,16 +51,16 @@ var _definition = require('../../../type/definition.js');
|
|
|
51
51
|
* const invalidDocument = parse(`
|
|
52
52
|
* { oldName }
|
|
53
53
|
* `);
|
|
54
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
54
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
55
|
+
* NoDeprecatedCustomRule,
|
|
56
|
+
* ]);
|
|
55
57
|
*
|
|
56
58
|
* invalidErrors.length; // => 1
|
|
57
59
|
*
|
|
58
60
|
* const validDocument = parse(`
|
|
59
61
|
* { name }
|
|
60
62
|
* `);
|
|
61
|
-
* const validErrors = validate(schema, validDocument, [NoDeprecatedCustomRule]);
|
|
62
|
-
*
|
|
63
|
-
* validErrors; // => []
|
|
63
|
+
* const validErrors = validate(schema, validDocument, [NoDeprecatedCustomRule]); // => []
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
66
|
function NoDeprecatedCustomRule(context) {
|
|
@@ -41,16 +41,16 @@ import { getNamedType, isInputObjectType } from '../../../type/definition.mjs';
|
|
|
41
41
|
* const invalidDocument = parse(`
|
|
42
42
|
* { oldName }
|
|
43
43
|
* `);
|
|
44
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
44
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
45
|
+
* NoDeprecatedCustomRule,
|
|
46
|
+
* ]);
|
|
45
47
|
*
|
|
46
48
|
* invalidErrors.length; // => 1
|
|
47
49
|
*
|
|
48
50
|
* const validDocument = parse(`
|
|
49
51
|
* { name }
|
|
50
52
|
* `);
|
|
51
|
-
* const validErrors = validate(schema, validDocument, [NoDeprecatedCustomRule]);
|
|
52
|
-
*
|
|
53
|
-
* validErrors; // => []
|
|
53
|
+
* const validErrors = validate(schema, validDocument, [NoDeprecatedCustomRule]); // => []
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
export function NoDeprecatedCustomRule(context) {
|
|
@@ -26,16 +26,18 @@ import type { ValidationContext } from '../../ValidationContext';
|
|
|
26
26
|
* const invalidDocument = parse(`
|
|
27
27
|
* { __schema { queryType { name } } }
|
|
28
28
|
* `);
|
|
29
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
29
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
30
|
+
* NoSchemaIntrospectionCustomRule,
|
|
31
|
+
* ]);
|
|
30
32
|
*
|
|
31
|
-
* invalidErrors.length; // =>
|
|
33
|
+
* invalidErrors.length; // => 2
|
|
32
34
|
*
|
|
33
35
|
* const validDocument = parse(`
|
|
34
36
|
* { name }
|
|
35
37
|
* `);
|
|
36
|
-
* const validErrors = validate(schema, validDocument, [
|
|
37
|
-
*
|
|
38
|
-
*
|
|
38
|
+
* const validErrors = validate(schema, validDocument, [
|
|
39
|
+
* NoSchemaIntrospectionCustomRule,
|
|
40
|
+
* ]); // => []
|
|
39
41
|
* ```
|
|
40
42
|
*/
|
|
41
43
|
export declare function NoSchemaIntrospectionCustomRule(
|
|
@@ -38,16 +38,18 @@ var _introspection = require('../../../type/introspection.js');
|
|
|
38
38
|
* const invalidDocument = parse(`
|
|
39
39
|
* { __schema { queryType { name } } }
|
|
40
40
|
* `);
|
|
41
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
41
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
42
|
+
* NoSchemaIntrospectionCustomRule,
|
|
43
|
+
* ]);
|
|
42
44
|
*
|
|
43
|
-
* invalidErrors.length; // =>
|
|
45
|
+
* invalidErrors.length; // => 2
|
|
44
46
|
*
|
|
45
47
|
* const validDocument = parse(`
|
|
46
48
|
* { name }
|
|
47
49
|
* `);
|
|
48
|
-
* const validErrors = validate(schema, validDocument, [
|
|
49
|
-
*
|
|
50
|
-
*
|
|
50
|
+
* const validErrors = validate(schema, validDocument, [
|
|
51
|
+
* NoSchemaIntrospectionCustomRule,
|
|
52
|
+
* ]); // => []
|
|
51
53
|
* ```
|
|
52
54
|
*/
|
|
53
55
|
function NoSchemaIntrospectionCustomRule(context) {
|
|
@@ -28,16 +28,18 @@ import { isIntrospectionType } from '../../../type/introspection.mjs';
|
|
|
28
28
|
* const invalidDocument = parse(`
|
|
29
29
|
* { __schema { queryType { name } } }
|
|
30
30
|
* `);
|
|
31
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
31
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
32
|
+
* NoSchemaIntrospectionCustomRule,
|
|
33
|
+
* ]);
|
|
32
34
|
*
|
|
33
|
-
* invalidErrors.length; // =>
|
|
35
|
+
* invalidErrors.length; // => 2
|
|
34
36
|
*
|
|
35
37
|
* const validDocument = parse(`
|
|
36
38
|
* { name }
|
|
37
39
|
* `);
|
|
38
|
-
* const validErrors = validate(schema, validDocument, [
|
|
39
|
-
*
|
|
40
|
-
*
|
|
40
|
+
* const validErrors = validate(schema, validDocument, [
|
|
41
|
+
* NoSchemaIntrospectionCustomRule,
|
|
42
|
+
* ]); // => []
|
|
41
43
|
* ```
|
|
42
44
|
*/
|
|
43
45
|
export function NoSchemaIntrospectionCustomRule(context) {
|
package/validation/validate.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ import type { SDLValidationRule, ValidationRule } from './ValidationContext';
|
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
export interface ValidationOptions {
|
|
13
|
+
/** Omit suggestions from validation errors. */
|
|
14
|
+
hideSuggestions?: Maybe<boolean>;
|
|
13
15
|
/**
|
|
14
16
|
* Maximum number of validation errors before validation stops.
|
|
15
17
|
* @internal
|