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
package/utilities/TypeInfo.js
CHANGED
|
@@ -44,7 +44,7 @@ class TypeInfo {
|
|
|
44
44
|
* }
|
|
45
45
|
* `);
|
|
46
46
|
* const typeInfo = new TypeInfo(schema);
|
|
47
|
-
* const seenTypes = [];
|
|
47
|
+
* const seenTypes: Array<string> = [];
|
|
48
48
|
*
|
|
49
49
|
* visit(
|
|
50
50
|
* parse('{ greeting }'),
|
|
@@ -162,7 +162,7 @@ class TypeInfo {
|
|
|
162
162
|
* }
|
|
163
163
|
* `);
|
|
164
164
|
* const typeInfo = new TypeInfo(schema);
|
|
165
|
-
* const fieldTypes = {};
|
|
165
|
+
* const fieldTypes: Record<string, string> = {};
|
|
166
166
|
*
|
|
167
167
|
* visit(
|
|
168
168
|
* parse('{ viewer { name } }'),
|
|
@@ -200,7 +200,7 @@ class TypeInfo {
|
|
|
200
200
|
* }
|
|
201
201
|
* `);
|
|
202
202
|
* const typeInfo = new TypeInfo(schema);
|
|
203
|
-
* const parentTypes = {};
|
|
203
|
+
* const parentTypes: Record<string, string> = {};
|
|
204
204
|
*
|
|
205
205
|
* visit(
|
|
206
206
|
* parse('{ viewer { name } }'),
|
|
@@ -239,7 +239,7 @@ class TypeInfo {
|
|
|
239
239
|
* }
|
|
240
240
|
* `);
|
|
241
241
|
* const typeInfo = new TypeInfo(schema);
|
|
242
|
-
* const inputTypes = {};
|
|
242
|
+
* const inputTypes: Record<string, string> = {};
|
|
243
243
|
*
|
|
244
244
|
* visit(
|
|
245
245
|
* parse('{ reviews(stars: 5, sort: OLDEST) }'),
|
|
@@ -277,7 +277,7 @@ class TypeInfo {
|
|
|
277
277
|
* }
|
|
278
278
|
* `);
|
|
279
279
|
* const typeInfo = new TypeInfo(schema);
|
|
280
|
-
* const parentInputTypes = {};
|
|
280
|
+
* const parentInputTypes: Record<string, string> = {};
|
|
281
281
|
*
|
|
282
282
|
* visit(
|
|
283
283
|
* parse('{ reviews(filter: { stars: 5 }) }'),
|
|
@@ -345,7 +345,7 @@ class TypeInfo {
|
|
|
345
345
|
* }
|
|
346
346
|
* `);
|
|
347
347
|
* const typeInfo = new TypeInfo(schema);
|
|
348
|
-
* let defaultLimit;
|
|
348
|
+
* let defaultLimit: unknown;
|
|
349
349
|
*
|
|
350
350
|
* visit(
|
|
351
351
|
* parse('{ reviews(limit: 5) }'),
|
|
@@ -472,6 +472,7 @@ class TypeInfo {
|
|
|
472
472
|
* @returns Nothing.
|
|
473
473
|
* @example
|
|
474
474
|
* ```ts
|
|
475
|
+
* import assert from 'node:assert/strict';
|
|
475
476
|
* import { Kind, parse } from 'graphql/language';
|
|
476
477
|
* import { buildSchema, TypeInfo } from 'graphql/utilities';
|
|
477
478
|
*
|
|
@@ -482,6 +483,7 @@ class TypeInfo {
|
|
|
482
483
|
* `);
|
|
483
484
|
* const document = parse('{ greeting }');
|
|
484
485
|
* const operation = document.definitions[0];
|
|
486
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
485
487
|
* const selectionSet = operation.selectionSet;
|
|
486
488
|
* const field = selectionSet.selections[0];
|
|
487
489
|
* const typeInfo = new TypeInfo(schema);
|
|
@@ -662,12 +664,13 @@ class TypeInfo {
|
|
|
662
664
|
}
|
|
663
665
|
}
|
|
664
666
|
/**
|
|
665
|
-
* Updates this TypeInfo instance
|
|
666
|
-
* @param node - AST node being
|
|
667
|
+
* Updates this TypeInfo instance when leaving an AST node.
|
|
668
|
+
* @param node - AST node being left.
|
|
667
669
|
* @returns Nothing.
|
|
668
670
|
* @example
|
|
669
671
|
* ```ts
|
|
670
|
-
* import
|
|
672
|
+
* import assert from 'node:assert/strict';
|
|
673
|
+
* import { parse, Kind } from 'graphql/language';
|
|
671
674
|
* import { buildSchema, TypeInfo } from 'graphql/utilities';
|
|
672
675
|
*
|
|
673
676
|
* const schema = buildSchema(`
|
|
@@ -677,6 +680,7 @@ class TypeInfo {
|
|
|
677
680
|
* `);
|
|
678
681
|
* const document = parse('{ greeting }');
|
|
679
682
|
* const operation = document.definitions[0];
|
|
683
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
680
684
|
* const selectionSet = operation.selectionSet;
|
|
681
685
|
* const field = selectionSet.selections[0];
|
|
682
686
|
* const typeInfo = new TypeInfo(schema);
|
|
@@ -687,7 +691,7 @@ class TypeInfo {
|
|
|
687
691
|
* String(typeInfo.getType()); // => 'String'
|
|
688
692
|
*
|
|
689
693
|
* typeInfo.leave(field);
|
|
690
|
-
* typeInfo.getType(); // =>
|
|
694
|
+
* String(typeInfo.getType()); // => 'Query'
|
|
691
695
|
* ```
|
|
692
696
|
*/
|
|
693
697
|
|
|
@@ -804,7 +808,7 @@ function getFieldDef(schema, parentType, fieldNode) {
|
|
|
804
808
|
* }
|
|
805
809
|
* `);
|
|
806
810
|
* const typeInfo = new TypeInfo(schema);
|
|
807
|
-
* const fields = [];
|
|
811
|
+
* const fields: Array<{ name: string; parentType: string; type: string }> = [];
|
|
808
812
|
*
|
|
809
813
|
* visit(
|
|
810
814
|
* parse('{ greeting }'),
|
package/utilities/TypeInfo.mjs
CHANGED
|
@@ -45,7 +45,7 @@ export class TypeInfo {
|
|
|
45
45
|
* }
|
|
46
46
|
* `);
|
|
47
47
|
* const typeInfo = new TypeInfo(schema);
|
|
48
|
-
* const seenTypes = [];
|
|
48
|
+
* const seenTypes: Array<string> = [];
|
|
49
49
|
*
|
|
50
50
|
* visit(
|
|
51
51
|
* parse('{ greeting }'),
|
|
@@ -163,7 +163,7 @@ export class TypeInfo {
|
|
|
163
163
|
* }
|
|
164
164
|
* `);
|
|
165
165
|
* const typeInfo = new TypeInfo(schema);
|
|
166
|
-
* const fieldTypes = {};
|
|
166
|
+
* const fieldTypes: Record<string, string> = {};
|
|
167
167
|
*
|
|
168
168
|
* visit(
|
|
169
169
|
* parse('{ viewer { name } }'),
|
|
@@ -201,7 +201,7 @@ export class TypeInfo {
|
|
|
201
201
|
* }
|
|
202
202
|
* `);
|
|
203
203
|
* const typeInfo = new TypeInfo(schema);
|
|
204
|
-
* const parentTypes = {};
|
|
204
|
+
* const parentTypes: Record<string, string> = {};
|
|
205
205
|
*
|
|
206
206
|
* visit(
|
|
207
207
|
* parse('{ viewer { name } }'),
|
|
@@ -240,7 +240,7 @@ export class TypeInfo {
|
|
|
240
240
|
* }
|
|
241
241
|
* `);
|
|
242
242
|
* const typeInfo = new TypeInfo(schema);
|
|
243
|
-
* const inputTypes = {};
|
|
243
|
+
* const inputTypes: Record<string, string> = {};
|
|
244
244
|
*
|
|
245
245
|
* visit(
|
|
246
246
|
* parse('{ reviews(stars: 5, sort: OLDEST) }'),
|
|
@@ -278,7 +278,7 @@ export class TypeInfo {
|
|
|
278
278
|
* }
|
|
279
279
|
* `);
|
|
280
280
|
* const typeInfo = new TypeInfo(schema);
|
|
281
|
-
* const parentInputTypes = {};
|
|
281
|
+
* const parentInputTypes: Record<string, string> = {};
|
|
282
282
|
*
|
|
283
283
|
* visit(
|
|
284
284
|
* parse('{ reviews(filter: { stars: 5 }) }'),
|
|
@@ -346,7 +346,7 @@ export class TypeInfo {
|
|
|
346
346
|
* }
|
|
347
347
|
* `);
|
|
348
348
|
* const typeInfo = new TypeInfo(schema);
|
|
349
|
-
* let defaultLimit;
|
|
349
|
+
* let defaultLimit: unknown;
|
|
350
350
|
*
|
|
351
351
|
* visit(
|
|
352
352
|
* parse('{ reviews(limit: 5) }'),
|
|
@@ -473,6 +473,7 @@ export class TypeInfo {
|
|
|
473
473
|
* @returns Nothing.
|
|
474
474
|
* @example
|
|
475
475
|
* ```ts
|
|
476
|
+
* import assert from 'node:assert/strict';
|
|
476
477
|
* import { Kind, parse } from 'graphql/language';
|
|
477
478
|
* import { buildSchema, TypeInfo } from 'graphql/utilities';
|
|
478
479
|
*
|
|
@@ -483,6 +484,7 @@ export class TypeInfo {
|
|
|
483
484
|
* `);
|
|
484
485
|
* const document = parse('{ greeting }');
|
|
485
486
|
* const operation = document.definitions[0];
|
|
487
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
486
488
|
* const selectionSet = operation.selectionSet;
|
|
487
489
|
* const field = selectionSet.selections[0];
|
|
488
490
|
* const typeInfo = new TypeInfo(schema);
|
|
@@ -649,12 +651,13 @@ export class TypeInfo {
|
|
|
649
651
|
}
|
|
650
652
|
}
|
|
651
653
|
/**
|
|
652
|
-
* Updates this TypeInfo instance
|
|
653
|
-
* @param node - AST node being
|
|
654
|
+
* Updates this TypeInfo instance when leaving an AST node.
|
|
655
|
+
* @param node - AST node being left.
|
|
654
656
|
* @returns Nothing.
|
|
655
657
|
* @example
|
|
656
658
|
* ```ts
|
|
657
|
-
* import
|
|
659
|
+
* import assert from 'node:assert/strict';
|
|
660
|
+
* import { parse, Kind } from 'graphql/language';
|
|
658
661
|
* import { buildSchema, TypeInfo } from 'graphql/utilities';
|
|
659
662
|
*
|
|
660
663
|
* const schema = buildSchema(`
|
|
@@ -664,6 +667,7 @@ export class TypeInfo {
|
|
|
664
667
|
* `);
|
|
665
668
|
* const document = parse('{ greeting }');
|
|
666
669
|
* const operation = document.definitions[0];
|
|
670
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
667
671
|
* const selectionSet = operation.selectionSet;
|
|
668
672
|
* const field = selectionSet.selections[0];
|
|
669
673
|
* const typeInfo = new TypeInfo(schema);
|
|
@@ -674,7 +678,7 @@ export class TypeInfo {
|
|
|
674
678
|
* String(typeInfo.getType()); // => 'String'
|
|
675
679
|
*
|
|
676
680
|
* typeInfo.leave(field);
|
|
677
|
-
* typeInfo.getType(); // =>
|
|
681
|
+
* String(typeInfo.getType()); // => 'Query'
|
|
678
682
|
* ```
|
|
679
683
|
*/
|
|
680
684
|
|
|
@@ -780,7 +784,7 @@ function getFieldDef(schema, parentType, fieldNode) {
|
|
|
780
784
|
* }
|
|
781
785
|
* `);
|
|
782
786
|
* const typeInfo = new TypeInfo(schema);
|
|
783
|
-
* const fields = [];
|
|
787
|
+
* const fields: Array<{ name: string; parentType: string; type: string }> = [];
|
|
784
788
|
*
|
|
785
789
|
* visit(
|
|
786
790
|
* parse('{ greeting }'),
|
|
@@ -29,7 +29,7 @@ export declare function assertValidName(name: string): string;
|
|
|
29
29
|
* isValidNameError('User'); // => undefined
|
|
30
30
|
*
|
|
31
31
|
* const error = isValidNameError('__typename');
|
|
32
|
-
* error
|
|
32
|
+
* error?.message; // => 'Name "__typename" must not begin with "__", which is reserved by GraphQL introspection.'
|
|
33
33
|
* ```
|
|
34
34
|
* @deprecated Please use `assertName` instead. Will be removed in v17
|
|
35
35
|
*/
|
|
@@ -53,7 +53,7 @@ function assertValidName(name) {
|
|
|
53
53
|
* isValidNameError('User'); // => undefined
|
|
54
54
|
*
|
|
55
55
|
* const error = isValidNameError('__typename');
|
|
56
|
-
* error
|
|
56
|
+
* error?.message; // => 'Name "__typename" must not begin with "__", which is reserved by GraphQL introspection.'
|
|
57
57
|
* ```
|
|
58
58
|
* @deprecated Please use `assertName` instead. Will be removed in v17
|
|
59
59
|
*/
|
|
@@ -42,7 +42,7 @@ export function assertValidName(name) {
|
|
|
42
42
|
* isValidNameError('User'); // => undefined
|
|
43
43
|
*
|
|
44
44
|
* const error = isValidNameError('__typename');
|
|
45
|
-
* error
|
|
45
|
+
* error?.message; // => 'Name "__typename" must not begin with "__", which is reserved by GraphQL introspection.'
|
|
46
46
|
* ```
|
|
47
47
|
* @deprecated Please use `assertName` instead. Will be removed in v17
|
|
48
48
|
*/
|
|
@@ -24,6 +24,7 @@ import type { GraphQLInputType } from '../type/definition';
|
|
|
24
24
|
* @returns A GraphQL value AST for the provided JavaScript value, or null when no literal can represent it.
|
|
25
25
|
* @example
|
|
26
26
|
* ```ts
|
|
27
|
+
* import assert from 'node:assert/strict';
|
|
27
28
|
* import { print } from 'graphql/language';
|
|
28
29
|
* import {
|
|
29
30
|
* GraphQLInputObjectType,
|
|
@@ -47,7 +48,8 @@ import type { GraphQLInputType } from '../type/definition';
|
|
|
47
48
|
* ReviewInput,
|
|
48
49
|
* );
|
|
49
50
|
*
|
|
50
|
-
*
|
|
51
|
+
* assert(valueNode);
|
|
52
|
+
* print(valueNode); // => '{stars: 5, tags: ["featured", "verified"]}'
|
|
51
53
|
* astFromValue(undefined, GraphQLString); // => null
|
|
52
54
|
* astFromValue(null, new GraphQLNonNull(GraphQLString)); // => null
|
|
53
55
|
* ```
|
|
@@ -43,6 +43,7 @@ var _scalars = require('../type/scalars.js');
|
|
|
43
43
|
* @returns A GraphQL value AST for the provided JavaScript value, or null when no literal can represent it.
|
|
44
44
|
* @example
|
|
45
45
|
* ```ts
|
|
46
|
+
* import assert from 'node:assert/strict';
|
|
46
47
|
* import { print } from 'graphql/language';
|
|
47
48
|
* import {
|
|
48
49
|
* GraphQLInputObjectType,
|
|
@@ -66,7 +67,8 @@ var _scalars = require('../type/scalars.js');
|
|
|
66
67
|
* ReviewInput,
|
|
67
68
|
* );
|
|
68
69
|
*
|
|
69
|
-
*
|
|
70
|
+
* assert(valueNode);
|
|
71
|
+
* print(valueNode); // => '{stars: 5, tags: ["featured", "verified"]}'
|
|
70
72
|
* astFromValue(undefined, GraphQLString); // => null
|
|
71
73
|
* astFromValue(null, new GraphQLNonNull(GraphQLString)); // => null
|
|
72
74
|
* ```
|
|
@@ -34,6 +34,7 @@ import { GraphQLID } from '../type/scalars.mjs';
|
|
|
34
34
|
* @returns A GraphQL value AST for the provided JavaScript value, or null when no literal can represent it.
|
|
35
35
|
* @example
|
|
36
36
|
* ```ts
|
|
37
|
+
* import assert from 'node:assert/strict';
|
|
37
38
|
* import { print } from 'graphql/language';
|
|
38
39
|
* import {
|
|
39
40
|
* GraphQLInputObjectType,
|
|
@@ -57,7 +58,8 @@ import { GraphQLID } from '../type/scalars.mjs';
|
|
|
57
58
|
* ReviewInput,
|
|
58
59
|
* );
|
|
59
60
|
*
|
|
60
|
-
*
|
|
61
|
+
* assert(valueNode);
|
|
62
|
+
* print(valueNode); // => '{stars: 5, tags: ["featured", "verified"]}'
|
|
61
63
|
* astFromValue(undefined, GraphQLString); // => null
|
|
62
64
|
* astFromValue(null, new GraphQLNonNull(GraphQLString)); // => null
|
|
63
65
|
* ```
|
|
@@ -33,19 +33,19 @@ export interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {
|
|
|
33
33
|
* const document = parse('type Query { hello: String }');
|
|
34
34
|
* const schema = buildASTSchema(document);
|
|
35
35
|
*
|
|
36
|
-
* schema.getQueryType()
|
|
36
|
+
* schema.getQueryType()?.name; // => 'Query'
|
|
37
37
|
* ```
|
|
38
38
|
* @example
|
|
39
39
|
* ```ts
|
|
40
|
-
* // This variant uses validation options when the SDL references unknown types.
|
|
41
40
|
* import { parse } from 'graphql/language';
|
|
42
41
|
* import { buildASTSchema } from 'graphql/utilities';
|
|
43
42
|
*
|
|
44
|
-
* const document = parse('type Query {
|
|
43
|
+
* const document = parse('type Query { greeting: String greeting: String }');
|
|
45
44
|
*
|
|
46
45
|
* buildASTSchema(document); // throws an error
|
|
46
|
+
*
|
|
47
|
+
* // Skipping SDL validation allows the duplicate field definition.
|
|
47
48
|
* buildASTSchema(document, {
|
|
48
|
-
* assumeValid: true,
|
|
49
49
|
* assumeValidSDL: true,
|
|
50
50
|
* }); // does not throw
|
|
51
51
|
* ```
|
|
@@ -66,7 +66,7 @@ export declare function buildASTSchema(
|
|
|
66
66
|
*
|
|
67
67
|
* const schema = buildSchema('type Query { hello: String }');
|
|
68
68
|
*
|
|
69
|
-
* schema.getQueryType()
|
|
69
|
+
* schema.getQueryType()?.name; // => 'Query'
|
|
70
70
|
* ```
|
|
71
71
|
* @example
|
|
72
72
|
* ```ts
|
|
@@ -74,7 +74,7 @@ export declare function buildASTSchema(
|
|
|
74
74
|
* import { buildSchema } from 'graphql/utilities';
|
|
75
75
|
*
|
|
76
76
|
* const schema = buildSchema(
|
|
77
|
-
* 'directive @tag on
|
|
77
|
+
* 'directive @tag on DIRECTIVE_DEFINITION\n' +
|
|
78
78
|
* 'directive @compose @tag on FIELD_DEFINITION',
|
|
79
79
|
* {
|
|
80
80
|
* experimentalDirectivesOnDirectiveDefinitions: true,
|
|
@@ -84,8 +84,8 @@ export declare function buildASTSchema(
|
|
|
84
84
|
*
|
|
85
85
|
* const directive = schema.getDirective('compose');
|
|
86
86
|
*
|
|
87
|
-
* directive
|
|
88
|
-
* directive
|
|
87
|
+
* directive?.name; // => 'compose'
|
|
88
|
+
* directive?.astNode?.loc; // => undefined
|
|
89
89
|
* ```
|
|
90
90
|
*/
|
|
91
91
|
export declare function buildSchema(
|
|
@@ -42,19 +42,19 @@ var _extendSchema = require('./extendSchema.js');
|
|
|
42
42
|
* const document = parse('type Query { hello: String }');
|
|
43
43
|
* const schema = buildASTSchema(document);
|
|
44
44
|
*
|
|
45
|
-
* schema.getQueryType()
|
|
45
|
+
* schema.getQueryType()?.name; // => 'Query'
|
|
46
46
|
* ```
|
|
47
47
|
* @example
|
|
48
48
|
* ```ts
|
|
49
|
-
* // This variant uses validation options when the SDL references unknown types.
|
|
50
49
|
* import { parse } from 'graphql/language';
|
|
51
50
|
* import { buildASTSchema } from 'graphql/utilities';
|
|
52
51
|
*
|
|
53
|
-
* const document = parse('type Query {
|
|
52
|
+
* const document = parse('type Query { greeting: String greeting: String }');
|
|
54
53
|
*
|
|
55
54
|
* buildASTSchema(document); // throws an error
|
|
55
|
+
*
|
|
56
|
+
* // Skipping SDL validation allows the duplicate field definition.
|
|
56
57
|
* buildASTSchema(document, {
|
|
57
|
-
* assumeValid: true,
|
|
58
58
|
* assumeValidSDL: true,
|
|
59
59
|
* }); // does not throw
|
|
60
60
|
* ```
|
|
@@ -133,7 +133,7 @@ function buildASTSchema(documentAST, options) {
|
|
|
133
133
|
*
|
|
134
134
|
* const schema = buildSchema('type Query { hello: String }');
|
|
135
135
|
*
|
|
136
|
-
* schema.getQueryType()
|
|
136
|
+
* schema.getQueryType()?.name; // => 'Query'
|
|
137
137
|
* ```
|
|
138
138
|
* @example
|
|
139
139
|
* ```ts
|
|
@@ -141,7 +141,7 @@ function buildASTSchema(documentAST, options) {
|
|
|
141
141
|
* import { buildSchema } from 'graphql/utilities';
|
|
142
142
|
*
|
|
143
143
|
* const schema = buildSchema(
|
|
144
|
-
* 'directive @tag on
|
|
144
|
+
* 'directive @tag on DIRECTIVE_DEFINITION\n' +
|
|
145
145
|
* 'directive @compose @tag on FIELD_DEFINITION',
|
|
146
146
|
* {
|
|
147
147
|
* experimentalDirectivesOnDirectiveDefinitions: true,
|
|
@@ -151,24 +151,13 @@ function buildASTSchema(documentAST, options) {
|
|
|
151
151
|
*
|
|
152
152
|
* const directive = schema.getDirective('compose');
|
|
153
153
|
*
|
|
154
|
-
* directive
|
|
155
|
-
* directive
|
|
154
|
+
* directive?.name; // => 'compose'
|
|
155
|
+
* directive?.astNode?.loc; // => undefined
|
|
156
156
|
* ```
|
|
157
157
|
*/
|
|
158
158
|
|
|
159
159
|
function buildSchema(source, options) {
|
|
160
|
-
const document = (0, _parser.parse)(source,
|
|
161
|
-
noLocation:
|
|
162
|
-
options === null || options === void 0 ? void 0 : options.noLocation,
|
|
163
|
-
allowLegacyFragmentVariables:
|
|
164
|
-
options === null || options === void 0
|
|
165
|
-
? void 0
|
|
166
|
-
: options.allowLegacyFragmentVariables,
|
|
167
|
-
experimentalDirectivesOnDirectiveDefinitions:
|
|
168
|
-
options === null || options === void 0
|
|
169
|
-
? void 0
|
|
170
|
-
: options.experimentalDirectivesOnDirectiveDefinitions,
|
|
171
|
-
});
|
|
160
|
+
const document = (0, _parser.parse)(source, options);
|
|
172
161
|
return buildASTSchema(document, {
|
|
173
162
|
assumeValidSDL:
|
|
174
163
|
options === null || options === void 0 ? void 0 : options.assumeValidSDL,
|
|
@@ -28,19 +28,19 @@ import { extendSchemaImpl } from './extendSchema.mjs';
|
|
|
28
28
|
* const document = parse('type Query { hello: String }');
|
|
29
29
|
* const schema = buildASTSchema(document);
|
|
30
30
|
*
|
|
31
|
-
* schema.getQueryType()
|
|
31
|
+
* schema.getQueryType()?.name; // => 'Query'
|
|
32
32
|
* ```
|
|
33
33
|
* @example
|
|
34
34
|
* ```ts
|
|
35
|
-
* // This variant uses validation options when the SDL references unknown types.
|
|
36
35
|
* import { parse } from 'graphql/language';
|
|
37
36
|
* import { buildASTSchema } from 'graphql/utilities';
|
|
38
37
|
*
|
|
39
|
-
* const document = parse('type Query {
|
|
38
|
+
* const document = parse('type Query { greeting: String greeting: String }');
|
|
40
39
|
*
|
|
41
40
|
* buildASTSchema(document); // throws an error
|
|
41
|
+
*
|
|
42
|
+
* // Skipping SDL validation allows the duplicate field definition.
|
|
42
43
|
* buildASTSchema(document, {
|
|
43
|
-
* assumeValid: true,
|
|
44
44
|
* assumeValidSDL: true,
|
|
45
45
|
* }); // does not throw
|
|
46
46
|
* ```
|
|
@@ -115,7 +115,7 @@ export function buildASTSchema(documentAST, options) {
|
|
|
115
115
|
*
|
|
116
116
|
* const schema = buildSchema('type Query { hello: String }');
|
|
117
117
|
*
|
|
118
|
-
* schema.getQueryType()
|
|
118
|
+
* schema.getQueryType()?.name; // => 'Query'
|
|
119
119
|
* ```
|
|
120
120
|
* @example
|
|
121
121
|
* ```ts
|
|
@@ -123,7 +123,7 @@ export function buildASTSchema(documentAST, options) {
|
|
|
123
123
|
* import { buildSchema } from 'graphql/utilities';
|
|
124
124
|
*
|
|
125
125
|
* const schema = buildSchema(
|
|
126
|
-
* 'directive @tag on
|
|
126
|
+
* 'directive @tag on DIRECTIVE_DEFINITION\n' +
|
|
127
127
|
* 'directive @compose @tag on FIELD_DEFINITION',
|
|
128
128
|
* {
|
|
129
129
|
* experimentalDirectivesOnDirectiveDefinitions: true,
|
|
@@ -133,24 +133,13 @@ export function buildASTSchema(documentAST, options) {
|
|
|
133
133
|
*
|
|
134
134
|
* const directive = schema.getDirective('compose');
|
|
135
135
|
*
|
|
136
|
-
* directive
|
|
137
|
-
* directive
|
|
136
|
+
* directive?.name; // => 'compose'
|
|
137
|
+
* directive?.astNode?.loc; // => undefined
|
|
138
138
|
* ```
|
|
139
139
|
*/
|
|
140
140
|
|
|
141
141
|
export function buildSchema(source, options) {
|
|
142
|
-
const document = parse(source,
|
|
143
|
-
noLocation:
|
|
144
|
-
options === null || options === void 0 ? void 0 : options.noLocation,
|
|
145
|
-
allowLegacyFragmentVariables:
|
|
146
|
-
options === null || options === void 0
|
|
147
|
-
? void 0
|
|
148
|
-
: options.allowLegacyFragmentVariables,
|
|
149
|
-
experimentalDirectivesOnDirectiveDefinitions:
|
|
150
|
-
options === null || options === void 0
|
|
151
|
-
? void 0
|
|
152
|
-
: options.experimentalDirectivesOnDirectiveDefinitions,
|
|
153
|
-
});
|
|
142
|
+
const document = parse(source, options);
|
|
154
143
|
return buildASTSchema(document, {
|
|
155
144
|
assumeValidSDL:
|
|
156
145
|
options === null || options === void 0 ? void 0 : options.assumeValidSDL,
|
|
@@ -18,14 +18,18 @@ import type { IntrospectionQuery } from './getIntrospectionQuery';
|
|
|
18
18
|
* @returns The client schema represented by the introspection result.
|
|
19
19
|
* @example
|
|
20
20
|
* ```ts
|
|
21
|
-
* import {
|
|
21
|
+
* import {
|
|
22
|
+
* buildClientSchema,
|
|
23
|
+
* introspectionFromSchema,
|
|
24
|
+
* buildSchema,
|
|
25
|
+
* } from 'graphql/utilities';
|
|
22
26
|
*
|
|
23
27
|
* const schema = buildSchema('type Query { hello: String }');
|
|
24
28
|
* const clientSchema = buildClientSchema(introspectionFromSchema(schema), {
|
|
25
29
|
* assumeValid: true,
|
|
26
30
|
* });
|
|
27
31
|
*
|
|
28
|
-
* clientSchema.getQueryType()
|
|
32
|
+
* clientSchema.getQueryType()?.name; // => 'Query'
|
|
29
33
|
* ```
|
|
30
34
|
*/
|
|
31
35
|
export declare function buildClientSchema(
|
|
@@ -45,14 +45,18 @@ var _valueFromAST = require('./valueFromAST.js');
|
|
|
45
45
|
* @returns The client schema represented by the introspection result.
|
|
46
46
|
* @example
|
|
47
47
|
* ```ts
|
|
48
|
-
* import {
|
|
48
|
+
* import {
|
|
49
|
+
* buildClientSchema,
|
|
50
|
+
* introspectionFromSchema,
|
|
51
|
+
* buildSchema,
|
|
52
|
+
* } from 'graphql/utilities';
|
|
49
53
|
*
|
|
50
54
|
* const schema = buildSchema('type Query { hello: String }');
|
|
51
55
|
* const clientSchema = buildClientSchema(introspectionFromSchema(schema), {
|
|
52
56
|
* assumeValid: true,
|
|
53
57
|
* });
|
|
54
58
|
*
|
|
55
|
-
* clientSchema.getQueryType()
|
|
59
|
+
* clientSchema.getQueryType()?.name; // => 'Query'
|
|
56
60
|
* ```
|
|
57
61
|
*/
|
|
58
62
|
function buildClientSchema(introspection, options) {
|
|
@@ -40,14 +40,18 @@ import { valueFromAST } from './valueFromAST.mjs';
|
|
|
40
40
|
* @returns The client schema represented by the introspection result.
|
|
41
41
|
* @example
|
|
42
42
|
* ```ts
|
|
43
|
-
* import {
|
|
43
|
+
* import {
|
|
44
|
+
* buildClientSchema,
|
|
45
|
+
* introspectionFromSchema,
|
|
46
|
+
* buildSchema,
|
|
47
|
+
* } from 'graphql/utilities';
|
|
44
48
|
*
|
|
45
49
|
* const schema = buildSchema('type Query { hello: String }');
|
|
46
50
|
* const clientSchema = buildClientSchema(introspectionFromSchema(schema), {
|
|
47
51
|
* assumeValid: true,
|
|
48
52
|
* });
|
|
49
53
|
*
|
|
50
|
-
* clientSchema.getQueryType()
|
|
54
|
+
* clientSchema.getQueryType()?.name; // => 'Query'
|
|
51
55
|
* ```
|
|
52
56
|
*/
|
|
53
57
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Maybe } from '../jsutils/Maybe';
|
|
2
2
|
import { GraphQLError } from '../error/GraphQLError';
|
|
3
3
|
import type { GraphQLInputType } from '../type/definition';
|
|
4
4
|
declare type OnErrorCB = (
|
|
@@ -11,6 +11,7 @@ declare type OnErrorCB = (
|
|
|
11
11
|
* @param inputValue - JavaScript value to coerce.
|
|
12
12
|
* @param type - GraphQL input type to coerce the value against.
|
|
13
13
|
* @param onError - Callback invoked for each coercion error.
|
|
14
|
+
* @param hideSuggestions - Omit suggestions from error messages.
|
|
14
15
|
* @returns Coerced value, or undefined if coercion failed and errors were reported.
|
|
15
16
|
* @example
|
|
16
17
|
* ```ts
|
|
@@ -32,7 +33,7 @@ declare type OnErrorCB = (
|
|
|
32
33
|
* },
|
|
33
34
|
* });
|
|
34
35
|
*
|
|
35
|
-
* coerceInputValue({ stars:
|
|
36
|
+
* coerceInputValue({ stars: 5, tags: ['featured'] }, ReviewInput); // => { stars: 5, tags: ['featured'] }
|
|
36
37
|
* coerceInputValue({ stars: 'bad' }, ReviewInput); // throws an error
|
|
37
38
|
* ```
|
|
38
39
|
* @example
|
|
@@ -41,7 +42,11 @@ declare type OnErrorCB = (
|
|
|
41
42
|
* import { GraphQLInt, GraphQLNonNull } from 'graphql/type';
|
|
42
43
|
* import { coerceInputValue } from 'graphql/utilities';
|
|
43
44
|
*
|
|
44
|
-
* const errors
|
|
45
|
+
* const errors: Array<{
|
|
46
|
+
* path: ReadonlyArray<string | number>;
|
|
47
|
+
* invalidValue: unknown;
|
|
48
|
+
* message: string;
|
|
49
|
+
* }> = [];
|
|
45
50
|
* const value = coerceInputValue(
|
|
46
51
|
* null,
|
|
47
52
|
* new GraphQLNonNull(GraphQLInt),
|
|
@@ -58,5 +63,6 @@ export declare function coerceInputValue(
|
|
|
58
63
|
inputValue: unknown,
|
|
59
64
|
type: GraphQLInputType,
|
|
60
65
|
onError?: OnErrorCB,
|
|
66
|
+
hideSuggestions?: Maybe<boolean>,
|
|
61
67
|
): unknown;
|
|
62
68
|
export {};
|