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/type/directives.js
CHANGED
|
@@ -122,7 +122,8 @@ class GraphQLDirective {
|
|
|
122
122
|
* @param config - Configuration describing this object.
|
|
123
123
|
* @example
|
|
124
124
|
* ```ts
|
|
125
|
-
* import
|
|
125
|
+
* import assert from 'node:assert/strict';
|
|
126
|
+
* import { DirectiveLocation, parse, Kind } from 'graphql/language';
|
|
126
127
|
* import {
|
|
127
128
|
* GraphQLBoolean,
|
|
128
129
|
* GraphQLDirective,
|
|
@@ -130,10 +131,15 @@ class GraphQLDirective {
|
|
|
130
131
|
* GraphQLNonNull,
|
|
131
132
|
* } from 'graphql/type';
|
|
132
133
|
*
|
|
133
|
-
* const document = parse(
|
|
134
|
+
* const document = parse(
|
|
135
|
+
* `
|
|
134
136
|
* directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION
|
|
135
|
-
* extend directive @cacheControl
|
|
136
|
-
*
|
|
137
|
+
* extend directive @cacheControl @tag
|
|
138
|
+
* `,
|
|
139
|
+
* { experimentalDirectivesOnDirectiveDefinitions: true },
|
|
140
|
+
* );
|
|
141
|
+
* assert(document.definitions[0].kind === Kind.DIRECTIVE_DEFINITION);
|
|
142
|
+
* assert(document.definitions[1].kind === Kind.DIRECTIVE_EXTENSION);
|
|
137
143
|
* const definition = document.definitions[0];
|
|
138
144
|
*
|
|
139
145
|
* const cacheControl = new GraphQLDirective({
|
|
@@ -150,14 +156,14 @@ class GraphQLDirective {
|
|
|
150
156
|
* },
|
|
151
157
|
* maxAge: {
|
|
152
158
|
* type: GraphQLInt,
|
|
153
|
-
* astNode: definition.arguments[0],
|
|
159
|
+
* astNode: definition.arguments?.[0],
|
|
154
160
|
* },
|
|
155
161
|
* },
|
|
156
162
|
* isRepeatable: true,
|
|
157
163
|
* deprecationReason: 'Use @cache instead.',
|
|
158
164
|
* extensions: { scope: 'cache' },
|
|
159
165
|
* astNode: definition,
|
|
160
|
-
* extensionASTNodes: [
|
|
166
|
+
* extensionASTNodes: [document.definitions[1]],
|
|
161
167
|
* });
|
|
162
168
|
*
|
|
163
169
|
* cacheControl.name; // => 'cacheControl'
|
package/type/directives.mjs
CHANGED
|
@@ -99,7 +99,8 @@ export class GraphQLDirective {
|
|
|
99
99
|
* @param config - Configuration describing this object.
|
|
100
100
|
* @example
|
|
101
101
|
* ```ts
|
|
102
|
-
* import
|
|
102
|
+
* import assert from 'node:assert/strict';
|
|
103
|
+
* import { DirectiveLocation, parse, Kind } from 'graphql/language';
|
|
103
104
|
* import {
|
|
104
105
|
* GraphQLBoolean,
|
|
105
106
|
* GraphQLDirective,
|
|
@@ -107,10 +108,15 @@ export class GraphQLDirective {
|
|
|
107
108
|
* GraphQLNonNull,
|
|
108
109
|
* } from 'graphql/type';
|
|
109
110
|
*
|
|
110
|
-
* const document = parse(
|
|
111
|
+
* const document = parse(
|
|
112
|
+
* `
|
|
111
113
|
* directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION
|
|
112
|
-
* extend directive @cacheControl
|
|
113
|
-
*
|
|
114
|
+
* extend directive @cacheControl @tag
|
|
115
|
+
* `,
|
|
116
|
+
* { experimentalDirectivesOnDirectiveDefinitions: true },
|
|
117
|
+
* );
|
|
118
|
+
* assert(document.definitions[0].kind === Kind.DIRECTIVE_DEFINITION);
|
|
119
|
+
* assert(document.definitions[1].kind === Kind.DIRECTIVE_EXTENSION);
|
|
114
120
|
* const definition = document.definitions[0];
|
|
115
121
|
*
|
|
116
122
|
* const cacheControl = new GraphQLDirective({
|
|
@@ -127,14 +133,14 @@ export class GraphQLDirective {
|
|
|
127
133
|
* },
|
|
128
134
|
* maxAge: {
|
|
129
135
|
* type: GraphQLInt,
|
|
130
|
-
* astNode: definition.arguments[0],
|
|
136
|
+
* astNode: definition.arguments?.[0],
|
|
131
137
|
* },
|
|
132
138
|
* },
|
|
133
139
|
* isRepeatable: true,
|
|
134
140
|
* deprecationReason: 'Use @cache instead.',
|
|
135
141
|
* extensions: { scope: 'cache' },
|
|
136
142
|
* astNode: definition,
|
|
137
|
-
* extensionASTNodes: [
|
|
143
|
+
* extensionASTNodes: [document.definitions[1]],
|
|
138
144
|
* });
|
|
139
145
|
*
|
|
140
146
|
* cacheControl.name; // => 'cacheControl'
|
package/type/scalars.js
CHANGED
|
@@ -100,7 +100,7 @@ const GraphQLInt = new _definition.GraphQLScalarType({
|
|
|
100
100
|
parseLiteral(valueNode) {
|
|
101
101
|
if (valueNode.kind !== _kinds.Kind.INT) {
|
|
102
102
|
throw new _GraphQLError.GraphQLError(
|
|
103
|
-
`Int cannot represent non-integer value: ${(0, _printer.
|
|
103
|
+
`Int cannot represent non-integer value: ${(0, _printer.printForError)(
|
|
104
104
|
valueNode,
|
|
105
105
|
)}`,
|
|
106
106
|
{
|
|
@@ -173,9 +173,8 @@ const GraphQLFloat = new _definition.GraphQLScalarType({
|
|
|
173
173
|
valueNode.kind !== _kinds.Kind.INT
|
|
174
174
|
) {
|
|
175
175
|
throw new _GraphQLError.GraphQLError(
|
|
176
|
-
`Float cannot represent non numeric value: ${(0,
|
|
177
|
-
|
|
178
|
-
)}`,
|
|
176
|
+
`Float cannot represent non numeric value: ${(0,
|
|
177
|
+
_printer.printForError)(valueNode)}`,
|
|
179
178
|
valueNode,
|
|
180
179
|
);
|
|
181
180
|
}
|
|
@@ -227,9 +226,8 @@ const GraphQLString = new _definition.GraphQLScalarType({
|
|
|
227
226
|
parseLiteral(valueNode) {
|
|
228
227
|
if (valueNode.kind !== _kinds.Kind.STRING) {
|
|
229
228
|
throw new _GraphQLError.GraphQLError(
|
|
230
|
-
`String cannot represent a non string value: ${(0,
|
|
231
|
-
|
|
232
|
-
)}`,
|
|
229
|
+
`String cannot represent a non string value: ${(0,
|
|
230
|
+
_printer.printForError)(valueNode)}`,
|
|
233
231
|
{
|
|
234
232
|
nodes: valueNode,
|
|
235
233
|
},
|
|
@@ -279,9 +277,8 @@ const GraphQLBoolean = new _definition.GraphQLScalarType({
|
|
|
279
277
|
parseLiteral(valueNode) {
|
|
280
278
|
if (valueNode.kind !== _kinds.Kind.BOOLEAN) {
|
|
281
279
|
throw new _GraphQLError.GraphQLError(
|
|
282
|
-
`Boolean cannot represent a non boolean value: ${(0,
|
|
283
|
-
|
|
284
|
-
)}`,
|
|
280
|
+
`Boolean cannot represent a non boolean value: ${(0,
|
|
281
|
+
_printer.printForError)(valueNode)}`,
|
|
285
282
|
{
|
|
286
283
|
nodes: valueNode,
|
|
287
284
|
},
|
|
@@ -336,7 +333,7 @@ const GraphQLID = new _definition.GraphQLScalarType({
|
|
|
336
333
|
) {
|
|
337
334
|
throw new _GraphQLError.GraphQLError(
|
|
338
335
|
'ID cannot represent a non-string and non-integer value: ' +
|
|
339
|
-
(0, _printer.
|
|
336
|
+
(0, _printer.printForError)(valueNode),
|
|
340
337
|
{
|
|
341
338
|
nodes: valueNode,
|
|
342
339
|
},
|
package/type/scalars.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { inspect } from '../jsutils/inspect.mjs';
|
|
|
3
3
|
import { isObjectLike } from '../jsutils/isObjectLike.mjs';
|
|
4
4
|
import { GraphQLError } from '../error/GraphQLError.mjs';
|
|
5
5
|
import { Kind } from '../language/kinds.mjs';
|
|
6
|
-
import { print } from '../language/printer.mjs';
|
|
6
|
+
import { printForError as print } from '../language/printer.mjs';
|
|
7
7
|
import { GraphQLScalarType } from './definition.mjs';
|
|
8
8
|
/**
|
|
9
9
|
* Maximum possible Int value as per GraphQL Spec (32-bit signed integer).
|
package/type/schema.d.ts
CHANGED
|
@@ -73,6 +73,8 @@ export interface GraphQLSchemaExtensions {
|
|
|
73
73
|
* validator and executor.
|
|
74
74
|
* @example
|
|
75
75
|
* ```ts
|
|
76
|
+
* import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql';
|
|
77
|
+
*
|
|
76
78
|
* const MyAppQueryRootType = new GraphQLObjectType({
|
|
77
79
|
* name: 'Query',
|
|
78
80
|
* fields: {
|
|
@@ -98,6 +100,13 @@ export interface GraphQLSchemaExtensions {
|
|
|
98
100
|
* referenced.
|
|
99
101
|
*
|
|
100
102
|
* ```ts
|
|
103
|
+
* import {
|
|
104
|
+
* GraphQLInterfaceType,
|
|
105
|
+
* GraphQLObjectType,
|
|
106
|
+
* GraphQLSchema,
|
|
107
|
+
* GraphQLString,
|
|
108
|
+
* } from 'graphql';
|
|
109
|
+
*
|
|
101
110
|
* const characterInterface = new GraphQLInterfaceType({
|
|
102
111
|
* name: 'Character',
|
|
103
112
|
* fields: {
|
|
@@ -142,9 +151,26 @@ export interface GraphQLSchemaExtensions {
|
|
|
142
151
|
* these specified directives, you must explicitly declare them.
|
|
143
152
|
*
|
|
144
153
|
* ```ts
|
|
154
|
+
* import {
|
|
155
|
+
* DirectiveLocation,
|
|
156
|
+
* GraphQLDirective,
|
|
157
|
+
* GraphQLObjectType,
|
|
158
|
+
* GraphQLSchema,
|
|
159
|
+
* GraphQLString,
|
|
160
|
+
* specifiedDirectives,
|
|
161
|
+
* } from 'graphql';
|
|
162
|
+
*
|
|
145
163
|
* const MyAppSchema = new GraphQLSchema({
|
|
146
|
-
* query:
|
|
147
|
-
*
|
|
164
|
+
* query: new GraphQLObjectType({
|
|
165
|
+
* name: 'Query',
|
|
166
|
+
* fields: { greeting: { type: GraphQLString } },
|
|
167
|
+
* }),
|
|
168
|
+
* directives: specifiedDirectives.concat([
|
|
169
|
+
* new GraphQLDirective({
|
|
170
|
+
* name: 'custom',
|
|
171
|
+
* locations: [DirectiveLocation.FIELD],
|
|
172
|
+
* }),
|
|
173
|
+
* ]),
|
|
148
174
|
* });
|
|
149
175
|
* ```
|
|
150
176
|
*/
|
|
@@ -175,11 +201,7 @@ export declare class GraphQLSchema {
|
|
|
175
201
|
* @example
|
|
176
202
|
* ```ts
|
|
177
203
|
* // Create a schema with the required query root.
|
|
178
|
-
* import {
|
|
179
|
-
* GraphQLObjectType,
|
|
180
|
-
* GraphQLSchema,
|
|
181
|
-
* GraphQLString,
|
|
182
|
-
* } from 'graphql/type';
|
|
204
|
+
* import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql/type';
|
|
183
205
|
*
|
|
184
206
|
* const Query = new GraphQLObjectType({
|
|
185
207
|
* name: 'Query',
|
|
@@ -201,8 +223,9 @@ export declare class GraphQLSchema {
|
|
|
201
223
|
* ```
|
|
202
224
|
* @example
|
|
203
225
|
* ```ts
|
|
226
|
+
* import assert from 'node:assert/strict';
|
|
204
227
|
* // This variant configures every schema option, including directives and extensions.
|
|
205
|
-
* import { DirectiveLocation, parse } from 'graphql/language';
|
|
228
|
+
* import { DirectiveLocation, parse, Kind } from 'graphql/language';
|
|
206
229
|
* import {
|
|
207
230
|
* GraphQLBoolean,
|
|
208
231
|
* GraphQLDirective,
|
|
@@ -241,6 +264,8 @@ export declare class GraphQLSchema {
|
|
|
241
264
|
*
|
|
242
265
|
* extend schema @auth
|
|
243
266
|
* `);
|
|
267
|
+
* assert(schemaDocument.definitions[0].kind === Kind.SCHEMA_DEFINITION);
|
|
268
|
+
* assert(schemaDocument.definitions[1].kind === Kind.SCHEMA_EXTENSION);
|
|
244
269
|
*
|
|
245
270
|
* const schema = new GraphQLSchema({
|
|
246
271
|
* description: 'Operations exposed by the application.',
|
|
@@ -251,7 +276,7 @@ export declare class GraphQLSchema {
|
|
|
251
276
|
* directives: [authDirective],
|
|
252
277
|
* extensions: { owner: 'platform' },
|
|
253
278
|
* astNode: schemaDocument.definitions[0],
|
|
254
|
-
* extensionASTNodes: [
|
|
279
|
+
* extensionASTNodes: [schemaDocument.definitions[1]],
|
|
255
280
|
* assumeValid: true,
|
|
256
281
|
* });
|
|
257
282
|
*
|
|
@@ -536,7 +561,7 @@ export declare class GraphQLSchema {
|
|
|
536
561
|
* }
|
|
537
562
|
* `);
|
|
538
563
|
*
|
|
539
|
-
* schema.getDirectives().map((directive) => directive.name); // => ['include', 'skip', 'deprecated', 'specifiedBy', 'oneOf'
|
|
564
|
+
* schema.getDirectives().map((directive) => directive.name); // => ['upper', 'include', 'skip', 'deprecated', 'specifiedBy', 'oneOf']
|
|
540
565
|
* ```
|
|
541
566
|
*/
|
|
542
567
|
getDirectives(): ReadonlyArray<GraphQLDirective>;
|
|
@@ -609,7 +634,7 @@ export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
|
|
|
609
634
|
mutation?: Maybe<GraphQLObjectType>;
|
|
610
635
|
/** Root object type for subscription operations. */
|
|
611
636
|
subscription?: Maybe<GraphQLObjectType>;
|
|
612
|
-
/**
|
|
637
|
+
/** Additional named types to include in the schema. */
|
|
613
638
|
types?: Maybe<ReadonlyArray<GraphQLNamedType>>;
|
|
614
639
|
/** Directives available in this schema or applied to this AST node. */
|
|
615
640
|
directives?: Maybe<ReadonlyArray<GraphQLDirective>>;
|
package/type/schema.js
CHANGED
|
@@ -95,6 +95,8 @@ function assertSchema(schema) {
|
|
|
95
95
|
* validator and executor.
|
|
96
96
|
* @example
|
|
97
97
|
* ```ts
|
|
98
|
+
* import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql';
|
|
99
|
+
*
|
|
98
100
|
* const MyAppQueryRootType = new GraphQLObjectType({
|
|
99
101
|
* name: 'Query',
|
|
100
102
|
* fields: {
|
|
@@ -120,6 +122,13 @@ function assertSchema(schema) {
|
|
|
120
122
|
* referenced.
|
|
121
123
|
*
|
|
122
124
|
* ```ts
|
|
125
|
+
* import {
|
|
126
|
+
* GraphQLInterfaceType,
|
|
127
|
+
* GraphQLObjectType,
|
|
128
|
+
* GraphQLSchema,
|
|
129
|
+
* GraphQLString,
|
|
130
|
+
* } from 'graphql';
|
|
131
|
+
*
|
|
123
132
|
* const characterInterface = new GraphQLInterfaceType({
|
|
124
133
|
* name: 'Character',
|
|
125
134
|
* fields: {
|
|
@@ -164,9 +173,26 @@ function assertSchema(schema) {
|
|
|
164
173
|
* these specified directives, you must explicitly declare them.
|
|
165
174
|
*
|
|
166
175
|
* ```ts
|
|
176
|
+
* import {
|
|
177
|
+
* DirectiveLocation,
|
|
178
|
+
* GraphQLDirective,
|
|
179
|
+
* GraphQLObjectType,
|
|
180
|
+
* GraphQLSchema,
|
|
181
|
+
* GraphQLString,
|
|
182
|
+
* specifiedDirectives,
|
|
183
|
+
* } from 'graphql';
|
|
184
|
+
*
|
|
167
185
|
* const MyAppSchema = new GraphQLSchema({
|
|
168
|
-
* query:
|
|
169
|
-
*
|
|
186
|
+
* query: new GraphQLObjectType({
|
|
187
|
+
* name: 'Query',
|
|
188
|
+
* fields: { greeting: { type: GraphQLString } },
|
|
189
|
+
* }),
|
|
190
|
+
* directives: specifiedDirectives.concat([
|
|
191
|
+
* new GraphQLDirective({
|
|
192
|
+
* name: 'custom',
|
|
193
|
+
* locations: [DirectiveLocation.FIELD],
|
|
194
|
+
* }),
|
|
195
|
+
* ]),
|
|
170
196
|
* });
|
|
171
197
|
* ```
|
|
172
198
|
*/
|
|
@@ -190,11 +216,7 @@ class GraphQLSchema {
|
|
|
190
216
|
* @example
|
|
191
217
|
* ```ts
|
|
192
218
|
* // Create a schema with the required query root.
|
|
193
|
-
* import {
|
|
194
|
-
* GraphQLObjectType,
|
|
195
|
-
* GraphQLSchema,
|
|
196
|
-
* GraphQLString,
|
|
197
|
-
* } from 'graphql/type';
|
|
219
|
+
* import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql/type';
|
|
198
220
|
*
|
|
199
221
|
* const Query = new GraphQLObjectType({
|
|
200
222
|
* name: 'Query',
|
|
@@ -216,8 +238,9 @@ class GraphQLSchema {
|
|
|
216
238
|
* ```
|
|
217
239
|
* @example
|
|
218
240
|
* ```ts
|
|
241
|
+
* import assert from 'node:assert/strict';
|
|
219
242
|
* // This variant configures every schema option, including directives and extensions.
|
|
220
|
-
* import { DirectiveLocation, parse } from 'graphql/language';
|
|
243
|
+
* import { DirectiveLocation, parse, Kind } from 'graphql/language';
|
|
221
244
|
* import {
|
|
222
245
|
* GraphQLBoolean,
|
|
223
246
|
* GraphQLDirective,
|
|
@@ -256,6 +279,8 @@ class GraphQLSchema {
|
|
|
256
279
|
*
|
|
257
280
|
* extend schema @auth
|
|
258
281
|
* `);
|
|
282
|
+
* assert(schemaDocument.definitions[0].kind === Kind.SCHEMA_DEFINITION);
|
|
283
|
+
* assert(schemaDocument.definitions[1].kind === Kind.SCHEMA_EXTENSION);
|
|
259
284
|
*
|
|
260
285
|
* const schema = new GraphQLSchema({
|
|
261
286
|
* description: 'Operations exposed by the application.',
|
|
@@ -266,7 +291,7 @@ class GraphQLSchema {
|
|
|
266
291
|
* directives: [authDirective],
|
|
267
292
|
* extensions: { owner: 'platform' },
|
|
268
293
|
* astNode: schemaDocument.definitions[0],
|
|
269
|
-
* extensionASTNodes: [
|
|
294
|
+
* extensionASTNodes: [schemaDocument.definitions[1]],
|
|
270
295
|
* assumeValid: true,
|
|
271
296
|
* });
|
|
272
297
|
*
|
|
@@ -750,7 +775,7 @@ class GraphQLSchema {
|
|
|
750
775
|
* }
|
|
751
776
|
* `);
|
|
752
777
|
*
|
|
753
|
-
* schema.getDirectives().map((directive) => directive.name); // => ['include', 'skip', 'deprecated', 'specifiedBy', 'oneOf'
|
|
778
|
+
* schema.getDirectives().map((directive) => directive.name); // => ['upper', 'include', 'skip', 'deprecated', 'specifiedBy', 'oneOf']
|
|
754
779
|
* ```
|
|
755
780
|
*/
|
|
756
781
|
|
package/type/schema.mjs
CHANGED
|
@@ -81,6 +81,8 @@ export function assertSchema(schema) {
|
|
|
81
81
|
* validator and executor.
|
|
82
82
|
* @example
|
|
83
83
|
* ```ts
|
|
84
|
+
* import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql';
|
|
85
|
+
*
|
|
84
86
|
* const MyAppQueryRootType = new GraphQLObjectType({
|
|
85
87
|
* name: 'Query',
|
|
86
88
|
* fields: {
|
|
@@ -106,6 +108,13 @@ export function assertSchema(schema) {
|
|
|
106
108
|
* referenced.
|
|
107
109
|
*
|
|
108
110
|
* ```ts
|
|
111
|
+
* import {
|
|
112
|
+
* GraphQLInterfaceType,
|
|
113
|
+
* GraphQLObjectType,
|
|
114
|
+
* GraphQLSchema,
|
|
115
|
+
* GraphQLString,
|
|
116
|
+
* } from 'graphql';
|
|
117
|
+
*
|
|
109
118
|
* const characterInterface = new GraphQLInterfaceType({
|
|
110
119
|
* name: 'Character',
|
|
111
120
|
* fields: {
|
|
@@ -150,9 +159,26 @@ export function assertSchema(schema) {
|
|
|
150
159
|
* these specified directives, you must explicitly declare them.
|
|
151
160
|
*
|
|
152
161
|
* ```ts
|
|
162
|
+
* import {
|
|
163
|
+
* DirectiveLocation,
|
|
164
|
+
* GraphQLDirective,
|
|
165
|
+
* GraphQLObjectType,
|
|
166
|
+
* GraphQLSchema,
|
|
167
|
+
* GraphQLString,
|
|
168
|
+
* specifiedDirectives,
|
|
169
|
+
* } from 'graphql';
|
|
170
|
+
*
|
|
153
171
|
* const MyAppSchema = new GraphQLSchema({
|
|
154
|
-
* query:
|
|
155
|
-
*
|
|
172
|
+
* query: new GraphQLObjectType({
|
|
173
|
+
* name: 'Query',
|
|
174
|
+
* fields: { greeting: { type: GraphQLString } },
|
|
175
|
+
* }),
|
|
176
|
+
* directives: specifiedDirectives.concat([
|
|
177
|
+
* new GraphQLDirective({
|
|
178
|
+
* name: 'custom',
|
|
179
|
+
* locations: [DirectiveLocation.FIELD],
|
|
180
|
+
* }),
|
|
181
|
+
* ]),
|
|
156
182
|
* });
|
|
157
183
|
* ```
|
|
158
184
|
*/
|
|
@@ -176,11 +202,7 @@ export class GraphQLSchema {
|
|
|
176
202
|
* @example
|
|
177
203
|
* ```ts
|
|
178
204
|
* // Create a schema with the required query root.
|
|
179
|
-
* import {
|
|
180
|
-
* GraphQLObjectType,
|
|
181
|
-
* GraphQLSchema,
|
|
182
|
-
* GraphQLString,
|
|
183
|
-
* } from 'graphql/type';
|
|
205
|
+
* import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql/type';
|
|
184
206
|
*
|
|
185
207
|
* const Query = new GraphQLObjectType({
|
|
186
208
|
* name: 'Query',
|
|
@@ -202,8 +224,9 @@ export class GraphQLSchema {
|
|
|
202
224
|
* ```
|
|
203
225
|
* @example
|
|
204
226
|
* ```ts
|
|
227
|
+
* import assert from 'node:assert/strict';
|
|
205
228
|
* // This variant configures every schema option, including directives and extensions.
|
|
206
|
-
* import { DirectiveLocation, parse } from 'graphql/language';
|
|
229
|
+
* import { DirectiveLocation, parse, Kind } from 'graphql/language';
|
|
207
230
|
* import {
|
|
208
231
|
* GraphQLBoolean,
|
|
209
232
|
* GraphQLDirective,
|
|
@@ -242,6 +265,8 @@ export class GraphQLSchema {
|
|
|
242
265
|
*
|
|
243
266
|
* extend schema @auth
|
|
244
267
|
* `);
|
|
268
|
+
* assert(schemaDocument.definitions[0].kind === Kind.SCHEMA_DEFINITION);
|
|
269
|
+
* assert(schemaDocument.definitions[1].kind === Kind.SCHEMA_EXTENSION);
|
|
245
270
|
*
|
|
246
271
|
* const schema = new GraphQLSchema({
|
|
247
272
|
* description: 'Operations exposed by the application.',
|
|
@@ -252,7 +277,7 @@ export class GraphQLSchema {
|
|
|
252
277
|
* directives: [authDirective],
|
|
253
278
|
* extensions: { owner: 'platform' },
|
|
254
279
|
* astNode: schemaDocument.definitions[0],
|
|
255
|
-
* extensionASTNodes: [
|
|
280
|
+
* extensionASTNodes: [schemaDocument.definitions[1]],
|
|
256
281
|
* assumeValid: true,
|
|
257
282
|
* });
|
|
258
283
|
*
|
|
@@ -734,7 +759,7 @@ export class GraphQLSchema {
|
|
|
734
759
|
* }
|
|
735
760
|
* `);
|
|
736
761
|
*
|
|
737
|
-
* schema.getDirectives().map((directive) => directive.name); // => ['include', 'skip', 'deprecated', 'specifiedBy', 'oneOf'
|
|
762
|
+
* schema.getDirectives().map((directive) => directive.name); // => ['upper', 'include', 'skip', 'deprecated', 'specifiedBy', 'oneOf']
|
|
738
763
|
* ```
|
|
739
764
|
*/
|
|
740
765
|
|
package/type/validate.d.ts
CHANGED
|
@@ -19,9 +19,7 @@ import type { GraphQLSchema } from './schema';
|
|
|
19
19
|
* name: String
|
|
20
20
|
* }
|
|
21
21
|
* `);
|
|
22
|
-
* const errors = validateSchema(schema);
|
|
23
|
-
*
|
|
24
|
-
* errors; // => []
|
|
22
|
+
* const errors = validateSchema(schema); // => []
|
|
25
23
|
* ```
|
|
26
24
|
*/
|
|
27
25
|
export declare function validateSchema(
|
package/type/validate.js
CHANGED
package/type/validate.mjs
CHANGED
package/utilities/TypeInfo.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare class TypeInfo {
|
|
|
47
47
|
* }
|
|
48
48
|
* `);
|
|
49
49
|
* const typeInfo = new TypeInfo(schema);
|
|
50
|
-
* const seenTypes = [];
|
|
50
|
+
* const seenTypes: Array<string> = [];
|
|
51
51
|
*
|
|
52
52
|
* visit(
|
|
53
53
|
* parse('{ greeting }'),
|
|
@@ -134,7 +134,7 @@ export declare class TypeInfo {
|
|
|
134
134
|
* }
|
|
135
135
|
* `);
|
|
136
136
|
* const typeInfo = new TypeInfo(schema);
|
|
137
|
-
* const fieldTypes = {};
|
|
137
|
+
* const fieldTypes: Record<string, string> = {};
|
|
138
138
|
*
|
|
139
139
|
* visit(
|
|
140
140
|
* parse('{ viewer { name } }'),
|
|
@@ -167,7 +167,7 @@ export declare class TypeInfo {
|
|
|
167
167
|
* }
|
|
168
168
|
* `);
|
|
169
169
|
* const typeInfo = new TypeInfo(schema);
|
|
170
|
-
* const parentTypes = {};
|
|
170
|
+
* const parentTypes: Record<string, string> = {};
|
|
171
171
|
*
|
|
172
172
|
* visit(
|
|
173
173
|
* parse('{ viewer { name } }'),
|
|
@@ -201,7 +201,7 @@ export declare class TypeInfo {
|
|
|
201
201
|
* }
|
|
202
202
|
* `);
|
|
203
203
|
* const typeInfo = new TypeInfo(schema);
|
|
204
|
-
* const inputTypes = {};
|
|
204
|
+
* const inputTypes: Record<string, string> = {};
|
|
205
205
|
*
|
|
206
206
|
* visit(
|
|
207
207
|
* parse('{ reviews(stars: 5, sort: OLDEST) }'),
|
|
@@ -234,7 +234,7 @@ export declare class TypeInfo {
|
|
|
234
234
|
* }
|
|
235
235
|
* `);
|
|
236
236
|
* const typeInfo = new TypeInfo(schema);
|
|
237
|
-
* const parentInputTypes = {};
|
|
237
|
+
* const parentInputTypes: Record<string, string> = {};
|
|
238
238
|
*
|
|
239
239
|
* visit(
|
|
240
240
|
* parse('{ reviews(filter: { stars: 5 }) }'),
|
|
@@ -292,7 +292,7 @@ export declare class TypeInfo {
|
|
|
292
292
|
* }
|
|
293
293
|
* `);
|
|
294
294
|
* const typeInfo = new TypeInfo(schema);
|
|
295
|
-
* let defaultLimit;
|
|
295
|
+
* let defaultLimit: unknown;
|
|
296
296
|
*
|
|
297
297
|
* visit(
|
|
298
298
|
* parse('{ reviews(limit: 5) }'),
|
|
@@ -405,6 +405,7 @@ export declare class TypeInfo {
|
|
|
405
405
|
* @returns Nothing.
|
|
406
406
|
* @example
|
|
407
407
|
* ```ts
|
|
408
|
+
* import assert from 'node:assert/strict';
|
|
408
409
|
* import { Kind, parse } from 'graphql/language';
|
|
409
410
|
* import { buildSchema, TypeInfo } from 'graphql/utilities';
|
|
410
411
|
*
|
|
@@ -415,6 +416,7 @@ export declare class TypeInfo {
|
|
|
415
416
|
* `);
|
|
416
417
|
* const document = parse('{ greeting }');
|
|
417
418
|
* const operation = document.definitions[0];
|
|
419
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
418
420
|
* const selectionSet = operation.selectionSet;
|
|
419
421
|
* const field = selectionSet.selections[0];
|
|
420
422
|
* const typeInfo = new TypeInfo(schema);
|
|
@@ -430,12 +432,13 @@ export declare class TypeInfo {
|
|
|
430
432
|
*/
|
|
431
433
|
enter(node: ASTNode): void;
|
|
432
434
|
/**
|
|
433
|
-
* Updates this TypeInfo instance
|
|
434
|
-
* @param node - AST node being
|
|
435
|
+
* Updates this TypeInfo instance when leaving an AST node.
|
|
436
|
+
* @param node - AST node being left.
|
|
435
437
|
* @returns Nothing.
|
|
436
438
|
* @example
|
|
437
439
|
* ```ts
|
|
438
|
-
* import
|
|
440
|
+
* import assert from 'node:assert/strict';
|
|
441
|
+
* import { parse, Kind } from 'graphql/language';
|
|
439
442
|
* import { buildSchema, TypeInfo } from 'graphql/utilities';
|
|
440
443
|
*
|
|
441
444
|
* const schema = buildSchema(`
|
|
@@ -445,6 +448,7 @@ export declare class TypeInfo {
|
|
|
445
448
|
* `);
|
|
446
449
|
* const document = parse('{ greeting }');
|
|
447
450
|
* const operation = document.definitions[0];
|
|
451
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
448
452
|
* const selectionSet = operation.selectionSet;
|
|
449
453
|
* const field = selectionSet.selections[0];
|
|
450
454
|
* const typeInfo = new TypeInfo(schema);
|
|
@@ -455,7 +459,7 @@ export declare class TypeInfo {
|
|
|
455
459
|
* String(typeInfo.getType()); // => 'String'
|
|
456
460
|
*
|
|
457
461
|
* typeInfo.leave(field);
|
|
458
|
-
* typeInfo.getType(); // =>
|
|
462
|
+
* String(typeInfo.getType()); // => 'Query'
|
|
459
463
|
* ```
|
|
460
464
|
*/
|
|
461
465
|
leave(node: ASTNode): void;
|
|
@@ -482,7 +486,7 @@ declare type GetFieldDefFn = (
|
|
|
482
486
|
* }
|
|
483
487
|
* `);
|
|
484
488
|
* const typeInfo = new TypeInfo(schema);
|
|
485
|
-
* const fields = [];
|
|
489
|
+
* const fields: Array<{ name: string; parentType: string; type: string }> = [];
|
|
486
490
|
*
|
|
487
491
|
* visit(
|
|
488
492
|
* parse('{ greeting }'),
|