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
|
@@ -31,16 +31,18 @@ import type { ValidationContext } from '../ValidationContext';
|
|
|
31
31
|
* const invalidDocument = parse(`
|
|
32
32
|
* { dog { ... on Cat { meowVolume } } }
|
|
33
33
|
* `);
|
|
34
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
34
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
35
|
+
* PossibleFragmentSpreadsRule,
|
|
36
|
+
* ]);
|
|
35
37
|
*
|
|
36
38
|
* invalidErrors.length; // => 1
|
|
37
39
|
*
|
|
38
40
|
* const validDocument = parse(`
|
|
39
41
|
* { dog { ... on Dog { barkVolume } } }
|
|
40
42
|
* `);
|
|
41
|
-
* const validErrors = validate(schema, validDocument, [
|
|
42
|
-
*
|
|
43
|
-
*
|
|
43
|
+
* const validErrors = validate(schema, validDocument, [
|
|
44
|
+
* PossibleFragmentSpreadsRule,
|
|
45
|
+
* ]); // => []
|
|
44
46
|
* ```
|
|
45
47
|
*/
|
|
46
48
|
export declare function PossibleFragmentSpreadsRule(
|
|
@@ -47,16 +47,18 @@ var _typeFromAST = require('../../utilities/typeFromAST.js');
|
|
|
47
47
|
* const invalidDocument = parse(`
|
|
48
48
|
* { dog { ... on Cat { meowVolume } } }
|
|
49
49
|
* `);
|
|
50
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
50
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
51
|
+
* PossibleFragmentSpreadsRule,
|
|
52
|
+
* ]);
|
|
51
53
|
*
|
|
52
54
|
* invalidErrors.length; // => 1
|
|
53
55
|
*
|
|
54
56
|
* const validDocument = parse(`
|
|
55
57
|
* { dog { ... on Dog { barkVolume } } }
|
|
56
58
|
* `);
|
|
57
|
-
* const validErrors = validate(schema, validDocument, [
|
|
58
|
-
*
|
|
59
|
-
*
|
|
59
|
+
* const validErrors = validate(schema, validDocument, [
|
|
60
|
+
* PossibleFragmentSpreadsRule,
|
|
61
|
+
* ]); // => []
|
|
60
62
|
* ```
|
|
61
63
|
*/
|
|
62
64
|
function PossibleFragmentSpreadsRule(context) {
|
|
@@ -35,16 +35,18 @@ import { typeFromAST } from '../../utilities/typeFromAST.mjs';
|
|
|
35
35
|
* const invalidDocument = parse(`
|
|
36
36
|
* { dog { ... on Cat { meowVolume } } }
|
|
37
37
|
* `);
|
|
38
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
38
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
39
|
+
* PossibleFragmentSpreadsRule,
|
|
40
|
+
* ]);
|
|
39
41
|
*
|
|
40
42
|
* invalidErrors.length; // => 1
|
|
41
43
|
*
|
|
42
44
|
* const validDocument = parse(`
|
|
43
45
|
* { dog { ... on Dog { barkVolume } } }
|
|
44
46
|
* `);
|
|
45
|
-
* const validErrors = validate(schema, validDocument, [
|
|
46
|
-
*
|
|
47
|
-
*
|
|
47
|
+
* const validErrors = validate(schema, validDocument, [
|
|
48
|
+
* PossibleFragmentSpreadsRule,
|
|
49
|
+
* ]); // => []
|
|
48
50
|
* ```
|
|
49
51
|
*/
|
|
50
52
|
export function PossibleFragmentSpreadsRule(context) {
|
|
@@ -25,16 +25,18 @@ import type {
|
|
|
25
25
|
* const invalidDocument = parse(`
|
|
26
26
|
* { field }
|
|
27
27
|
* `);
|
|
28
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
28
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
29
|
+
* ProvidedRequiredArgumentsRule,
|
|
30
|
+
* ]);
|
|
29
31
|
*
|
|
30
32
|
* invalidErrors.length; // => 1
|
|
31
33
|
*
|
|
32
34
|
* const validDocument = parse(`
|
|
33
35
|
* { field(required: "x") }
|
|
34
36
|
* `);
|
|
35
|
-
* const validErrors = validate(schema, validDocument, [
|
|
36
|
-
*
|
|
37
|
-
*
|
|
37
|
+
* const validErrors = validate(schema, validDocument, [
|
|
38
|
+
* ProvidedRequiredArgumentsRule,
|
|
39
|
+
* ]); // => []
|
|
38
40
|
* ```
|
|
39
41
|
*/
|
|
40
42
|
export declare function ProvidedRequiredArgumentsRule(
|
|
@@ -44,16 +44,18 @@ var _directives = require('../../type/directives.js');
|
|
|
44
44
|
* const invalidDocument = parse(`
|
|
45
45
|
* { field }
|
|
46
46
|
* `);
|
|
47
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
47
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
48
|
+
* ProvidedRequiredArgumentsRule,
|
|
49
|
+
* ]);
|
|
48
50
|
*
|
|
49
51
|
* invalidErrors.length; // => 1
|
|
50
52
|
*
|
|
51
53
|
* const validDocument = parse(`
|
|
52
54
|
* { field(required: "x") }
|
|
53
55
|
* `);
|
|
54
|
-
* const validErrors = validate(schema, validDocument, [
|
|
55
|
-
*
|
|
56
|
-
*
|
|
56
|
+
* const validErrors = validate(schema, validDocument, [
|
|
57
|
+
* ProvidedRequiredArgumentsRule,
|
|
58
|
+
* ]); // => []
|
|
57
59
|
* ```
|
|
58
60
|
*/
|
|
59
61
|
function ProvidedRequiredArgumentsRule(context) {
|
|
@@ -28,16 +28,18 @@ import { specifiedDirectives } from '../../type/directives.mjs';
|
|
|
28
28
|
* const invalidDocument = parse(`
|
|
29
29
|
* { field }
|
|
30
30
|
* `);
|
|
31
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
31
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
32
|
+
* ProvidedRequiredArgumentsRule,
|
|
33
|
+
* ]);
|
|
32
34
|
*
|
|
33
35
|
* invalidErrors.length; // => 1
|
|
34
36
|
*
|
|
35
37
|
* const validDocument = parse(`
|
|
36
38
|
* { field(required: "x") }
|
|
37
39
|
* `);
|
|
38
|
-
* const validErrors = validate(schema, validDocument, [
|
|
39
|
-
*
|
|
40
|
-
*
|
|
40
|
+
* const validErrors = validate(schema, validDocument, [
|
|
41
|
+
* ProvidedRequiredArgumentsRule,
|
|
42
|
+
* ]); // => []
|
|
41
43
|
* ```
|
|
42
44
|
*/
|
|
43
45
|
export function ProvidedRequiredArgumentsRule(context) {
|
|
@@ -29,9 +29,7 @@ import type { ValidationContext } from '../ValidationContext';
|
|
|
29
29
|
* const validDocument = parse(`
|
|
30
30
|
* { name }
|
|
31
31
|
* `);
|
|
32
|
-
* const validErrors = validate(schema, validDocument, [ScalarLeafsRule]);
|
|
33
|
-
*
|
|
34
|
-
* validErrors; // => []
|
|
32
|
+
* const validErrors = validate(schema, validDocument, [ScalarLeafsRule]); // => []
|
|
35
33
|
* ```
|
|
36
34
|
*/
|
|
37
35
|
export declare function ScalarLeafsRule(context: ValidationContext): ASTVisitor;
|
|
@@ -41,9 +41,7 @@ var _definition = require('../../type/definition.js');
|
|
|
41
41
|
* const validDocument = parse(`
|
|
42
42
|
* { name }
|
|
43
43
|
* `);
|
|
44
|
-
* const validErrors = validate(schema, validDocument, [ScalarLeafsRule]);
|
|
45
|
-
*
|
|
46
|
-
* validErrors; // => []
|
|
44
|
+
* const validErrors = validate(schema, validDocument, [ScalarLeafsRule]); // => []
|
|
47
45
|
* ```
|
|
48
46
|
*/
|
|
49
47
|
function ScalarLeafsRule(context) {
|
|
@@ -31,9 +31,7 @@ import { getNamedType, isLeafType } from '../../type/definition.mjs';
|
|
|
31
31
|
* const validDocument = parse(`
|
|
32
32
|
* { name }
|
|
33
33
|
* `);
|
|
34
|
-
* const validErrors = validate(schema, validDocument, [ScalarLeafsRule]);
|
|
35
|
-
*
|
|
36
|
-
* validErrors; // => []
|
|
34
|
+
* const validErrors = validate(schema, validDocument, [ScalarLeafsRule]); // => []
|
|
37
35
|
* ```
|
|
38
36
|
*/
|
|
39
37
|
export function ScalarLeafsRule(context) {
|
|
@@ -29,16 +29,18 @@ import type { ValidationContext } from '../ValidationContext';
|
|
|
29
29
|
* const invalidDocument = parse(`
|
|
30
30
|
* subscription { a b }
|
|
31
31
|
* `);
|
|
32
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
32
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
33
|
+
* SingleFieldSubscriptionsRule,
|
|
34
|
+
* ]);
|
|
33
35
|
*
|
|
34
36
|
* invalidErrors.length; // => 1
|
|
35
37
|
*
|
|
36
38
|
* const validDocument = parse(`
|
|
37
39
|
* subscription { a }
|
|
38
40
|
* `);
|
|
39
|
-
* const validErrors = validate(schema, validDocument, [
|
|
40
|
-
*
|
|
41
|
-
*
|
|
41
|
+
* const validErrors = validate(schema, validDocument, [
|
|
42
|
+
* SingleFieldSubscriptionsRule,
|
|
43
|
+
* ]); // => []
|
|
42
44
|
* ```
|
|
43
45
|
*/
|
|
44
46
|
export declare function SingleFieldSubscriptionsRule(
|
|
@@ -41,19 +41,55 @@ var _collectFields = require('../../execution/collectFields.js');
|
|
|
41
41
|
* const invalidDocument = parse(`
|
|
42
42
|
* subscription { a b }
|
|
43
43
|
* `);
|
|
44
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
44
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
45
|
+
* SingleFieldSubscriptionsRule,
|
|
46
|
+
* ]);
|
|
45
47
|
*
|
|
46
48
|
* invalidErrors.length; // => 1
|
|
47
49
|
*
|
|
48
50
|
* const validDocument = parse(`
|
|
49
51
|
* subscription { a }
|
|
50
52
|
* `);
|
|
51
|
-
* const validErrors = validate(schema, validDocument, [
|
|
52
|
-
*
|
|
53
|
-
*
|
|
53
|
+
* const validErrors = validate(schema, validDocument, [
|
|
54
|
+
* SingleFieldSubscriptionsRule,
|
|
55
|
+
* ]); // => []
|
|
54
56
|
* ```
|
|
55
57
|
*/
|
|
56
58
|
function SingleFieldSubscriptionsRule(context) {
|
|
59
|
+
let fragments;
|
|
60
|
+
|
|
61
|
+
function reserveSelectionSetWork(selectionSet) {
|
|
62
|
+
context.spendFragmentWork(selectionSet.selections.length);
|
|
63
|
+
|
|
64
|
+
for (const selection of selectionSet.selections) {
|
|
65
|
+
const directives = selection.directives;
|
|
66
|
+
|
|
67
|
+
if (directives !== undefined) {
|
|
68
|
+
context.spendFragmentWork(directives.length);
|
|
69
|
+
|
|
70
|
+
for (const directive of directives) {
|
|
71
|
+
if (
|
|
72
|
+
directive.name.value === 'skip' ||
|
|
73
|
+
directive.name.value === 'include'
|
|
74
|
+
) {
|
|
75
|
+
var _directive$arguments$, _directive$arguments;
|
|
76
|
+
|
|
77
|
+
context.spendFragmentWork(
|
|
78
|
+
(_directive$arguments$ =
|
|
79
|
+
(_directive$arguments = directive.arguments) === null ||
|
|
80
|
+
_directive$arguments === void 0
|
|
81
|
+
? void 0
|
|
82
|
+
: _directive$arguments.length) !== null &&
|
|
83
|
+
_directive$arguments$ !== void 0
|
|
84
|
+
? _directive$arguments$
|
|
85
|
+
: 0,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
57
93
|
return {
|
|
58
94
|
OperationDefinition(node) {
|
|
59
95
|
if (node.operation === 'subscription') {
|
|
@@ -63,12 +99,16 @@ function SingleFieldSubscriptionsRule(context) {
|
|
|
63
99
|
if (subscriptionType) {
|
|
64
100
|
const operationName = node.name ? node.name.value : null;
|
|
65
101
|
const variableValues = Object.create(null);
|
|
66
|
-
const document = context.getDocument();
|
|
67
|
-
const fragments = Object.create(null);
|
|
68
102
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
103
|
+
if (fragments === undefined) {
|
|
104
|
+
fragments = Object.create(null);
|
|
105
|
+
const definitions = context.getDocument().definitions;
|
|
106
|
+
context.spendFragmentWork(definitions.length);
|
|
107
|
+
|
|
108
|
+
for (const definition of definitions) {
|
|
109
|
+
if (definition.kind === _kinds.Kind.FRAGMENT_DEFINITION) {
|
|
110
|
+
fragments[definition.name.value] = definition;
|
|
111
|
+
}
|
|
72
112
|
}
|
|
73
113
|
}
|
|
74
114
|
|
|
@@ -78,6 +118,7 @@ function SingleFieldSubscriptionsRule(context) {
|
|
|
78
118
|
variableValues,
|
|
79
119
|
subscriptionType,
|
|
80
120
|
node.selectionSet,
|
|
121
|
+
reserveSelectionSetWork,
|
|
81
122
|
);
|
|
82
123
|
|
|
83
124
|
if (fields.size > 1) {
|
|
@@ -31,19 +31,55 @@ import { collectFields } from '../../execution/collectFields.mjs';
|
|
|
31
31
|
* const invalidDocument = parse(`
|
|
32
32
|
* subscription { a b }
|
|
33
33
|
* `);
|
|
34
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
34
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
35
|
+
* SingleFieldSubscriptionsRule,
|
|
36
|
+
* ]);
|
|
35
37
|
*
|
|
36
38
|
* invalidErrors.length; // => 1
|
|
37
39
|
*
|
|
38
40
|
* const validDocument = parse(`
|
|
39
41
|
* subscription { a }
|
|
40
42
|
* `);
|
|
41
|
-
* const validErrors = validate(schema, validDocument, [
|
|
42
|
-
*
|
|
43
|
-
*
|
|
43
|
+
* const validErrors = validate(schema, validDocument, [
|
|
44
|
+
* SingleFieldSubscriptionsRule,
|
|
45
|
+
* ]); // => []
|
|
44
46
|
* ```
|
|
45
47
|
*/
|
|
46
48
|
export function SingleFieldSubscriptionsRule(context) {
|
|
49
|
+
let fragments;
|
|
50
|
+
|
|
51
|
+
function reserveSelectionSetWork(selectionSet) {
|
|
52
|
+
context.spendFragmentWork(selectionSet.selections.length);
|
|
53
|
+
|
|
54
|
+
for (const selection of selectionSet.selections) {
|
|
55
|
+
const directives = selection.directives;
|
|
56
|
+
|
|
57
|
+
if (directives !== undefined) {
|
|
58
|
+
context.spendFragmentWork(directives.length);
|
|
59
|
+
|
|
60
|
+
for (const directive of directives) {
|
|
61
|
+
if (
|
|
62
|
+
directive.name.value === 'skip' ||
|
|
63
|
+
directive.name.value === 'include'
|
|
64
|
+
) {
|
|
65
|
+
var _directive$arguments$, _directive$arguments;
|
|
66
|
+
|
|
67
|
+
context.spendFragmentWork(
|
|
68
|
+
(_directive$arguments$ =
|
|
69
|
+
(_directive$arguments = directive.arguments) === null ||
|
|
70
|
+
_directive$arguments === void 0
|
|
71
|
+
? void 0
|
|
72
|
+
: _directive$arguments.length) !== null &&
|
|
73
|
+
_directive$arguments$ !== void 0
|
|
74
|
+
? _directive$arguments$
|
|
75
|
+
: 0,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
47
83
|
return {
|
|
48
84
|
OperationDefinition(node) {
|
|
49
85
|
if (node.operation === 'subscription') {
|
|
@@ -53,12 +89,16 @@ export function SingleFieldSubscriptionsRule(context) {
|
|
|
53
89
|
if (subscriptionType) {
|
|
54
90
|
const operationName = node.name ? node.name.value : null;
|
|
55
91
|
const variableValues = Object.create(null);
|
|
56
|
-
const document = context.getDocument();
|
|
57
|
-
const fragments = Object.create(null);
|
|
58
92
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
93
|
+
if (fragments === undefined) {
|
|
94
|
+
fragments = Object.create(null);
|
|
95
|
+
const definitions = context.getDocument().definitions;
|
|
96
|
+
context.spendFragmentWork(definitions.length);
|
|
97
|
+
|
|
98
|
+
for (const definition of definitions) {
|
|
99
|
+
if (definition.kind === Kind.FRAGMENT_DEFINITION) {
|
|
100
|
+
fragments[definition.name.value] = definition;
|
|
101
|
+
}
|
|
62
102
|
}
|
|
63
103
|
}
|
|
64
104
|
|
|
@@ -68,6 +108,7 @@ export function SingleFieldSubscriptionsRule(context) {
|
|
|
68
108
|
variableValues,
|
|
69
109
|
subscriptionType,
|
|
70
110
|
node.selectionSet,
|
|
111
|
+
reserveSelectionSetWork,
|
|
71
112
|
);
|
|
72
113
|
|
|
73
114
|
if (fields.size > 1) {
|
|
@@ -24,16 +24,16 @@ import type { ASTValidationContext } from '../ValidationContext';
|
|
|
24
24
|
* const invalidDocument = parse(`
|
|
25
25
|
* { field(arg: "1", arg: "2") }
|
|
26
26
|
* `);
|
|
27
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
28
|
+
* UniqueArgumentNamesRule,
|
|
29
|
+
* ]);
|
|
28
30
|
*
|
|
29
31
|
* invalidErrors.length; // => 1
|
|
30
32
|
*
|
|
31
33
|
* const validDocument = parse(`
|
|
32
34
|
* { field(arg: "1") }
|
|
33
35
|
* `);
|
|
34
|
-
* const validErrors = validate(schema, validDocument, [UniqueArgumentNamesRule]);
|
|
35
|
-
*
|
|
36
|
-
* validErrors; // => []
|
|
36
|
+
* const validErrors = validate(schema, validDocument, [UniqueArgumentNamesRule]); // => []
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
export declare function UniqueArgumentNamesRule(
|
|
@@ -34,16 +34,16 @@ var _GraphQLError = require('../../error/GraphQLError.js');
|
|
|
34
34
|
* const invalidDocument = parse(`
|
|
35
35
|
* { field(arg: "1", arg: "2") }
|
|
36
36
|
* `);
|
|
37
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
37
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
38
|
+
* UniqueArgumentNamesRule,
|
|
39
|
+
* ]);
|
|
38
40
|
*
|
|
39
41
|
* invalidErrors.length; // => 1
|
|
40
42
|
*
|
|
41
43
|
* const validDocument = parse(`
|
|
42
44
|
* { field(arg: "1") }
|
|
43
45
|
* `);
|
|
44
|
-
* const validErrors = validate(schema, validDocument, [UniqueArgumentNamesRule]);
|
|
45
|
-
*
|
|
46
|
-
* validErrors; // => []
|
|
46
|
+
* const validErrors = validate(schema, validDocument, [UniqueArgumentNamesRule]); // => []
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
49
|
function UniqueArgumentNamesRule(context) {
|
|
@@ -25,16 +25,16 @@ import { GraphQLError } from '../../error/GraphQLError.mjs';
|
|
|
25
25
|
* const invalidDocument = parse(`
|
|
26
26
|
* { field(arg: "1", arg: "2") }
|
|
27
27
|
* `);
|
|
28
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
28
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
29
|
+
* UniqueArgumentNamesRule,
|
|
30
|
+
* ]);
|
|
29
31
|
*
|
|
30
32
|
* invalidErrors.length; // => 1
|
|
31
33
|
*
|
|
32
34
|
* const validDocument = parse(`
|
|
33
35
|
* { field(arg: "1") }
|
|
34
36
|
* `);
|
|
35
|
-
* const validErrors = validate(schema, validDocument, [UniqueArgumentNamesRule]);
|
|
36
|
-
*
|
|
37
|
-
* validErrors; // => []
|
|
37
|
+
* const validErrors = validate(schema, validDocument, [UniqueArgumentNamesRule]); // => []
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
export function UniqueArgumentNamesRule(context) {
|
|
@@ -27,16 +27,18 @@ import type {
|
|
|
27
27
|
* const invalidDocument = parse(`
|
|
28
28
|
* { name @include(if: true) @include(if: false) }
|
|
29
29
|
* `);
|
|
30
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
30
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
31
|
+
* UniqueDirectivesPerLocationRule,
|
|
32
|
+
* ]);
|
|
31
33
|
*
|
|
32
34
|
* invalidErrors.length; // => 1
|
|
33
35
|
*
|
|
34
36
|
* const validDocument = parse(`
|
|
35
37
|
* { name @include(if: true) }
|
|
36
38
|
* `);
|
|
37
|
-
* const validErrors = validate(schema, validDocument, [
|
|
38
|
-
*
|
|
39
|
-
*
|
|
39
|
+
* const validErrors = validate(schema, validDocument, [
|
|
40
|
+
* UniqueDirectivesPerLocationRule,
|
|
41
|
+
* ]); // => []
|
|
40
42
|
* ```
|
|
41
43
|
*/
|
|
42
44
|
export declare function UniqueDirectivesPerLocationRule(
|
|
@@ -38,16 +38,18 @@ var _directives = require('../../type/directives.js');
|
|
|
38
38
|
* const invalidDocument = parse(`
|
|
39
39
|
* { name @include(if: true) @include(if: false) }
|
|
40
40
|
* `);
|
|
41
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
41
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
42
|
+
* UniqueDirectivesPerLocationRule,
|
|
43
|
+
* ]);
|
|
42
44
|
*
|
|
43
45
|
* invalidErrors.length; // => 1
|
|
44
46
|
*
|
|
45
47
|
* const validDocument = parse(`
|
|
46
48
|
* { name @include(if: true) }
|
|
47
49
|
* `);
|
|
48
|
-
* const validErrors = validate(schema, validDocument, [
|
|
49
|
-
*
|
|
50
|
-
*
|
|
50
|
+
* const validErrors = validate(schema, validDocument, [
|
|
51
|
+
* UniqueDirectivesPerLocationRule,
|
|
52
|
+
* ]); // => []
|
|
51
53
|
* ```
|
|
52
54
|
*/
|
|
53
55
|
function UniqueDirectivesPerLocationRule(context) {
|
|
@@ -30,16 +30,18 @@ import { specifiedDirectives } from '../../type/directives.mjs';
|
|
|
30
30
|
* const invalidDocument = parse(`
|
|
31
31
|
* { name @include(if: true) @include(if: false) }
|
|
32
32
|
* `);
|
|
33
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
33
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
34
|
+
* UniqueDirectivesPerLocationRule,
|
|
35
|
+
* ]);
|
|
34
36
|
*
|
|
35
37
|
* invalidErrors.length; // => 1
|
|
36
38
|
*
|
|
37
39
|
* const validDocument = parse(`
|
|
38
40
|
* { name @include(if: true) }
|
|
39
41
|
* `);
|
|
40
|
-
* const validErrors = validate(schema, validDocument, [
|
|
41
|
-
*
|
|
42
|
-
*
|
|
42
|
+
* const validErrors = validate(schema, validDocument, [
|
|
43
|
+
* UniqueDirectivesPerLocationRule,
|
|
44
|
+
* ]); // => []
|
|
43
45
|
* ```
|
|
44
46
|
*/
|
|
45
47
|
export function UniqueDirectivesPerLocationRule(context) {
|
|
@@ -23,16 +23,16 @@ import type { ASTValidationContext } from '../ValidationContext';
|
|
|
23
23
|
* const invalidDocument = parse(`
|
|
24
24
|
* fragment A on Query { name } fragment A on Query { name } query { ...A }
|
|
25
25
|
* `);
|
|
26
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
26
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* UniqueFragmentNamesRule,
|
|
28
|
+
* ]);
|
|
27
29
|
*
|
|
28
30
|
* invalidErrors.length; // => 1
|
|
29
31
|
*
|
|
30
32
|
* const validDocument = parse(`
|
|
31
33
|
* fragment A on Query { name } query { ...A }
|
|
32
34
|
* `);
|
|
33
|
-
* const validErrors = validate(schema, validDocument, [UniqueFragmentNamesRule]);
|
|
34
|
-
*
|
|
35
|
-
* validErrors; // => []
|
|
35
|
+
* const validErrors = validate(schema, validDocument, [UniqueFragmentNamesRule]); // => []
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export declare function UniqueFragmentNamesRule(
|
|
@@ -31,16 +31,16 @@ var _GraphQLError = require('../../error/GraphQLError.js');
|
|
|
31
31
|
* const invalidDocument = parse(`
|
|
32
32
|
* fragment A on Query { name } fragment A on Query { name } query { ...A }
|
|
33
33
|
* `);
|
|
34
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
34
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
35
|
+
* UniqueFragmentNamesRule,
|
|
36
|
+
* ]);
|
|
35
37
|
*
|
|
36
38
|
* invalidErrors.length; // => 1
|
|
37
39
|
*
|
|
38
40
|
* const validDocument = parse(`
|
|
39
41
|
* fragment A on Query { name } query { ...A }
|
|
40
42
|
* `);
|
|
41
|
-
* const validErrors = validate(schema, validDocument, [UniqueFragmentNamesRule]);
|
|
42
|
-
*
|
|
43
|
-
* validErrors; // => []
|
|
43
|
+
* const validErrors = validate(schema, validDocument, [UniqueFragmentNamesRule]); // => []
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
function UniqueFragmentNamesRule(context) {
|
|
@@ -23,16 +23,16 @@ import { GraphQLError } from '../../error/GraphQLError.mjs';
|
|
|
23
23
|
* const invalidDocument = parse(`
|
|
24
24
|
* fragment A on Query { name } fragment A on Query { name } query { ...A }
|
|
25
25
|
* `);
|
|
26
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
26
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* UniqueFragmentNamesRule,
|
|
28
|
+
* ]);
|
|
27
29
|
*
|
|
28
30
|
* invalidErrors.length; // => 1
|
|
29
31
|
*
|
|
30
32
|
* const validDocument = parse(`
|
|
31
33
|
* fragment A on Query { name } query { ...A }
|
|
32
34
|
* `);
|
|
33
|
-
* const validErrors = validate(schema, validDocument, [UniqueFragmentNamesRule]);
|
|
34
|
-
*
|
|
35
|
-
* validErrors; // => []
|
|
35
|
+
* const validErrors = validate(schema, validDocument, [UniqueFragmentNamesRule]); // => []
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export function UniqueFragmentNamesRule(context) {
|
|
@@ -28,16 +28,18 @@ import type { ASTValidationContext } from '../ValidationContext';
|
|
|
28
28
|
* const invalidDocument = parse(`
|
|
29
29
|
* { search(filter: { name: "a", name: "b" }) }
|
|
30
30
|
* `);
|
|
31
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
31
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
32
|
+
* UniqueInputFieldNamesRule,
|
|
33
|
+
* ]);
|
|
32
34
|
*
|
|
33
35
|
* invalidErrors.length; // => 1
|
|
34
36
|
*
|
|
35
37
|
* const validDocument = parse(`
|
|
36
38
|
* { search(filter: { name: "a" }) }
|
|
37
39
|
* `);
|
|
38
|
-
* const validErrors = validate(schema, validDocument, [
|
|
39
|
-
*
|
|
40
|
-
*
|
|
40
|
+
* const validErrors = validate(schema, validDocument, [
|
|
41
|
+
* UniqueInputFieldNamesRule,
|
|
42
|
+
* ]); // => []
|
|
41
43
|
* ```
|
|
42
44
|
*/
|
|
43
45
|
export declare function UniqueInputFieldNamesRule(
|
|
@@ -38,16 +38,18 @@ var _GraphQLError = require('../../error/GraphQLError.js');
|
|
|
38
38
|
* const invalidDocument = parse(`
|
|
39
39
|
* { search(filter: { name: "a", name: "b" }) }
|
|
40
40
|
* `);
|
|
41
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
41
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
42
|
+
* UniqueInputFieldNamesRule,
|
|
43
|
+
* ]);
|
|
42
44
|
*
|
|
43
45
|
* invalidErrors.length; // => 1
|
|
44
46
|
*
|
|
45
47
|
* const validDocument = parse(`
|
|
46
48
|
* { search(filter: { name: "a" }) }
|
|
47
49
|
* `);
|
|
48
|
-
* const validErrors = validate(schema, validDocument, [
|
|
49
|
-
*
|
|
50
|
-
*
|
|
50
|
+
* const validErrors = validate(schema, validDocument, [
|
|
51
|
+
* UniqueInputFieldNamesRule,
|
|
52
|
+
* ]); // => []
|
|
51
53
|
* ```
|
|
52
54
|
*/
|
|
53
55
|
function UniqueInputFieldNamesRule(context) {
|
|
@@ -29,16 +29,18 @@ import { GraphQLError } from '../../error/GraphQLError.mjs';
|
|
|
29
29
|
* const invalidDocument = parse(`
|
|
30
30
|
* { search(filter: { name: "a", name: "b" }) }
|
|
31
31
|
* `);
|
|
32
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
32
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
33
|
+
* UniqueInputFieldNamesRule,
|
|
34
|
+
* ]);
|
|
33
35
|
*
|
|
34
36
|
* invalidErrors.length; // => 1
|
|
35
37
|
*
|
|
36
38
|
* const validDocument = parse(`
|
|
37
39
|
* { search(filter: { name: "a" }) }
|
|
38
40
|
* `);
|
|
39
|
-
* const validErrors = validate(schema, validDocument, [
|
|
40
|
-
*
|
|
41
|
-
*
|
|
41
|
+
* const validErrors = validate(schema, validDocument, [
|
|
42
|
+
* UniqueInputFieldNamesRule,
|
|
43
|
+
* ]); // => []
|
|
42
44
|
* ```
|
|
43
45
|
*/
|
|
44
46
|
export function UniqueInputFieldNamesRule(context) {
|