graphql 16.14.1 → 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 +190 -122
- package/type/definition.js +175 -102
- package/type/definition.mjs +174 -101
- package/type/directives.d.ts +14 -8
- package/type/directives.js +13 -7
- package/type/directives.mjs +13 -7
- package/type/scalars.js +8 -11
- package/type/scalars.mjs +1 -1
- package/type/schema.d.ts +38 -13
- package/type/schema.js +36 -11
- package/type/schema.mjs +36 -11
- 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.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export declare class GraphQLDirective {
|
|
|
77
77
|
isRepeatable: boolean;
|
|
78
78
|
/** Reason this element is deprecated, if one was provided. */
|
|
79
79
|
deprecationReason: Maybe<string>;
|
|
80
|
-
/**
|
|
80
|
+
/** Custom extension fields reserved for users. */
|
|
81
81
|
extensions: Readonly<GraphQLDirectiveExtensions>;
|
|
82
82
|
/** AST node from which this schema element was built, if available. */
|
|
83
83
|
astNode: Maybe<DirectiveDefinitionNode>;
|
|
@@ -88,7 +88,8 @@ export declare class GraphQLDirective {
|
|
|
88
88
|
* @param config - Configuration describing this object.
|
|
89
89
|
* @example
|
|
90
90
|
* ```ts
|
|
91
|
-
* import
|
|
91
|
+
* import assert from 'node:assert/strict';
|
|
92
|
+
* import { DirectiveLocation, parse, Kind } from 'graphql/language';
|
|
92
93
|
* import {
|
|
93
94
|
* GraphQLBoolean,
|
|
94
95
|
* GraphQLDirective,
|
|
@@ -96,10 +97,15 @@ export declare class GraphQLDirective {
|
|
|
96
97
|
* GraphQLNonNull,
|
|
97
98
|
* } from 'graphql/type';
|
|
98
99
|
*
|
|
99
|
-
* const document = parse(
|
|
100
|
+
* const document = parse(
|
|
101
|
+
* `
|
|
100
102
|
* directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION
|
|
101
|
-
* extend directive @cacheControl
|
|
102
|
-
*
|
|
103
|
+
* extend directive @cacheControl @tag
|
|
104
|
+
* `,
|
|
105
|
+
* { experimentalDirectivesOnDirectiveDefinitions: true },
|
|
106
|
+
* );
|
|
107
|
+
* assert(document.definitions[0].kind === Kind.DIRECTIVE_DEFINITION);
|
|
108
|
+
* assert(document.definitions[1].kind === Kind.DIRECTIVE_EXTENSION);
|
|
103
109
|
* const definition = document.definitions[0];
|
|
104
110
|
*
|
|
105
111
|
* const cacheControl = new GraphQLDirective({
|
|
@@ -116,14 +122,14 @@ export declare class GraphQLDirective {
|
|
|
116
122
|
* },
|
|
117
123
|
* maxAge: {
|
|
118
124
|
* type: GraphQLInt,
|
|
119
|
-
* astNode: definition.arguments[0],
|
|
125
|
+
* astNode: definition.arguments?.[0],
|
|
120
126
|
* },
|
|
121
127
|
* },
|
|
122
128
|
* isRepeatable: true,
|
|
123
129
|
* deprecationReason: 'Use @cache instead.',
|
|
124
130
|
* extensions: { scope: 'cache' },
|
|
125
131
|
* astNode: definition,
|
|
126
|
-
* extensionASTNodes: [
|
|
132
|
+
* extensionASTNodes: [document.definitions[1]],
|
|
127
133
|
* });
|
|
128
134
|
*
|
|
129
135
|
* cacheControl.name; // => 'cacheControl'
|
|
@@ -214,7 +220,7 @@ export interface GraphQLDirectiveConfig {
|
|
|
214
220
|
isRepeatable?: Maybe<boolean>;
|
|
215
221
|
/** Reason this element is deprecated, if one was provided. */
|
|
216
222
|
deprecationReason?: Maybe<string>;
|
|
217
|
-
/**
|
|
223
|
+
/** Custom extension fields reserved for users. */
|
|
218
224
|
extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;
|
|
219
225
|
/** AST node from which this schema element was built, if available. */
|
|
220
226
|
astNode?: Maybe<DirectiveDefinitionNode>;
|
package/type/directives.js
CHANGED
|
@@ -111,7 +111,7 @@ class GraphQLDirective {
|
|
|
111
111
|
|
|
112
112
|
/** Reason this element is deprecated, if one was provided. */
|
|
113
113
|
|
|
114
|
-
/**
|
|
114
|
+
/** Custom extension fields reserved for users. */
|
|
115
115
|
|
|
116
116
|
/** AST node from which this schema element was built, if available. */
|
|
117
117
|
|
|
@@ -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
|
@@ -88,7 +88,7 @@ export class GraphQLDirective {
|
|
|
88
88
|
|
|
89
89
|
/** Reason this element is deprecated, if one was provided. */
|
|
90
90
|
|
|
91
|
-
/**
|
|
91
|
+
/** Custom extension fields reserved for users. */
|
|
92
92
|
|
|
93
93
|
/** AST node from which this schema element was built, if available. */
|
|
94
94
|
|
|
@@ -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,16 +151,33 @@ 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
|
*/
|
|
151
177
|
export declare class GraphQLSchema {
|
|
152
178
|
/** Human-readable description for this schema element, if provided. */
|
|
153
179
|
description: Maybe<string>;
|
|
154
|
-
/**
|
|
180
|
+
/** Custom extension fields reserved for users. */
|
|
155
181
|
extensions: Readonly<GraphQLSchemaExtensions>;
|
|
156
182
|
/** AST node from which this schema element was built, if available. */
|
|
157
183
|
astNode: Maybe<SchemaDefinitionNode>;
|
|
@@ -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,11 +634,11 @@ 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>>;
|
|
616
|
-
/**
|
|
641
|
+
/** Custom extension fields reserved for users. */
|
|
617
642
|
extensions?: Maybe<Readonly<GraphQLSchemaExtensions>>;
|
|
618
643
|
/** AST node from which this schema element was built, if available. */
|
|
619
644
|
astNode?: Maybe<SchemaDefinitionNode>;
|
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,16 +173,33 @@ 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
|
*/
|
|
173
199
|
class GraphQLSchema {
|
|
174
200
|
/** Human-readable description for this schema element, if provided. */
|
|
175
201
|
|
|
176
|
-
/**
|
|
202
|
+
/** Custom extension fields reserved for users. */
|
|
177
203
|
|
|
178
204
|
/** AST node from which this schema element was built, if available. */
|
|
179
205
|
|
|
@@ -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,16 +159,33 @@ 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
|
*/
|
|
159
185
|
export class GraphQLSchema {
|
|
160
186
|
/** Human-readable description for this schema element, if provided. */
|
|
161
187
|
|
|
162
|
-
/**
|
|
188
|
+
/** Custom extension fields reserved for users. */
|
|
163
189
|
|
|
164
190
|
/** AST node from which this schema element was built, if available. */
|
|
165
191
|
|
|
@@ -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