graphql 16.11.0 → 16.13.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/README.md +49 -6
- package/execution/execute.d.ts +14 -1
- package/execution/execute.js +72 -13
- package/execution/execute.mjs +72 -13
- package/execution/subscribe.js +1 -0
- package/execution/subscribe.mjs +2 -0
- package/index.d.ts +11 -0
- package/index.js +24 -0
- package/index.mjs +6 -2
- package/language/ast.d.ts +45 -1
- package/language/ast.js +14 -1
- package/language/ast.mjs +14 -1
- package/language/index.d.ts +14 -1
- package/language/index.js +12 -0
- package/language/index.mjs +8 -1
- package/language/kinds.d.ts +6 -0
- package/language/kinds.js +5 -0
- package/language/kinds.mjs +5 -0
- package/language/lexer.d.ts +52 -1
- package/language/lexer.js +10 -0
- package/language/lexer.mjs +17 -4
- package/language/parser.d.ts +30 -3
- package/language/parser.js +129 -13
- package/language/parser.mjs +123 -11
- package/language/predicates.d.ts +4 -0
- package/language/predicates.js +11 -0
- package/language/predicates.mjs +9 -0
- package/language/printer.js +42 -13
- package/language/printer.mjs +42 -13
- package/language/schemaCoordinateLexer.d.ts +43 -0
- package/language/schemaCoordinateLexer.js +171 -0
- package/language/schemaCoordinateLexer.mjs +122 -0
- package/language/tokenKind.d.ts +1 -0
- package/language/tokenKind.js +1 -0
- package/language/tokenKind.mjs +1 -0
- package/package.json +1 -1
- package/utilities/index.d.ts +5 -0
- package/utilities/index.js +14 -0
- package/utilities/index.mjs +5 -0
- package/utilities/resolveSchemaCoordinate.d.ts +80 -0
- package/utilities/resolveSchemaCoordinate.js +260 -0
- package/utilities/resolveSchemaCoordinate.mjs +243 -0
- package/validation/rules/ValuesOfCorrectTypeRule.js +7 -36
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +7 -35
- package/validation/validate.js +12 -0
- package/validation/validate.mjs +13 -2
- package/version.js +2 -2
- package/version.mjs +2 -2
package/README.md
CHANGED
|
@@ -103,9 +103,9 @@ graphql({ schema, source }).then((result) => {
|
|
|
103
103
|
});
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
**Note**: Please don't forget to set `NODE_ENV=production` if you are running a production server. It will disable some checks that can be useful during development but will significantly
|
|
106
|
+
**Note**: Please don't forget to set `NODE_ENV=production` if you are running a production server. It will disable some checks that can be useful during development but will significantly impact performance.
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
## Want to ride the bleeding edge?
|
|
109
109
|
|
|
110
110
|
The `npm` branch in this repository is automatically maintained to be the last
|
|
111
111
|
commit to `main` to pass all tests, in the same form found on npm. It is
|
|
@@ -127,7 +127,7 @@ Each release of GraphQL.js will be accompanied by an experimental release contai
|
|
|
127
127
|
|
|
128
128
|
Community feedback on this experimental release is much appreciated and can be provided on the [issue created for this purpose](https://github.com/graphql/graphql-js/issues/2848).
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
## Using in a Browser
|
|
131
131
|
|
|
132
132
|
GraphQL.js is a general-purpose library and can be used both in a Node server
|
|
133
133
|
and in the browser. As an example, the [GraphiQL](https://github.com/graphql/graphiql/)
|
|
@@ -139,7 +139,7 @@ the portions of the library you use. This works because GraphQL.js is distribute
|
|
|
139
139
|
with both CommonJS (`require()`) and ESModule (`import`) files. Ensure that any
|
|
140
140
|
custom build configurations look for `.mjs` files!
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
## Contributing
|
|
143
143
|
|
|
144
144
|
We actively welcome pull requests. Learn how to [contribute](./.github/CONTRIBUTING.md).
|
|
145
145
|
|
|
@@ -151,10 +151,53 @@ You can find [detailed information here](https://github.com/graphql/graphql-wg/t
|
|
|
151
151
|
|
|
152
152
|
If your company benefits from GraphQL and you would like to provide essential financial support for the systems and people that power our community, please also consider membership in the [GraphQL Foundation](https://foundation.graphql.org/join).
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
## Changelog
|
|
155
155
|
|
|
156
156
|
Changes are tracked as [GitHub releases](https://github.com/graphql/graphql-js/releases).
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
## License
|
|
159
159
|
|
|
160
160
|
GraphQL.js is [MIT-licensed](./LICENSE).
|
|
161
|
+
|
|
162
|
+
## Version Support
|
|
163
|
+
|
|
164
|
+
GraphQL.JS follows Semantic Versioning (SemVer) for its releases. Our version support policy is as follows:
|
|
165
|
+
|
|
166
|
+
- Latest Major Version: We provide full support, including bug fixes and security updates, for the latest major version of GraphQL.JS.
|
|
167
|
+
- Previous Major Version: We offer feature support for the previous major version for 12 months after the release of the newest major version.
|
|
168
|
+
This means that for 12 months we can backport features for specification changes _if_ they don't cause any breaking changes. We'll continue
|
|
169
|
+
supporting the previous major version with bug and security fixes.
|
|
170
|
+
- Older Versions: Versions older than the previous major release are considered unsupported. While the code remains available,
|
|
171
|
+
we do not actively maintain or provide updates for these versions.
|
|
172
|
+
One exception to this rule is when the older version has been released < 1 year ago, in that case we
|
|
173
|
+
will treat it like the "Previous Major Version".
|
|
174
|
+
|
|
175
|
+
### Long-Term Support (LTS)
|
|
176
|
+
|
|
177
|
+
We do not currently offer a Long-Term Support version of GraphQL.JS. Users are encouraged to upgrade to the latest stable version
|
|
178
|
+
to receive the most up-to-date features, performance improvements, and security updates.
|
|
179
|
+
|
|
180
|
+
### End-of-Life (EOL) Schedule
|
|
181
|
+
|
|
182
|
+
We will announce the EOL date for a major version at least 6 months in advance.
|
|
183
|
+
After a version reaches its EOL, it will no longer receive updates, even for critical security issues.
|
|
184
|
+
|
|
185
|
+
### Upgrade Assistance
|
|
186
|
+
|
|
187
|
+
To assist users in upgrading to newer versions:
|
|
188
|
+
|
|
189
|
+
- We maintain detailed release notes for each version, highlighting new features, breaking changes, and deprecations.
|
|
190
|
+
- [Our documentation](https://www.graphql-js.org/) includes migration guides for moving between major versions.
|
|
191
|
+
- The [community forum (Discord channel #graphql-js)](https://discord.graphql.org) is available for users who need additional assistance with upgrades.
|
|
192
|
+
|
|
193
|
+
### Security Updates
|
|
194
|
+
|
|
195
|
+
We prioritize the security of GraphQL.JS:
|
|
196
|
+
|
|
197
|
+
- Critical security updates will be applied to both the current and previous major version.
|
|
198
|
+
- For versions that have reached EOL, we strongly recommend upgrading to a supported version to receive security updates.
|
|
199
|
+
|
|
200
|
+
### Community Contributions
|
|
201
|
+
|
|
202
|
+
We welcome community contributions for all versions of GraphQL.JS. However, our maintainers will primarily focus on reviewing
|
|
203
|
+
and merging contributions for supported versions.
|
package/execution/execute.d.ts
CHANGED
|
@@ -55,7 +55,18 @@ export interface ExecutionContext {
|
|
|
55
55
|
fieldResolver: GraphQLFieldResolver<any, any>;
|
|
56
56
|
typeResolver: GraphQLTypeResolver<any, any>;
|
|
57
57
|
subscribeFieldResolver: GraphQLFieldResolver<any, any>;
|
|
58
|
-
|
|
58
|
+
collectedErrors: CollectedErrors;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
declare class CollectedErrors {
|
|
64
|
+
private _errorPositions;
|
|
65
|
+
private _errors;
|
|
66
|
+
constructor();
|
|
67
|
+
get errors(): ReadonlyArray<GraphQLError>;
|
|
68
|
+
add(error: GraphQLError, path: Path | undefined): void;
|
|
69
|
+
private _hasNulledPosition;
|
|
59
70
|
}
|
|
60
71
|
/**
|
|
61
72
|
* The result of GraphQL execution.
|
|
@@ -121,6 +132,7 @@ export declare function executeSync(args: ExecutionArgs): ExecutionResult;
|
|
|
121
132
|
* Essential assertions before executing to provide developer feedback for
|
|
122
133
|
* improper use of the GraphQL library.
|
|
123
134
|
*
|
|
135
|
+
* @deprecated will be removed in v17 in favor of assertValidSchema() and TS checks
|
|
124
136
|
* @internal
|
|
125
137
|
*/
|
|
126
138
|
export declare function assertValidExecutionArguments(
|
|
@@ -188,3 +200,4 @@ export declare function getFieldDef(
|
|
|
188
200
|
parentType: GraphQLObjectType,
|
|
189
201
|
fieldNode: FieldNode,
|
|
190
202
|
): Maybe<GraphQLField<unknown, unknown>>;
|
|
203
|
+
export {};
|
package/execution/execute.js
CHANGED
|
@@ -91,6 +91,55 @@ const collectSubfields = (0, _memoize.memoize3)(
|
|
|
91
91
|
* and the fragments defined in the query document
|
|
92
92
|
*/
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
class CollectedErrors {
|
|
98
|
+
constructor() {
|
|
99
|
+
this._errorPositions = new Set();
|
|
100
|
+
this._errors = [];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
get errors() {
|
|
104
|
+
return this._errors;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
add(error, path) {
|
|
108
|
+
// Do not modify errors list if the execution position for this error or
|
|
109
|
+
// any of its ancestors has already been nulled via error propagation.
|
|
110
|
+
// This check should be unnecessary for implementations able to implement
|
|
111
|
+
// actual cancellation.
|
|
112
|
+
if (this._hasNulledPosition(path)) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this._errorPositions.add(path);
|
|
117
|
+
|
|
118
|
+
this._errors.push(error);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
_hasNulledPosition(startPath) {
|
|
122
|
+
let path = startPath;
|
|
123
|
+
|
|
124
|
+
while (path !== undefined) {
|
|
125
|
+
if (this._errorPositions.has(path)) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
path = path.prev;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return this._errorPositions.has(undefined);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The result of GraphQL execution.
|
|
137
|
+
*
|
|
138
|
+
* - `errors` is included when any errors occurred as a non-empty array.
|
|
139
|
+
* - `data` is the result of a successful execution of the query.
|
|
140
|
+
* - `extensions` is reserved for adding non-standard properties.
|
|
141
|
+
*/
|
|
142
|
+
|
|
94
143
|
/**
|
|
95
144
|
* Implements the "Executing requests" section of the GraphQL specification.
|
|
96
145
|
*
|
|
@@ -137,18 +186,18 @@ function execute(args) {
|
|
|
137
186
|
|
|
138
187
|
if ((0, _isPromise.isPromise)(result)) {
|
|
139
188
|
return result.then(
|
|
140
|
-
(data) => buildResponse(data, exeContext.errors),
|
|
189
|
+
(data) => buildResponse(data, exeContext.collectedErrors.errors),
|
|
141
190
|
(error) => {
|
|
142
|
-
exeContext.
|
|
143
|
-
return buildResponse(null, exeContext.errors);
|
|
191
|
+
exeContext.collectedErrors.add(error, undefined);
|
|
192
|
+
return buildResponse(null, exeContext.collectedErrors.errors);
|
|
144
193
|
},
|
|
145
194
|
);
|
|
146
195
|
}
|
|
147
196
|
|
|
148
|
-
return buildResponse(result, exeContext.errors);
|
|
197
|
+
return buildResponse(result, exeContext.collectedErrors.errors);
|
|
149
198
|
} catch (error) {
|
|
150
|
-
exeContext.
|
|
151
|
-
return buildResponse(null, exeContext.errors);
|
|
199
|
+
exeContext.collectedErrors.add(error, undefined);
|
|
200
|
+
return buildResponse(null, exeContext.collectedErrors.errors);
|
|
152
201
|
}
|
|
153
202
|
}
|
|
154
203
|
/**
|
|
@@ -185,6 +234,7 @@ function buildResponse(data, errors) {
|
|
|
185
234
|
* Essential assertions before executing to provide developer feedback for
|
|
186
235
|
* improper use of the GraphQL library.
|
|
187
236
|
*
|
|
237
|
+
* @deprecated will be removed in v17 in favor of assertValidSchema() and TS checks
|
|
188
238
|
* @internal
|
|
189
239
|
*/
|
|
190
240
|
|
|
@@ -319,7 +369,7 @@ function buildExecutionContext(args) {
|
|
|
319
369
|
subscribeFieldResolver !== null && subscribeFieldResolver !== void 0
|
|
320
370
|
? subscribeFieldResolver
|
|
321
371
|
: defaultFieldResolver,
|
|
322
|
-
|
|
372
|
+
collectedErrors: new CollectedErrors(),
|
|
323
373
|
};
|
|
324
374
|
}
|
|
325
375
|
/**
|
|
@@ -524,7 +574,7 @@ function executeField(exeContext, parentType, source, fieldNodes, path) {
|
|
|
524
574
|
fieldNodes,
|
|
525
575
|
(0, _Path.pathToArray)(path),
|
|
526
576
|
);
|
|
527
|
-
return handleFieldError(error, returnType, exeContext);
|
|
577
|
+
return handleFieldError(error, returnType, path, exeContext);
|
|
528
578
|
});
|
|
529
579
|
}
|
|
530
580
|
|
|
@@ -535,7 +585,7 @@ function executeField(exeContext, parentType, source, fieldNodes, path) {
|
|
|
535
585
|
fieldNodes,
|
|
536
586
|
(0, _Path.pathToArray)(path),
|
|
537
587
|
);
|
|
538
|
-
return handleFieldError(error, returnType, exeContext);
|
|
588
|
+
return handleFieldError(error, returnType, path, exeContext);
|
|
539
589
|
}
|
|
540
590
|
}
|
|
541
591
|
/**
|
|
@@ -559,7 +609,7 @@ function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
|
|
|
559
609
|
};
|
|
560
610
|
}
|
|
561
611
|
|
|
562
|
-
function handleFieldError(error, returnType, exeContext) {
|
|
612
|
+
function handleFieldError(error, returnType, path, exeContext) {
|
|
563
613
|
// If the field type is non-nullable, then it is resolved without any
|
|
564
614
|
// protection from errors, however it still properly locates the error.
|
|
565
615
|
if ((0, _definition.isNonNullType)(returnType)) {
|
|
@@ -567,7 +617,7 @@ function handleFieldError(error, returnType, exeContext) {
|
|
|
567
617
|
} // Otherwise, error protection is applied, logging the error and resolving
|
|
568
618
|
// a null value for this field if one is encountered.
|
|
569
619
|
|
|
570
|
-
exeContext.
|
|
620
|
+
exeContext.collectedErrors.add(error, path);
|
|
571
621
|
return null;
|
|
572
622
|
}
|
|
573
623
|
/**
|
|
@@ -732,7 +782,7 @@ function completeListValue(
|
|
|
732
782
|
fieldNodes,
|
|
733
783
|
(0, _Path.pathToArray)(itemPath),
|
|
734
784
|
);
|
|
735
|
-
return handleFieldError(error, itemType, exeContext);
|
|
785
|
+
return handleFieldError(error, itemType, itemPath, exeContext);
|
|
736
786
|
});
|
|
737
787
|
}
|
|
738
788
|
|
|
@@ -743,7 +793,7 @@ function completeListValue(
|
|
|
743
793
|
fieldNodes,
|
|
744
794
|
(0, _Path.pathToArray)(itemPath),
|
|
745
795
|
);
|
|
746
|
-
return handleFieldError(error, itemType, exeContext);
|
|
796
|
+
return handleFieldError(error, itemType, itemPath, exeContext);
|
|
747
797
|
}
|
|
748
798
|
});
|
|
749
799
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
@@ -974,6 +1024,15 @@ const defaultTypeResolver = function (value, contextValue, info, abstractType) {
|
|
|
974
1024
|
if ((0, _isPromise.isPromise)(isTypeOfResult)) {
|
|
975
1025
|
promisedIsTypeOfResults[i] = isTypeOfResult;
|
|
976
1026
|
} else if (isTypeOfResult) {
|
|
1027
|
+
if (promisedIsTypeOfResults.length) {
|
|
1028
|
+
// Explicitly ignore any promise rejections
|
|
1029
|
+
Promise.allSettled(promisedIsTypeOfResults)
|
|
1030
|
+
/* c8 ignore next 3 */
|
|
1031
|
+
.catch(() => {
|
|
1032
|
+
// Do nothing
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
|
|
977
1036
|
return type.name;
|
|
978
1037
|
}
|
|
979
1038
|
}
|
package/execution/execute.mjs
CHANGED
|
@@ -72,6 +72,55 @@ const collectSubfields = memoize3((exeContext, returnType, fieldNodes) =>
|
|
|
72
72
|
* and the fragments defined in the query document
|
|
73
73
|
*/
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
class CollectedErrors {
|
|
79
|
+
constructor() {
|
|
80
|
+
this._errorPositions = new Set();
|
|
81
|
+
this._errors = [];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get errors() {
|
|
85
|
+
return this._errors;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
add(error, path) {
|
|
89
|
+
// Do not modify errors list if the execution position for this error or
|
|
90
|
+
// any of its ancestors has already been nulled via error propagation.
|
|
91
|
+
// This check should be unnecessary for implementations able to implement
|
|
92
|
+
// actual cancellation.
|
|
93
|
+
if (this._hasNulledPosition(path)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this._errorPositions.add(path);
|
|
98
|
+
|
|
99
|
+
this._errors.push(error);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
_hasNulledPosition(startPath) {
|
|
103
|
+
let path = startPath;
|
|
104
|
+
|
|
105
|
+
while (path !== undefined) {
|
|
106
|
+
if (this._errorPositions.has(path)) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
path = path.prev;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return this._errorPositions.has(undefined);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The result of GraphQL execution.
|
|
118
|
+
*
|
|
119
|
+
* - `errors` is included when any errors occurred as a non-empty array.
|
|
120
|
+
* - `data` is the result of a successful execution of the query.
|
|
121
|
+
* - `extensions` is reserved for adding non-standard properties.
|
|
122
|
+
*/
|
|
123
|
+
|
|
75
124
|
/**
|
|
76
125
|
* Implements the "Executing requests" section of the GraphQL specification.
|
|
77
126
|
*
|
|
@@ -118,18 +167,18 @@ export function execute(args) {
|
|
|
118
167
|
|
|
119
168
|
if (isPromise(result)) {
|
|
120
169
|
return result.then(
|
|
121
|
-
(data) => buildResponse(data, exeContext.errors),
|
|
170
|
+
(data) => buildResponse(data, exeContext.collectedErrors.errors),
|
|
122
171
|
(error) => {
|
|
123
|
-
exeContext.
|
|
124
|
-
return buildResponse(null, exeContext.errors);
|
|
172
|
+
exeContext.collectedErrors.add(error, undefined);
|
|
173
|
+
return buildResponse(null, exeContext.collectedErrors.errors);
|
|
125
174
|
},
|
|
126
175
|
);
|
|
127
176
|
}
|
|
128
177
|
|
|
129
|
-
return buildResponse(result, exeContext.errors);
|
|
178
|
+
return buildResponse(result, exeContext.collectedErrors.errors);
|
|
130
179
|
} catch (error) {
|
|
131
|
-
exeContext.
|
|
132
|
-
return buildResponse(null, exeContext.errors);
|
|
180
|
+
exeContext.collectedErrors.add(error, undefined);
|
|
181
|
+
return buildResponse(null, exeContext.collectedErrors.errors);
|
|
133
182
|
}
|
|
134
183
|
}
|
|
135
184
|
/**
|
|
@@ -166,6 +215,7 @@ function buildResponse(data, errors) {
|
|
|
166
215
|
* Essential assertions before executing to provide developer feedback for
|
|
167
216
|
* improper use of the GraphQL library.
|
|
168
217
|
*
|
|
218
|
+
* @deprecated will be removed in v17 in favor of assertValidSchema() and TS checks
|
|
169
219
|
* @internal
|
|
170
220
|
*/
|
|
171
221
|
|
|
@@ -300,7 +350,7 @@ export function buildExecutionContext(args) {
|
|
|
300
350
|
subscribeFieldResolver !== null && subscribeFieldResolver !== void 0
|
|
301
351
|
? subscribeFieldResolver
|
|
302
352
|
: defaultFieldResolver,
|
|
303
|
-
|
|
353
|
+
collectedErrors: new CollectedErrors(),
|
|
304
354
|
};
|
|
305
355
|
}
|
|
306
356
|
/**
|
|
@@ -501,14 +551,14 @@ function executeField(exeContext, parentType, source, fieldNodes, path) {
|
|
|
501
551
|
// to take a second callback for the error case.
|
|
502
552
|
return completed.then(undefined, (rawError) => {
|
|
503
553
|
const error = locatedError(rawError, fieldNodes, pathToArray(path));
|
|
504
|
-
return handleFieldError(error, returnType, exeContext);
|
|
554
|
+
return handleFieldError(error, returnType, path, exeContext);
|
|
505
555
|
});
|
|
506
556
|
}
|
|
507
557
|
|
|
508
558
|
return completed;
|
|
509
559
|
} catch (rawError) {
|
|
510
560
|
const error = locatedError(rawError, fieldNodes, pathToArray(path));
|
|
511
|
-
return handleFieldError(error, returnType, exeContext);
|
|
561
|
+
return handleFieldError(error, returnType, path, exeContext);
|
|
512
562
|
}
|
|
513
563
|
}
|
|
514
564
|
/**
|
|
@@ -538,7 +588,7 @@ export function buildResolveInfo(
|
|
|
538
588
|
};
|
|
539
589
|
}
|
|
540
590
|
|
|
541
|
-
function handleFieldError(error, returnType, exeContext) {
|
|
591
|
+
function handleFieldError(error, returnType, path, exeContext) {
|
|
542
592
|
// If the field type is non-nullable, then it is resolved without any
|
|
543
593
|
// protection from errors, however it still properly locates the error.
|
|
544
594
|
if (isNonNullType(returnType)) {
|
|
@@ -546,7 +596,7 @@ function handleFieldError(error, returnType, exeContext) {
|
|
|
546
596
|
} // Otherwise, error protection is applied, logging the error and resolving
|
|
547
597
|
// a null value for this field if one is encountered.
|
|
548
598
|
|
|
549
|
-
exeContext.
|
|
599
|
+
exeContext.collectedErrors.add(error, path);
|
|
550
600
|
return null;
|
|
551
601
|
}
|
|
552
602
|
/**
|
|
@@ -710,14 +760,14 @@ function completeListValue(
|
|
|
710
760
|
fieldNodes,
|
|
711
761
|
pathToArray(itemPath),
|
|
712
762
|
);
|
|
713
|
-
return handleFieldError(error, itemType, exeContext);
|
|
763
|
+
return handleFieldError(error, itemType, itemPath, exeContext);
|
|
714
764
|
});
|
|
715
765
|
}
|
|
716
766
|
|
|
717
767
|
return completedItem;
|
|
718
768
|
} catch (rawError) {
|
|
719
769
|
const error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
|
|
720
|
-
return handleFieldError(error, itemType, exeContext);
|
|
770
|
+
return handleFieldError(error, itemType, itemPath, exeContext);
|
|
721
771
|
}
|
|
722
772
|
});
|
|
723
773
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
@@ -945,6 +995,15 @@ export const defaultTypeResolver = function (
|
|
|
945
995
|
if (isPromise(isTypeOfResult)) {
|
|
946
996
|
promisedIsTypeOfResults[i] = isTypeOfResult;
|
|
947
997
|
} else if (isTypeOfResult) {
|
|
998
|
+
if (promisedIsTypeOfResults.length) {
|
|
999
|
+
// Explicitly ignore any promise rejections
|
|
1000
|
+
Promise.allSettled(promisedIsTypeOfResults)
|
|
1001
|
+
/* c8 ignore next 3 */
|
|
1002
|
+
.catch(() => {
|
|
1003
|
+
// Do nothing
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
|
|
948
1007
|
return type.name;
|
|
949
1008
|
}
|
|
950
1009
|
}
|
package/execution/subscribe.js
CHANGED
|
@@ -125,6 +125,7 @@ async function createSourceEventStream(...rawArgs) {
|
|
|
125
125
|
const args = toNormalizedArgs(rawArgs);
|
|
126
126
|
const { schema, document, variableValues } = args; // If arguments are missing or incorrectly typed, this is an internal
|
|
127
127
|
// developer mistake which should throw an early error.
|
|
128
|
+
// eslint-disable-next-line import/no-deprecated
|
|
128
129
|
|
|
129
130
|
(0, _execute.assertValidExecutionArguments)(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments,
|
|
130
131
|
// a "Response" with only errors is returned.
|
package/execution/subscribe.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { GraphQLError } from '../error/GraphQLError.mjs';
|
|
|
6
6
|
import { locatedError } from '../error/locatedError.mjs';
|
|
7
7
|
import { collectFields } from './collectFields.mjs';
|
|
8
8
|
import {
|
|
9
|
+
// eslint-disable-next-line import/no-deprecated
|
|
9
10
|
assertValidExecutionArguments,
|
|
10
11
|
buildExecutionContext,
|
|
11
12
|
buildResolveInfo,
|
|
@@ -111,6 +112,7 @@ export async function createSourceEventStream(...rawArgs) {
|
|
|
111
112
|
const args = toNormalizedArgs(rawArgs);
|
|
112
113
|
const { schema, document, variableValues } = args; // If arguments are missing or incorrectly typed, this is an internal
|
|
113
114
|
// developer mistake which should throw an early error.
|
|
115
|
+
// eslint-disable-next-line import/no-deprecated
|
|
114
116
|
|
|
115
117
|
assertValidExecutionArguments(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments,
|
|
116
118
|
// a "Response" with only errors is returned.
|
package/index.d.ts
CHANGED
|
@@ -190,6 +190,7 @@ export {
|
|
|
190
190
|
parseValue,
|
|
191
191
|
parseConstValue,
|
|
192
192
|
parseType,
|
|
193
|
+
parseSchemaCoordinate,
|
|
193
194
|
print,
|
|
194
195
|
visit,
|
|
195
196
|
visitInParallel,
|
|
@@ -208,6 +209,7 @@ export {
|
|
|
208
209
|
isTypeDefinitionNode,
|
|
209
210
|
isTypeSystemExtensionNode,
|
|
210
211
|
isTypeExtensionNode,
|
|
212
|
+
isSchemaCoordinateNode,
|
|
211
213
|
} from './language/index';
|
|
212
214
|
export type {
|
|
213
215
|
ParseOptions,
|
|
@@ -278,6 +280,12 @@ export type {
|
|
|
278
280
|
UnionTypeExtensionNode,
|
|
279
281
|
EnumTypeExtensionNode,
|
|
280
282
|
InputObjectTypeExtensionNode,
|
|
283
|
+
SchemaCoordinateNode,
|
|
284
|
+
TypeCoordinateNode,
|
|
285
|
+
MemberCoordinateNode,
|
|
286
|
+
ArgumentCoordinateNode,
|
|
287
|
+
DirectiveCoordinateNode,
|
|
288
|
+
DirectiveArgumentCoordinateNode,
|
|
281
289
|
} from './language/index';
|
|
282
290
|
export {
|
|
283
291
|
execute,
|
|
@@ -386,6 +394,8 @@ export {
|
|
|
386
394
|
DangerousChangeType,
|
|
387
395
|
findBreakingChanges,
|
|
388
396
|
findDangerousChanges,
|
|
397
|
+
resolveSchemaCoordinate,
|
|
398
|
+
resolveASTSchemaCoordinate,
|
|
389
399
|
} from './utilities/index';
|
|
390
400
|
export type {
|
|
391
401
|
IntrospectionOptions,
|
|
@@ -414,4 +424,5 @@ export type {
|
|
|
414
424
|
BreakingChange,
|
|
415
425
|
DangerousChange,
|
|
416
426
|
TypedQueryDocumentNode,
|
|
427
|
+
ResolvedSchemaElement,
|
|
417
428
|
} from './utilities/index';
|
package/index.js
CHANGED
|
@@ -981,6 +981,12 @@ Object.defineProperty(exports, 'isSchema', {
|
|
|
981
981
|
return _index.isSchema;
|
|
982
982
|
},
|
|
983
983
|
});
|
|
984
|
+
Object.defineProperty(exports, 'isSchemaCoordinateNode', {
|
|
985
|
+
enumerable: true,
|
|
986
|
+
get: function () {
|
|
987
|
+
return _index2.isSchemaCoordinateNode;
|
|
988
|
+
},
|
|
989
|
+
});
|
|
984
990
|
Object.defineProperty(exports, 'isSelectionNode', {
|
|
985
991
|
enumerable: true,
|
|
986
992
|
get: function () {
|
|
@@ -1089,6 +1095,12 @@ Object.defineProperty(exports, 'parseConstValue', {
|
|
|
1089
1095
|
return _index2.parseConstValue;
|
|
1090
1096
|
},
|
|
1091
1097
|
});
|
|
1098
|
+
Object.defineProperty(exports, 'parseSchemaCoordinate', {
|
|
1099
|
+
enumerable: true,
|
|
1100
|
+
get: function () {
|
|
1101
|
+
return _index2.parseSchemaCoordinate;
|
|
1102
|
+
},
|
|
1103
|
+
});
|
|
1092
1104
|
Object.defineProperty(exports, 'parseType', {
|
|
1093
1105
|
enumerable: true,
|
|
1094
1106
|
get: function () {
|
|
@@ -1149,6 +1161,12 @@ Object.defineProperty(exports, 'recommendedRules', {
|
|
|
1149
1161
|
return _index4.recommendedRules;
|
|
1150
1162
|
},
|
|
1151
1163
|
});
|
|
1164
|
+
Object.defineProperty(exports, 'resolveASTSchemaCoordinate', {
|
|
1165
|
+
enumerable: true,
|
|
1166
|
+
get: function () {
|
|
1167
|
+
return _index6.resolveASTSchemaCoordinate;
|
|
1168
|
+
},
|
|
1169
|
+
});
|
|
1152
1170
|
Object.defineProperty(exports, 'resolveObjMapThunk', {
|
|
1153
1171
|
enumerable: true,
|
|
1154
1172
|
get: function () {
|
|
@@ -1161,6 +1179,12 @@ Object.defineProperty(exports, 'resolveReadonlyArrayThunk', {
|
|
|
1161
1179
|
return _index.resolveReadonlyArrayThunk;
|
|
1162
1180
|
},
|
|
1163
1181
|
});
|
|
1182
|
+
Object.defineProperty(exports, 'resolveSchemaCoordinate', {
|
|
1183
|
+
enumerable: true,
|
|
1184
|
+
get: function () {
|
|
1185
|
+
return _index6.resolveSchemaCoordinate;
|
|
1186
|
+
},
|
|
1187
|
+
});
|
|
1164
1188
|
Object.defineProperty(exports, 'responsePathAsArray', {
|
|
1165
1189
|
enumerable: true,
|
|
1166
1190
|
get: function () {
|
package/index.mjs
CHANGED
|
@@ -135,7 +135,8 @@ export {
|
|
|
135
135
|
parse,
|
|
136
136
|
parseValue,
|
|
137
137
|
parseConstValue,
|
|
138
|
-
parseType,
|
|
138
|
+
parseType,
|
|
139
|
+
parseSchemaCoordinate, // Print
|
|
139
140
|
print, // Visit
|
|
140
141
|
visit,
|
|
141
142
|
visitInParallel,
|
|
@@ -154,6 +155,7 @@ export {
|
|
|
154
155
|
isTypeDefinitionNode,
|
|
155
156
|
isTypeSystemExtensionNode,
|
|
156
157
|
isTypeExtensionNode,
|
|
158
|
+
isSchemaCoordinateNode,
|
|
157
159
|
} from './language/index.mjs';
|
|
158
160
|
// Execute GraphQL queries.
|
|
159
161
|
export {
|
|
@@ -254,5 +256,7 @@ export {
|
|
|
254
256
|
BreakingChangeType,
|
|
255
257
|
DangerousChangeType,
|
|
256
258
|
findBreakingChanges,
|
|
257
|
-
findDangerousChanges,
|
|
259
|
+
findDangerousChanges, // Schema Coordinates
|
|
260
|
+
resolveSchemaCoordinate,
|
|
261
|
+
resolveASTSchemaCoordinate,
|
|
258
262
|
} from './utilities/index.mjs';
|
package/language/ast.d.ts
CHANGED
|
@@ -134,7 +134,12 @@ export declare type ASTNode =
|
|
|
134
134
|
| InterfaceTypeExtensionNode
|
|
135
135
|
| UnionTypeExtensionNode
|
|
136
136
|
| EnumTypeExtensionNode
|
|
137
|
-
| InputObjectTypeExtensionNode
|
|
137
|
+
| InputObjectTypeExtensionNode
|
|
138
|
+
| TypeCoordinateNode
|
|
139
|
+
| MemberCoordinateNode
|
|
140
|
+
| ArgumentCoordinateNode
|
|
141
|
+
| DirectiveCoordinateNode
|
|
142
|
+
| DirectiveArgumentCoordinateNode;
|
|
138
143
|
/**
|
|
139
144
|
* Utility type listing all nodes indexed by their kind.
|
|
140
145
|
*/
|
|
@@ -173,6 +178,7 @@ export declare type ExecutableDefinitionNode =
|
|
|
173
178
|
| FragmentDefinitionNode;
|
|
174
179
|
export interface OperationDefinitionNode {
|
|
175
180
|
readonly kind: Kind.OPERATION_DEFINITION;
|
|
181
|
+
readonly description?: StringValueNode;
|
|
176
182
|
readonly loc?: Location;
|
|
177
183
|
readonly operation: OperationTypeNode;
|
|
178
184
|
readonly name?: NameNode;
|
|
@@ -188,6 +194,7 @@ declare enum OperationTypeNode {
|
|
|
188
194
|
export { OperationTypeNode };
|
|
189
195
|
export interface VariableDefinitionNode {
|
|
190
196
|
readonly kind: Kind.VARIABLE_DEFINITION;
|
|
197
|
+
readonly description?: StringValueNode;
|
|
191
198
|
readonly loc?: Location;
|
|
192
199
|
readonly variable: VariableNode;
|
|
193
200
|
readonly type: TypeNode;
|
|
@@ -245,6 +252,7 @@ export interface InlineFragmentNode {
|
|
|
245
252
|
}
|
|
246
253
|
export interface FragmentDefinitionNode {
|
|
247
254
|
readonly kind: Kind.FRAGMENT_DEFINITION;
|
|
255
|
+
readonly description?: StringValueNode;
|
|
248
256
|
readonly loc?: Location;
|
|
249
257
|
readonly name: NameNode;
|
|
250
258
|
/** @deprecated variableDefinitions will be removed in v17.0.0 */
|
|
@@ -536,3 +544,39 @@ export interface InputObjectTypeExtensionNode {
|
|
|
536
544
|
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
|
|
537
545
|
readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
|
|
538
546
|
}
|
|
547
|
+
/** Schema Coordinates */
|
|
548
|
+
export declare type SchemaCoordinateNode =
|
|
549
|
+
| TypeCoordinateNode
|
|
550
|
+
| MemberCoordinateNode
|
|
551
|
+
| ArgumentCoordinateNode
|
|
552
|
+
| DirectiveCoordinateNode
|
|
553
|
+
| DirectiveArgumentCoordinateNode;
|
|
554
|
+
export interface TypeCoordinateNode {
|
|
555
|
+
readonly kind: Kind.TYPE_COORDINATE;
|
|
556
|
+
readonly loc?: Location;
|
|
557
|
+
readonly name: NameNode;
|
|
558
|
+
}
|
|
559
|
+
export interface MemberCoordinateNode {
|
|
560
|
+
readonly kind: Kind.MEMBER_COORDINATE;
|
|
561
|
+
readonly loc?: Location;
|
|
562
|
+
readonly name: NameNode;
|
|
563
|
+
readonly memberName: NameNode;
|
|
564
|
+
}
|
|
565
|
+
export interface ArgumentCoordinateNode {
|
|
566
|
+
readonly kind: Kind.ARGUMENT_COORDINATE;
|
|
567
|
+
readonly loc?: Location;
|
|
568
|
+
readonly name: NameNode;
|
|
569
|
+
readonly fieldName: NameNode;
|
|
570
|
+
readonly argumentName: NameNode;
|
|
571
|
+
}
|
|
572
|
+
export interface DirectiveCoordinateNode {
|
|
573
|
+
readonly kind: Kind.DIRECTIVE_COORDINATE;
|
|
574
|
+
readonly loc?: Location;
|
|
575
|
+
readonly name: NameNode;
|
|
576
|
+
}
|
|
577
|
+
export interface DirectiveArgumentCoordinateNode {
|
|
578
|
+
readonly kind: Kind.DIRECTIVE_ARGUMENT_COORDINATE;
|
|
579
|
+
readonly loc?: Location;
|
|
580
|
+
readonly name: NameNode;
|
|
581
|
+
readonly argumentName: NameNode;
|
|
582
|
+
}
|