graphql 17.0.0-beta.2 → 17.0.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 +3 -5
- package/__dev__/diagnostics.d.mts +1 -0
- package/__dev__/diagnostics.d.ts +1 -0
- package/__dev__/diagnostics.js +3 -0
- package/__dev__/diagnostics.mjs +3 -0
- package/diagnostics.d.mts +307 -0
- package/diagnostics.d.ts +307 -0
- package/diagnostics.js +75 -0
- package/diagnostics.js.map +1 -0
- package/diagnostics.mjs +70 -0
- package/diagnostics.mjs.map +1 -0
- package/error/GraphQLError.d.mts +3 -1
- package/error/GraphQLError.d.ts +3 -1
- package/error/GraphQLError.js +3 -3
- package/error/GraphQLError.js.map +1 -1
- package/error/GraphQLError.mjs +3 -3
- package/error/GraphQLError.mjs.map +1 -1
- package/error/locatedError.d.mts +1 -3
- package/error/locatedError.d.ts +1 -3
- package/error/locatedError.js.map +1 -1
- package/error/locatedError.mjs.map +1 -1
- package/execution/ExecutionArgs.d.mts +6 -0
- package/execution/ExecutionArgs.d.ts +6 -0
- package/execution/ExecutionArgs.js.map +1 -1
- package/execution/ExecutionArgs.mjs.map +1 -1
- package/execution/Executor.d.mts +19 -1
- package/execution/Executor.d.ts +19 -1
- package/execution/Executor.js +49 -4
- package/execution/Executor.js.map +1 -1
- package/execution/Executor.mjs +49 -4
- package/execution/Executor.mjs.map +1 -1
- package/execution/execute.d.mts +65 -44
- package/execution/execute.d.ts +65 -44
- package/execution/execute.js +73 -4
- package/execution/execute.js.map +1 -1
- package/execution/execute.mjs +73 -4
- package/execution/execute.mjs.map +1 -1
- package/execution/values.d.mts +17 -17
- package/execution/values.d.ts +17 -17
- package/execution/values.js.map +1 -1
- package/execution/values.mjs.map +1 -1
- package/index.d.mts +1 -0
- package/index.d.ts +1 -0
- package/index.js.map +1 -1
- package/index.mjs.map +1 -1
- package/language/parser.d.mts +20 -30
- package/language/parser.d.ts +20 -30
- package/language/parser.js +9 -9
- package/language/parser.js.map +1 -1
- package/language/parser.mjs +9 -9
- package/language/parser.mjs.map +1 -1
- package/language/predicates.d.mts +5 -1
- package/language/predicates.d.ts +5 -1
- package/language/predicates.js.map +1 -1
- package/language/predicates.mjs.map +1 -1
- package/language/source.d.mts +4 -5
- package/language/source.d.ts +4 -5
- package/language/source.js.map +1 -1
- package/language/source.mjs.map +1 -1
- package/language/visitor.d.mts +10 -2
- package/language/visitor.d.ts +10 -2
- package/language/visitor.js.map +1 -1
- package/language/visitor.mjs.map +1 -1
- package/package.json +2 -2
- package/type/definition.d.mts +96 -64
- package/type/definition.d.ts +96 -64
- package/type/definition.js.map +1 -1
- package/type/definition.mjs.map +1 -1
- package/type/directives.d.mts +3 -3
- package/type/directives.d.ts +3 -3
- package/type/directives.js.map +1 -1
- package/type/directives.mjs.map +1 -1
- package/type/schema.d.mts +4 -8
- package/type/schema.d.ts +4 -8
- package/type/schema.js.map +1 -1
- package/type/schema.mjs.map +1 -1
- package/type/validate.js +101 -30
- package/type/validate.js.map +1 -1
- package/type/validate.mjs +101 -30
- package/type/validate.mjs.map +1 -1
- package/utilities/TypeInfo.d.mts +1 -1
- package/utilities/TypeInfo.d.ts +1 -1
- package/utilities/TypeInfo.js.map +1 -1
- package/utilities/TypeInfo.mjs.map +1 -1
- package/utilities/buildASTSchema.d.mts +0 -1
- package/utilities/buildASTSchema.d.ts +0 -1
- package/utilities/buildASTSchema.js +0 -1
- package/utilities/buildASTSchema.js.map +1 -1
- package/utilities/buildASTSchema.mjs +0 -1
- package/utilities/buildASTSchema.mjs.map +1 -1
- package/utilities/buildClientSchema.d.mts +5 -1
- package/utilities/buildClientSchema.d.ts +5 -1
- package/utilities/buildClientSchema.js.map +1 -1
- package/utilities/buildClientSchema.mjs.map +1 -1
- package/utilities/coerceInputValue.d.mts +7 -6
- package/utilities/coerceInputValue.d.ts +7 -6
- package/utilities/coerceInputValue.js.map +1 -1
- package/utilities/coerceInputValue.mjs.map +1 -1
- package/utilities/concatAST.d.mts +4 -1
- package/utilities/concatAST.d.ts +4 -1
- package/utilities/concatAST.js.map +1 -1
- package/utilities/concatAST.mjs.map +1 -1
- package/utilities/extendSchema.d.mts +3 -3
- package/utilities/extendSchema.d.ts +3 -3
- package/utilities/extendSchema.js +5 -1
- package/utilities/extendSchema.js.map +1 -1
- package/utilities/extendSchema.mjs +5 -1
- package/utilities/extendSchema.mjs.map +1 -1
- package/utilities/introspectionFromSchema.d.mts +6 -2
- package/utilities/introspectionFromSchema.d.ts +6 -2
- package/utilities/introspectionFromSchema.js.map +1 -1
- package/utilities/introspectionFromSchema.mjs.map +1 -1
- package/utilities/lexicographicSortSchema.d.mts +5 -1
- package/utilities/lexicographicSortSchema.d.ts +5 -1
- package/utilities/lexicographicSortSchema.js.map +1 -1
- package/utilities/lexicographicSortSchema.mjs.map +1 -1
- package/utilities/printSchema.d.mts +5 -1
- package/utilities/printSchema.d.ts +5 -1
- package/utilities/printSchema.js.map +1 -1
- package/utilities/printSchema.mjs.map +1 -1
- package/utilities/replaceVariables.d.mts +4 -8
- package/utilities/replaceVariables.d.ts +4 -8
- package/utilities/replaceVariables.js.map +1 -1
- package/utilities/replaceVariables.mjs.map +1 -1
- package/utilities/stripIgnoredCharacters.d.mts +2 -2
- package/utilities/stripIgnoredCharacters.d.ts +2 -2
- package/utilities/stripIgnoredCharacters.js.map +1 -1
- package/utilities/stripIgnoredCharacters.mjs.map +1 -1
- package/utilities/typeComparators.d.mts +1 -5
- package/utilities/typeComparators.d.ts +1 -5
- package/utilities/typeComparators.js.map +1 -1
- package/utilities/typeComparators.mjs.map +1 -1
- package/utilities/validateInputValue.d.mts +10 -8
- package/utilities/validateInputValue.d.ts +10 -8
- package/utilities/validateInputValue.js.map +1 -1
- package/utilities/validateInputValue.mjs.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.mts +4 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.ts +4 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.js +70 -17
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.js.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs +70 -17
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.mts +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.ts +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js +90 -21
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs +91 -22
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs.map +1 -1
- package/validation/rules/ExecutableDefinitionsRule.d.mts +6 -2
- package/validation/rules/ExecutableDefinitionsRule.d.ts +6 -2
- package/validation/rules/ExecutableDefinitionsRule.js.map +1 -1
- package/validation/rules/ExecutableDefinitionsRule.mjs.map +1 -1
- package/validation/rules/FieldsOnCorrectTypeRule.d.mts +3 -1
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +3 -1
- package/validation/rules/FieldsOnCorrectTypeRule.js.map +1 -1
- package/validation/rules/FieldsOnCorrectTypeRule.mjs.map +1 -1
- package/validation/rules/FragmentsOnCompositeTypesRule.d.mts +6 -2
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +6 -2
- package/validation/rules/FragmentsOnCompositeTypesRule.js.map +1 -1
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs.map +1 -1
- package/validation/rules/KnownArgumentNamesRule.d.mts +3 -1
- package/validation/rules/KnownArgumentNamesRule.d.ts +3 -1
- package/validation/rules/KnownArgumentNamesRule.js.map +1 -1
- package/validation/rules/KnownArgumentNamesRule.mjs.map +1 -1
- package/validation/rules/KnownDirectivesRule.js +2 -1
- package/validation/rules/KnownDirectivesRule.js.map +1 -1
- package/validation/rules/KnownDirectivesRule.mjs +2 -1
- package/validation/rules/KnownDirectivesRule.mjs.map +1 -1
- package/validation/rules/KnownFragmentNamesRule.d.mts +3 -1
- package/validation/rules/KnownFragmentNamesRule.d.ts +3 -1
- package/validation/rules/KnownFragmentNamesRule.js.map +1 -1
- package/validation/rules/KnownFragmentNamesRule.mjs.map +1 -1
- package/validation/rules/LoneAnonymousOperationRule.d.mts +6 -2
- package/validation/rules/LoneAnonymousOperationRule.d.ts +6 -2
- package/validation/rules/LoneAnonymousOperationRule.js.map +1 -1
- package/validation/rules/LoneAnonymousOperationRule.mjs.map +1 -1
- package/validation/rules/MaxIntrospectionDepthRule.d.mts +6 -2
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +6 -2
- package/validation/rules/MaxIntrospectionDepthRule.js.map +1 -1
- package/validation/rules/MaxIntrospectionDepthRule.mjs.map +1 -1
- package/validation/rules/NoUndefinedVariablesRule.d.mts +3 -1
- package/validation/rules/NoUndefinedVariablesRule.d.ts +3 -1
- package/validation/rules/NoUndefinedVariablesRule.js.map +1 -1
- package/validation/rules/NoUndefinedVariablesRule.mjs.map +1 -1
- package/validation/rules/NoUnusedFragmentsRule.d.mts +3 -1
- package/validation/rules/NoUnusedFragmentsRule.d.ts +3 -1
- package/validation/rules/NoUnusedFragmentsRule.js.map +1 -1
- package/validation/rules/NoUnusedFragmentsRule.mjs.map +1 -1
- package/validation/rules/NoUnusedVariablesRule.d.mts +3 -1
- package/validation/rules/NoUnusedVariablesRule.d.ts +3 -1
- package/validation/rules/NoUnusedVariablesRule.js.map +1 -1
- package/validation/rules/NoUnusedVariablesRule.mjs.map +1 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.mts +6 -2
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +6 -2
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js.map +1 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs.map +1 -1
- package/validation/rules/PossibleFragmentSpreadsRule.d.mts +6 -2
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +6 -2
- package/validation/rules/PossibleFragmentSpreadsRule.js.map +1 -1
- package/validation/rules/PossibleFragmentSpreadsRule.mjs.map +1 -1
- package/validation/rules/ProvidedRequiredArgumentsRule.d.mts +6 -2
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +6 -2
- package/validation/rules/ProvidedRequiredArgumentsRule.js.map +1 -1
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs.map +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.d.mts +6 -2
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +6 -2
- package/validation/rules/SingleFieldSubscriptionsRule.js.map +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.mjs.map +1 -1
- package/validation/rules/UniqueArgumentNamesRule.d.mts +3 -1
- package/validation/rules/UniqueArgumentNamesRule.d.ts +3 -1
- package/validation/rules/UniqueArgumentNamesRule.js.map +1 -1
- package/validation/rules/UniqueArgumentNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueDirectivesPerLocationRule.d.mts +6 -2
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +6 -2
- package/validation/rules/UniqueDirectivesPerLocationRule.js.map +1 -1
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs.map +1 -1
- package/validation/rules/UniqueFragmentNamesRule.d.mts +3 -1
- package/validation/rules/UniqueFragmentNamesRule.d.ts +3 -1
- package/validation/rules/UniqueFragmentNamesRule.js.map +1 -1
- package/validation/rules/UniqueFragmentNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.d.mts +6 -2
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +6 -2
- package/validation/rules/UniqueInputFieldNamesRule.js.map +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueOperationNamesRule.d.mts +3 -1
- package/validation/rules/UniqueOperationNamesRule.d.ts +3 -1
- package/validation/rules/UniqueOperationNamesRule.js.map +1 -1
- package/validation/rules/UniqueOperationNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueVariableNamesRule.d.mts +3 -1
- package/validation/rules/UniqueVariableNamesRule.d.ts +3 -1
- package/validation/rules/UniqueVariableNamesRule.js.map +1 -1
- package/validation/rules/UniqueVariableNamesRule.mjs.map +1 -1
- package/validation/rules/ValuesOfCorrectTypeRule.d.mts +3 -1
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +3 -1
- package/validation/rules/ValuesOfCorrectTypeRule.js.map +1 -1
- package/validation/rules/ValuesOfCorrectTypeRule.mjs.map +1 -1
- package/validation/rules/VariablesAreInputTypesRule.d.mts +6 -2
- package/validation/rules/VariablesAreInputTypesRule.d.ts +6 -2
- package/validation/rules/VariablesAreInputTypesRule.js.map +1 -1
- package/validation/rules/VariablesAreInputTypesRule.mjs.map +1 -1
- package/validation/rules/VariablesInAllowedPositionRule.d.mts +6 -2
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +6 -2
- package/validation/rules/VariablesInAllowedPositionRule.js.map +1 -1
- package/validation/rules/VariablesInAllowedPositionRule.mjs.map +1 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.d.mts +3 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +3 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.js.map +1 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs.map +1 -1
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.mts +6 -2
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +6 -2
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.map +1 -1
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs.map +1 -1
- package/validation/validate.d.mts +3 -6
- package/validation/validate.d.ts +3 -6
- package/validation/validate.js +6 -0
- package/validation/validate.js.map +1 -1
- package/validation/validate.mjs +6 -0
- package/validation/validate.mjs.map +1 -1
- package/version.js +2 -2
- package/version.js.map +1 -1
- package/version.mjs +2 -2
- package/version.mjs.map +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
[](https://graphql.org/conf/2025/?utm_source=github&utm_medium=graphql_js&utm_campaign=readme)
|
|
2
|
-
|
|
3
1
|
# GraphQL.js
|
|
4
2
|
|
|
5
3
|
The JavaScript reference implementation for GraphQL, a query language for APIs created by Facebook.
|
|
6
4
|
|
|
7
5
|
[](https://badge.fury.io/js/graphql)
|
|
8
|
-
[](https://github.com/graphql/graphql-js/actions/workflows/push.yml?query=branch%3A17.x.x)
|
|
9
7
|
|
|
10
8
|
See more complete documentation at https://graphql.org/ and
|
|
11
9
|
https://graphql.org/graphql-js/.
|
|
@@ -111,7 +109,7 @@ graphql({ schema, source }).then((result) => {
|
|
|
111
109
|
## Want to ride the bleeding edge?
|
|
112
110
|
|
|
113
111
|
The `npm` branch in this repository is automatically maintained to be the last
|
|
114
|
-
commit to `
|
|
112
|
+
commit to `17.x.x` to pass all tests, in the same form found on npm. It is
|
|
115
113
|
recommended to use builds deployed to npm for many reasons, but if you want to use
|
|
116
114
|
the latest not-yet-released version of graphql-js, you can do so by depending
|
|
117
115
|
directly on this branch:
|
|
@@ -139,7 +137,7 @@ in files with the `.js` extension and the ESModule build within `.mjs` files.
|
|
|
139
137
|
|
|
140
138
|
We actively welcome pull requests. Learn how to [contribute](./.github/CONTRIBUTING.md).
|
|
141
139
|
|
|
142
|
-
This repository is managed by EasyCLA. Project participants must sign the free
|
|
140
|
+
This repository is managed by EasyCLA. Project participants must sign the free [GraphQL Specification Membership agreement](https://preview-spec-membership.graphql.org) before making a contribution. You only need to do this one time, and it can be signed by [individual contributors](http://individual-spec-membership.graphql.org/) or their [employers](http://corporate-spec-membership.graphql.org/).
|
|
143
141
|
|
|
144
142
|
To initiate the signature process please open a PR against this repo. The EasyCLA bot will block the merge if we still need a membership agreement from you.
|
|
145
143
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../diagnostics.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../diagnostics.js';
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TracingChannel integration.
|
|
3
|
+
*
|
|
4
|
+
* GraphQL.js publishes lifecycle events on a set of named tracing channels
|
|
5
|
+
* that application performance monitoring (APM) tools can subscribe to in
|
|
6
|
+
* order to observe parse, validate, execute, subscribe, and resolver behavior,
|
|
7
|
+
* plus selected executor internals. At module load time GraphQL.js resolves
|
|
8
|
+
* `node:diagnostics_channel` itself so APMs do not need to interact with the
|
|
9
|
+
* GraphQL API to enable tracing. On runtimes that do not expose
|
|
10
|
+
* `node:diagnostics_channel` (e.g., browsers) the load silently no-ops and
|
|
11
|
+
* emission sites short-circuit.
|
|
12
|
+
*
|
|
13
|
+
* Within the tracing context types, `error` means the traced JavaScript call
|
|
14
|
+
* threw or rejected; it does not mean every `GraphQLError` returned by
|
|
15
|
+
* GraphQL.js. Some channels complete normally and publish GraphQL errors on
|
|
16
|
+
* `result`. Resolver errors can appear both as `message.error` on
|
|
17
|
+
* `graphql:resolve` and as formatted errors in an enclosing execution or
|
|
18
|
+
* subscription result. `graphql:parse`, `graphql:validate`, and
|
|
19
|
+
* `graphql:execute:variableCoercion` are sync-only channels.
|
|
20
|
+
* @category Diagnostics
|
|
21
|
+
*/
|
|
22
|
+
import type { Maybe } from "./jsutils/Maybe.mjs";
|
|
23
|
+
import type { ObjMap } from "./jsutils/ObjMap.mjs";
|
|
24
|
+
import type { GraphQLError } from "./error/GraphQLError.mjs";
|
|
25
|
+
import type { DocumentNode, OperationDefinitionNode, OperationTypeNode } from "./language/ast.mjs";
|
|
26
|
+
import type { Source } from "./language/source.mjs";
|
|
27
|
+
import type { GraphQLSchema } from "./type/schema.mjs";
|
|
28
|
+
import type { ExecutionResult } from "./execution/Executor.mjs";
|
|
29
|
+
import type { ExperimentalIncrementalExecutionResults } from "./execution/incremental/IncrementalExecutor.mjs";
|
|
30
|
+
import type { VariableValues } from "./execution/values.mjs";
|
|
31
|
+
/**
|
|
32
|
+
* Structural subset of `DiagnosticsChannel` sufficient for publishing and
|
|
33
|
+
* subscriber gating. The `node:diagnostics_channel` `Channel` satisfies this.
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export interface MinimalChannel<TMessage = unknown> {
|
|
38
|
+
readonly hasSubscribers?: boolean;
|
|
39
|
+
publish: (message: TMessage) => void;
|
|
40
|
+
runStores: <T, ContextType extends object>(context: ContextType, fn: (this: ContextType, ...args: Array<unknown>) => T, thisArg?: unknown, ...args: Array<unknown>) => T;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Structural subset of the Node.js `TracingChannel` API. The
|
|
44
|
+
* `node:diagnostics_channel` `TracingChannel` satisfies this by duck typing,
|
|
45
|
+
* so GraphQL.js does not need a dependency on `@types/node` or on the runtime
|
|
46
|
+
* itself.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export interface MinimalTracingChannel<TContext = unknown> {
|
|
51
|
+
readonly hasSubscribers: boolean | undefined;
|
|
52
|
+
readonly start: MinimalChannel<TContext>;
|
|
53
|
+
readonly end: MinimalChannel<TContext>;
|
|
54
|
+
readonly asyncStart: MinimalChannel<TContext>;
|
|
55
|
+
readonly asyncEnd: MinimalChannel<TContext>;
|
|
56
|
+
readonly error: MinimalChannel<TContext>;
|
|
57
|
+
traceSync: <T>(fn: (...args: Array<unknown>) => T, context: TContext extends object ? TContext : object, thisArg?: unknown, ...args: Array<unknown>) => T;
|
|
58
|
+
}
|
|
59
|
+
/** Context published on the sync-only `graphql:parse` channel. */
|
|
60
|
+
export interface GraphQLParseContext {
|
|
61
|
+
/** Source text or source object passed to the parser. */
|
|
62
|
+
source: string | Source;
|
|
63
|
+
/** Error thrown while parsing, when parsing fails. */
|
|
64
|
+
error?: unknown;
|
|
65
|
+
/** Parsed document, when parsing succeeds. */
|
|
66
|
+
result?: DocumentNode;
|
|
67
|
+
}
|
|
68
|
+
/** Context published on the sync-only `graphql:validate` channel. */
|
|
69
|
+
export interface GraphQLValidateContext {
|
|
70
|
+
/** Schema used for validation. */
|
|
71
|
+
schema: GraphQLSchema;
|
|
72
|
+
/** Parsed document being validated. */
|
|
73
|
+
document: DocumentNode;
|
|
74
|
+
/** Error thrown while validating, when validation fails abruptly. */
|
|
75
|
+
error?: unknown;
|
|
76
|
+
/** Validation errors returned by validation. */
|
|
77
|
+
result?: ReadonlyArray<GraphQLError>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Context published on `graphql:execute`.
|
|
81
|
+
*
|
|
82
|
+
* Returned results may contain GraphQL errors collected during execution.
|
|
83
|
+
*/
|
|
84
|
+
export interface GraphQLExecuteContext {
|
|
85
|
+
/** Schema used for execution. */
|
|
86
|
+
schema: GraphQLSchema;
|
|
87
|
+
/** Parsed document being executed. */
|
|
88
|
+
document: DocumentNode;
|
|
89
|
+
/** Raw variable values provided by the caller before coercion. */
|
|
90
|
+
rawVariableValues: Maybe<{
|
|
91
|
+
readonly [variable: string]: unknown;
|
|
92
|
+
}>;
|
|
93
|
+
/** Selected operation name, if one is available. */
|
|
94
|
+
operationName: string | undefined;
|
|
95
|
+
/** Selected operation type, if one is available. */
|
|
96
|
+
operationType: OperationTypeNode | undefined;
|
|
97
|
+
/** Error thrown or rejected while executing, when execution fails abruptly. */
|
|
98
|
+
error?: unknown;
|
|
99
|
+
/** Execution result returned by execution, including GraphQL errors. */
|
|
100
|
+
result?: ExecutionResult | ExperimentalIncrementalExecutionResults;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Context published on `graphql:execute:rootSelectionSet`.
|
|
104
|
+
*
|
|
105
|
+
* Returned results may contain GraphQL errors collected during execution.
|
|
106
|
+
*/
|
|
107
|
+
export interface GraphQLExecuteRootSelectionSetContext {
|
|
108
|
+
/** Schema used for execution. */
|
|
109
|
+
schema: GraphQLSchema;
|
|
110
|
+
/** Parsed document being executed. */
|
|
111
|
+
document: DocumentNode;
|
|
112
|
+
/** Operation definition selected for execution. */
|
|
113
|
+
operation: OperationDefinitionNode;
|
|
114
|
+
/** Raw variable values provided by the caller before coercion. */
|
|
115
|
+
rawVariableValues: Maybe<{
|
|
116
|
+
readonly [variable: string]: unknown;
|
|
117
|
+
}>;
|
|
118
|
+
/** Selected operation name, if one is available. */
|
|
119
|
+
operationName: string | undefined;
|
|
120
|
+
/** Selected operation type. */
|
|
121
|
+
operationType: OperationTypeNode;
|
|
122
|
+
/** Error thrown or rejected while executing the root selection set. */
|
|
123
|
+
error?: unknown;
|
|
124
|
+
/**
|
|
125
|
+
* Execution result returned from the root selection set, including GraphQL
|
|
126
|
+
* errors.
|
|
127
|
+
*/
|
|
128
|
+
result?: ExecutionResult | ExperimentalIncrementalExecutionResults;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Context published on `graphql:execute:variableCoercion`.
|
|
132
|
+
*
|
|
133
|
+
* Coercion runs synchronously while execution arguments are validated, so only
|
|
134
|
+
* the `start`/`end` (and, on an abrupt throw, `error`) lifecycle fires.
|
|
135
|
+
* Ordinary variable coercion failures are returned on `result.errors`; when
|
|
136
|
+
* execution is invoked through APIs such as `execute()` or `subscribe()`, they
|
|
137
|
+
* surface as GraphQL result errors rather than as the tracing `error`
|
|
138
|
+
* lifecycle event.
|
|
139
|
+
*/
|
|
140
|
+
export interface GraphQLExecuteVariableCoercionContext {
|
|
141
|
+
/** Schema used for variable coercion. */
|
|
142
|
+
schema: GraphQLSchema;
|
|
143
|
+
/** Parsed document being executed. */
|
|
144
|
+
document: DocumentNode;
|
|
145
|
+
/** Operation definition whose variables are being coerced. */
|
|
146
|
+
operation: OperationDefinitionNode;
|
|
147
|
+
/** Raw variable values provided by the caller before coercion. */
|
|
148
|
+
rawVariableValues: Maybe<{
|
|
149
|
+
readonly [variable: string]: unknown;
|
|
150
|
+
}>;
|
|
151
|
+
/** Selected operation name, if one is available. */
|
|
152
|
+
operationName: string | undefined;
|
|
153
|
+
/** Selected operation type. */
|
|
154
|
+
operationType: OperationTypeNode;
|
|
155
|
+
/** Error thrown while coercing variables, when coercion fails abruptly. */
|
|
156
|
+
error?: unknown;
|
|
157
|
+
/** Coerced variable values or coercion errors returned by coercion. */
|
|
158
|
+
result?: {
|
|
159
|
+
variableValues: VariableValues;
|
|
160
|
+
} | {
|
|
161
|
+
errors: ReadonlyArray<GraphQLError>;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Context published on `graphql:subscribe`.
|
|
166
|
+
*
|
|
167
|
+
* Subscription source resolver errors and invalid source stream results are
|
|
168
|
+
* returned on `result` as ExecutionResult errors; they do not publish the
|
|
169
|
+
* `error` lifecycle event unless subscription setup fails abruptly before
|
|
170
|
+
* GraphQL can form a result.
|
|
171
|
+
*/
|
|
172
|
+
export interface GraphQLSubscribeContext {
|
|
173
|
+
/** Schema used for subscription execution. */
|
|
174
|
+
schema: GraphQLSchema;
|
|
175
|
+
/** Parsed subscription document. */
|
|
176
|
+
document: DocumentNode;
|
|
177
|
+
/** Raw variable values provided by the caller before coercion. */
|
|
178
|
+
rawVariableValues: Maybe<{
|
|
179
|
+
readonly [variable: string]: unknown;
|
|
180
|
+
}>;
|
|
181
|
+
/** Selected operation name, if one is available. */
|
|
182
|
+
operationName: string | undefined;
|
|
183
|
+
/** Selected operation type, if one is available. */
|
|
184
|
+
operationType: OperationTypeNode | undefined;
|
|
185
|
+
/** Error thrown or rejected while subscribing, when setup fails abruptly. */
|
|
186
|
+
error?: unknown;
|
|
187
|
+
/**
|
|
188
|
+
* Subscription response stream, or an ExecutionResult containing GraphQL
|
|
189
|
+
* errors.
|
|
190
|
+
*/
|
|
191
|
+
result?: AsyncGenerator<ExecutionResult, void, void> | ExecutionResult;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Context published on `graphql:resolve`.
|
|
195
|
+
*
|
|
196
|
+
* Resolver throws and rejections publish the `error` lifecycle event here.
|
|
197
|
+
* The same failure may also be formatted into the enclosing execution or
|
|
198
|
+
* subscription result.
|
|
199
|
+
*/
|
|
200
|
+
export interface GraphQLResolveContext {
|
|
201
|
+
/** Field name being resolved. */
|
|
202
|
+
fieldName: string;
|
|
203
|
+
/** Response alias for the field being resolved. */
|
|
204
|
+
alias: string;
|
|
205
|
+
/** Parent type name for the field being resolved. */
|
|
206
|
+
parentType: string;
|
|
207
|
+
/** Return type string for the field being resolved. */
|
|
208
|
+
fieldType: string;
|
|
209
|
+
/** Argument values passed to the resolver. */
|
|
210
|
+
args: ObjMap<unknown>;
|
|
211
|
+
/** Whether the field is using the default resolver. */
|
|
212
|
+
isDefaultResolver: boolean;
|
|
213
|
+
/** Response path for the field being resolved. */
|
|
214
|
+
fieldPath: string;
|
|
215
|
+
/** Error thrown or rejected by the resolver, when resolution fails. */
|
|
216
|
+
error?: unknown;
|
|
217
|
+
/** Value returned by the resolver, when resolution succeeds. */
|
|
218
|
+
result?: unknown;
|
|
219
|
+
}
|
|
220
|
+
/** Mapping from tracing channel name to the context type published on it. */
|
|
221
|
+
export interface GraphQLChannelContextByName {
|
|
222
|
+
/** Context published on `graphql:parse`. */
|
|
223
|
+
'graphql:parse': GraphQLParseContext;
|
|
224
|
+
/** Context published on `graphql:validate`. */
|
|
225
|
+
'graphql:validate': GraphQLValidateContext;
|
|
226
|
+
/** Context published on `graphql:execute`. */
|
|
227
|
+
'graphql:execute': GraphQLExecuteContext;
|
|
228
|
+
/** Context published on `graphql:execute:variableCoercion`. */
|
|
229
|
+
'graphql:execute:variableCoercion': GraphQLExecuteVariableCoercionContext;
|
|
230
|
+
/** Context published on `graphql:execute:rootSelectionSet`. */
|
|
231
|
+
'graphql:execute:rootSelectionSet': GraphQLExecuteRootSelectionSetContext;
|
|
232
|
+
/** Context published on `graphql:subscribe`. */
|
|
233
|
+
'graphql:subscribe': GraphQLSubscribeContext;
|
|
234
|
+
/** Context published on `graphql:resolve`. */
|
|
235
|
+
'graphql:resolve': GraphQLResolveContext;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The collection of tracing channels GraphQL.js emits on. Application
|
|
239
|
+
* performance monitoring (APM) tools subscribe to these by name on their own
|
|
240
|
+
* `node:diagnostics_channel` import; both paths land on the same channel
|
|
241
|
+
* instance because `tracingChannel(name)` is cached by name.
|
|
242
|
+
*/
|
|
243
|
+
export interface GraphQLChannels {
|
|
244
|
+
/** Tracing channel for `graphql:execute`. */
|
|
245
|
+
execute: MinimalTracingChannel<GraphQLExecuteContext>;
|
|
246
|
+
/** Tracing channel for `graphql:execute:variableCoercion`. */
|
|
247
|
+
executeVariableCoercion: MinimalTracingChannel<GraphQLExecuteVariableCoercionContext>;
|
|
248
|
+
/** Tracing channel for `graphql:execute:rootSelectionSet`. */
|
|
249
|
+
executeRootSelectionSet: MinimalTracingChannel<GraphQLExecuteRootSelectionSetContext>;
|
|
250
|
+
/** Tracing channel for `graphql:parse`. */
|
|
251
|
+
parse: MinimalTracingChannel<GraphQLParseContext>;
|
|
252
|
+
/** Tracing channel for `graphql:validate`. */
|
|
253
|
+
validate: MinimalTracingChannel<GraphQLValidateContext>;
|
|
254
|
+
/** Tracing channel for `graphql:resolve`. */
|
|
255
|
+
resolve: MinimalTracingChannel<GraphQLResolveContext>;
|
|
256
|
+
/** Tracing channel for `graphql:subscribe`. */
|
|
257
|
+
subscribe: MinimalTracingChannel<GraphQLSubscribeContext>;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Per-channel handles, resolved once at module load. `undefined` when
|
|
261
|
+
* `node:diagnostics_channel` isn't available. Emission sites read these
|
|
262
|
+
* directly to keep the no-subscriber fast path to a single property access
|
|
263
|
+
* plus a `hasSubscribers` check (no function calls, no closures).
|
|
264
|
+
*
|
|
265
|
+
* @internal
|
|
266
|
+
*/
|
|
267
|
+
export declare const parseChannel: MinimalTracingChannel<GraphQLParseContext> | undefined;
|
|
268
|
+
/** @internal */
|
|
269
|
+
export declare const validateChannel: MinimalTracingChannel<GraphQLValidateContext> | undefined;
|
|
270
|
+
/** @internal */
|
|
271
|
+
export declare const executeChannel: MinimalTracingChannel<GraphQLExecuteContext> | undefined;
|
|
272
|
+
/** @internal */
|
|
273
|
+
export declare const executeVariableCoercionChannel: MinimalTracingChannel<GraphQLExecuteVariableCoercionContext> | undefined;
|
|
274
|
+
/** @internal */
|
|
275
|
+
export declare const executeRootSelectionSetChannel: MinimalTracingChannel<GraphQLExecuteRootSelectionSetContext> | undefined;
|
|
276
|
+
/** @internal */
|
|
277
|
+
export declare const subscribeChannel: MinimalTracingChannel<GraphQLSubscribeContext> | undefined;
|
|
278
|
+
/** @internal */
|
|
279
|
+
export declare const resolveChannel: MinimalTracingChannel<GraphQLResolveContext> | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* Whether emission sites should publish to `channel`. Trusts the
|
|
282
|
+
* `TracingChannel.hasSubscribers` aggregate when the runtime exposes it; if
|
|
283
|
+
* the getter is missing (e.g. Bun's `node:diagnostics_channel`, where
|
|
284
|
+
* `tracingChannel.hasSubscribers` is `undefined`), falls back to checking
|
|
285
|
+
* each of the five underlying lifecycle channels so a subscriber attached
|
|
286
|
+
* via `tracingChannel.subscribe(handlers)` is still observed.
|
|
287
|
+
*
|
|
288
|
+
* @internal
|
|
289
|
+
*/
|
|
290
|
+
export declare function shouldTrace<TContext = unknown>(channel: MinimalTracingChannel<TContext> | undefined): channel is MinimalTracingChannel<TContext>;
|
|
291
|
+
interface TraceLifecycleContext {
|
|
292
|
+
error?: unknown;
|
|
293
|
+
result?: unknown;
|
|
294
|
+
}
|
|
295
|
+
type TraceStartContext<TContext extends TraceLifecycleContext> = Omit<TContext, 'error' | 'result'>;
|
|
296
|
+
/**
|
|
297
|
+
* Publish a traced call that may complete synchronously or with a promise.
|
|
298
|
+
* Caller has already verified that a subscriber is attached. On normal
|
|
299
|
+
* completion, `result` is attached before the terminal `end` or `asyncEnd`
|
|
300
|
+
* event. When the traced call throws or rejects, `error` is attached, the
|
|
301
|
+
* `error` sub-channel fires, and the terminal `end` or `asyncEnd` event is
|
|
302
|
+
* published before the original failure is propagated.
|
|
303
|
+
*
|
|
304
|
+
* @internal
|
|
305
|
+
*/
|
|
306
|
+
export declare function traceMixed<TResult, TContext extends TraceLifecycleContext>(channel: MinimalTracingChannel<TContext>, contextInput: TraceStartContext<TContext>, fn: () => TResult): TResult;
|
|
307
|
+
export {};
|
package/diagnostics.d.ts
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TracingChannel integration.
|
|
3
|
+
*
|
|
4
|
+
* GraphQL.js publishes lifecycle events on a set of named tracing channels
|
|
5
|
+
* that application performance monitoring (APM) tools can subscribe to in
|
|
6
|
+
* order to observe parse, validate, execute, subscribe, and resolver behavior,
|
|
7
|
+
* plus selected executor internals. At module load time GraphQL.js resolves
|
|
8
|
+
* `node:diagnostics_channel` itself so APMs do not need to interact with the
|
|
9
|
+
* GraphQL API to enable tracing. On runtimes that do not expose
|
|
10
|
+
* `node:diagnostics_channel` (e.g., browsers) the load silently no-ops and
|
|
11
|
+
* emission sites short-circuit.
|
|
12
|
+
*
|
|
13
|
+
* Within the tracing context types, `error` means the traced JavaScript call
|
|
14
|
+
* threw or rejected; it does not mean every `GraphQLError` returned by
|
|
15
|
+
* GraphQL.js. Some channels complete normally and publish GraphQL errors on
|
|
16
|
+
* `result`. Resolver errors can appear both as `message.error` on
|
|
17
|
+
* `graphql:resolve` and as formatted errors in an enclosing execution or
|
|
18
|
+
* subscription result. `graphql:parse`, `graphql:validate`, and
|
|
19
|
+
* `graphql:execute:variableCoercion` are sync-only channels.
|
|
20
|
+
* @category Diagnostics
|
|
21
|
+
*/
|
|
22
|
+
import type { Maybe } from "./jsutils/Maybe.js";
|
|
23
|
+
import type { ObjMap } from "./jsutils/ObjMap.js";
|
|
24
|
+
import type { GraphQLError } from "./error/GraphQLError.js";
|
|
25
|
+
import type { DocumentNode, OperationDefinitionNode, OperationTypeNode } from "./language/ast.js";
|
|
26
|
+
import type { Source } from "./language/source.js";
|
|
27
|
+
import type { GraphQLSchema } from "./type/schema.js";
|
|
28
|
+
import type { ExecutionResult } from "./execution/Executor.js";
|
|
29
|
+
import type { ExperimentalIncrementalExecutionResults } from "./execution/incremental/IncrementalExecutor.js";
|
|
30
|
+
import type { VariableValues } from "./execution/values.js";
|
|
31
|
+
/**
|
|
32
|
+
* Structural subset of `DiagnosticsChannel` sufficient for publishing and
|
|
33
|
+
* subscriber gating. The `node:diagnostics_channel` `Channel` satisfies this.
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export interface MinimalChannel<TMessage = unknown> {
|
|
38
|
+
readonly hasSubscribers?: boolean;
|
|
39
|
+
publish: (message: TMessage) => void;
|
|
40
|
+
runStores: <T, ContextType extends object>(context: ContextType, fn: (this: ContextType, ...args: Array<unknown>) => T, thisArg?: unknown, ...args: Array<unknown>) => T;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Structural subset of the Node.js `TracingChannel` API. The
|
|
44
|
+
* `node:diagnostics_channel` `TracingChannel` satisfies this by duck typing,
|
|
45
|
+
* so GraphQL.js does not need a dependency on `@types/node` or on the runtime
|
|
46
|
+
* itself.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export interface MinimalTracingChannel<TContext = unknown> {
|
|
51
|
+
readonly hasSubscribers: boolean | undefined;
|
|
52
|
+
readonly start: MinimalChannel<TContext>;
|
|
53
|
+
readonly end: MinimalChannel<TContext>;
|
|
54
|
+
readonly asyncStart: MinimalChannel<TContext>;
|
|
55
|
+
readonly asyncEnd: MinimalChannel<TContext>;
|
|
56
|
+
readonly error: MinimalChannel<TContext>;
|
|
57
|
+
traceSync: <T>(fn: (...args: Array<unknown>) => T, context: TContext extends object ? TContext : object, thisArg?: unknown, ...args: Array<unknown>) => T;
|
|
58
|
+
}
|
|
59
|
+
/** Context published on the sync-only `graphql:parse` channel. */
|
|
60
|
+
export interface GraphQLParseContext {
|
|
61
|
+
/** Source text or source object passed to the parser. */
|
|
62
|
+
source: string | Source;
|
|
63
|
+
/** Error thrown while parsing, when parsing fails. */
|
|
64
|
+
error?: unknown;
|
|
65
|
+
/** Parsed document, when parsing succeeds. */
|
|
66
|
+
result?: DocumentNode;
|
|
67
|
+
}
|
|
68
|
+
/** Context published on the sync-only `graphql:validate` channel. */
|
|
69
|
+
export interface GraphQLValidateContext {
|
|
70
|
+
/** Schema used for validation. */
|
|
71
|
+
schema: GraphQLSchema;
|
|
72
|
+
/** Parsed document being validated. */
|
|
73
|
+
document: DocumentNode;
|
|
74
|
+
/** Error thrown while validating, when validation fails abruptly. */
|
|
75
|
+
error?: unknown;
|
|
76
|
+
/** Validation errors returned by validation. */
|
|
77
|
+
result?: ReadonlyArray<GraphQLError>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Context published on `graphql:execute`.
|
|
81
|
+
*
|
|
82
|
+
* Returned results may contain GraphQL errors collected during execution.
|
|
83
|
+
*/
|
|
84
|
+
export interface GraphQLExecuteContext {
|
|
85
|
+
/** Schema used for execution. */
|
|
86
|
+
schema: GraphQLSchema;
|
|
87
|
+
/** Parsed document being executed. */
|
|
88
|
+
document: DocumentNode;
|
|
89
|
+
/** Raw variable values provided by the caller before coercion. */
|
|
90
|
+
rawVariableValues: Maybe<{
|
|
91
|
+
readonly [variable: string]: unknown;
|
|
92
|
+
}>;
|
|
93
|
+
/** Selected operation name, if one is available. */
|
|
94
|
+
operationName: string | undefined;
|
|
95
|
+
/** Selected operation type, if one is available. */
|
|
96
|
+
operationType: OperationTypeNode | undefined;
|
|
97
|
+
/** Error thrown or rejected while executing, when execution fails abruptly. */
|
|
98
|
+
error?: unknown;
|
|
99
|
+
/** Execution result returned by execution, including GraphQL errors. */
|
|
100
|
+
result?: ExecutionResult | ExperimentalIncrementalExecutionResults;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Context published on `graphql:execute:rootSelectionSet`.
|
|
104
|
+
*
|
|
105
|
+
* Returned results may contain GraphQL errors collected during execution.
|
|
106
|
+
*/
|
|
107
|
+
export interface GraphQLExecuteRootSelectionSetContext {
|
|
108
|
+
/** Schema used for execution. */
|
|
109
|
+
schema: GraphQLSchema;
|
|
110
|
+
/** Parsed document being executed. */
|
|
111
|
+
document: DocumentNode;
|
|
112
|
+
/** Operation definition selected for execution. */
|
|
113
|
+
operation: OperationDefinitionNode;
|
|
114
|
+
/** Raw variable values provided by the caller before coercion. */
|
|
115
|
+
rawVariableValues: Maybe<{
|
|
116
|
+
readonly [variable: string]: unknown;
|
|
117
|
+
}>;
|
|
118
|
+
/** Selected operation name, if one is available. */
|
|
119
|
+
operationName: string | undefined;
|
|
120
|
+
/** Selected operation type. */
|
|
121
|
+
operationType: OperationTypeNode;
|
|
122
|
+
/** Error thrown or rejected while executing the root selection set. */
|
|
123
|
+
error?: unknown;
|
|
124
|
+
/**
|
|
125
|
+
* Execution result returned from the root selection set, including GraphQL
|
|
126
|
+
* errors.
|
|
127
|
+
*/
|
|
128
|
+
result?: ExecutionResult | ExperimentalIncrementalExecutionResults;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Context published on `graphql:execute:variableCoercion`.
|
|
132
|
+
*
|
|
133
|
+
* Coercion runs synchronously while execution arguments are validated, so only
|
|
134
|
+
* the `start`/`end` (and, on an abrupt throw, `error`) lifecycle fires.
|
|
135
|
+
* Ordinary variable coercion failures are returned on `result.errors`; when
|
|
136
|
+
* execution is invoked through APIs such as `execute()` or `subscribe()`, they
|
|
137
|
+
* surface as GraphQL result errors rather than as the tracing `error`
|
|
138
|
+
* lifecycle event.
|
|
139
|
+
*/
|
|
140
|
+
export interface GraphQLExecuteVariableCoercionContext {
|
|
141
|
+
/** Schema used for variable coercion. */
|
|
142
|
+
schema: GraphQLSchema;
|
|
143
|
+
/** Parsed document being executed. */
|
|
144
|
+
document: DocumentNode;
|
|
145
|
+
/** Operation definition whose variables are being coerced. */
|
|
146
|
+
operation: OperationDefinitionNode;
|
|
147
|
+
/** Raw variable values provided by the caller before coercion. */
|
|
148
|
+
rawVariableValues: Maybe<{
|
|
149
|
+
readonly [variable: string]: unknown;
|
|
150
|
+
}>;
|
|
151
|
+
/** Selected operation name, if one is available. */
|
|
152
|
+
operationName: string | undefined;
|
|
153
|
+
/** Selected operation type. */
|
|
154
|
+
operationType: OperationTypeNode;
|
|
155
|
+
/** Error thrown while coercing variables, when coercion fails abruptly. */
|
|
156
|
+
error?: unknown;
|
|
157
|
+
/** Coerced variable values or coercion errors returned by coercion. */
|
|
158
|
+
result?: {
|
|
159
|
+
variableValues: VariableValues;
|
|
160
|
+
} | {
|
|
161
|
+
errors: ReadonlyArray<GraphQLError>;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Context published on `graphql:subscribe`.
|
|
166
|
+
*
|
|
167
|
+
* Subscription source resolver errors and invalid source stream results are
|
|
168
|
+
* returned on `result` as ExecutionResult errors; they do not publish the
|
|
169
|
+
* `error` lifecycle event unless subscription setup fails abruptly before
|
|
170
|
+
* GraphQL can form a result.
|
|
171
|
+
*/
|
|
172
|
+
export interface GraphQLSubscribeContext {
|
|
173
|
+
/** Schema used for subscription execution. */
|
|
174
|
+
schema: GraphQLSchema;
|
|
175
|
+
/** Parsed subscription document. */
|
|
176
|
+
document: DocumentNode;
|
|
177
|
+
/** Raw variable values provided by the caller before coercion. */
|
|
178
|
+
rawVariableValues: Maybe<{
|
|
179
|
+
readonly [variable: string]: unknown;
|
|
180
|
+
}>;
|
|
181
|
+
/** Selected operation name, if one is available. */
|
|
182
|
+
operationName: string | undefined;
|
|
183
|
+
/** Selected operation type, if one is available. */
|
|
184
|
+
operationType: OperationTypeNode | undefined;
|
|
185
|
+
/** Error thrown or rejected while subscribing, when setup fails abruptly. */
|
|
186
|
+
error?: unknown;
|
|
187
|
+
/**
|
|
188
|
+
* Subscription response stream, or an ExecutionResult containing GraphQL
|
|
189
|
+
* errors.
|
|
190
|
+
*/
|
|
191
|
+
result?: AsyncGenerator<ExecutionResult, void, void> | ExecutionResult;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Context published on `graphql:resolve`.
|
|
195
|
+
*
|
|
196
|
+
* Resolver throws and rejections publish the `error` lifecycle event here.
|
|
197
|
+
* The same failure may also be formatted into the enclosing execution or
|
|
198
|
+
* subscription result.
|
|
199
|
+
*/
|
|
200
|
+
export interface GraphQLResolveContext {
|
|
201
|
+
/** Field name being resolved. */
|
|
202
|
+
fieldName: string;
|
|
203
|
+
/** Response alias for the field being resolved. */
|
|
204
|
+
alias: string;
|
|
205
|
+
/** Parent type name for the field being resolved. */
|
|
206
|
+
parentType: string;
|
|
207
|
+
/** Return type string for the field being resolved. */
|
|
208
|
+
fieldType: string;
|
|
209
|
+
/** Argument values passed to the resolver. */
|
|
210
|
+
args: ObjMap<unknown>;
|
|
211
|
+
/** Whether the field is using the default resolver. */
|
|
212
|
+
isDefaultResolver: boolean;
|
|
213
|
+
/** Response path for the field being resolved. */
|
|
214
|
+
fieldPath: string;
|
|
215
|
+
/** Error thrown or rejected by the resolver, when resolution fails. */
|
|
216
|
+
error?: unknown;
|
|
217
|
+
/** Value returned by the resolver, when resolution succeeds. */
|
|
218
|
+
result?: unknown;
|
|
219
|
+
}
|
|
220
|
+
/** Mapping from tracing channel name to the context type published on it. */
|
|
221
|
+
export interface GraphQLChannelContextByName {
|
|
222
|
+
/** Context published on `graphql:parse`. */
|
|
223
|
+
'graphql:parse': GraphQLParseContext;
|
|
224
|
+
/** Context published on `graphql:validate`. */
|
|
225
|
+
'graphql:validate': GraphQLValidateContext;
|
|
226
|
+
/** Context published on `graphql:execute`. */
|
|
227
|
+
'graphql:execute': GraphQLExecuteContext;
|
|
228
|
+
/** Context published on `graphql:execute:variableCoercion`. */
|
|
229
|
+
'graphql:execute:variableCoercion': GraphQLExecuteVariableCoercionContext;
|
|
230
|
+
/** Context published on `graphql:execute:rootSelectionSet`. */
|
|
231
|
+
'graphql:execute:rootSelectionSet': GraphQLExecuteRootSelectionSetContext;
|
|
232
|
+
/** Context published on `graphql:subscribe`. */
|
|
233
|
+
'graphql:subscribe': GraphQLSubscribeContext;
|
|
234
|
+
/** Context published on `graphql:resolve`. */
|
|
235
|
+
'graphql:resolve': GraphQLResolveContext;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The collection of tracing channels GraphQL.js emits on. Application
|
|
239
|
+
* performance monitoring (APM) tools subscribe to these by name on their own
|
|
240
|
+
* `node:diagnostics_channel` import; both paths land on the same channel
|
|
241
|
+
* instance because `tracingChannel(name)` is cached by name.
|
|
242
|
+
*/
|
|
243
|
+
export interface GraphQLChannels {
|
|
244
|
+
/** Tracing channel for `graphql:execute`. */
|
|
245
|
+
execute: MinimalTracingChannel<GraphQLExecuteContext>;
|
|
246
|
+
/** Tracing channel for `graphql:execute:variableCoercion`. */
|
|
247
|
+
executeVariableCoercion: MinimalTracingChannel<GraphQLExecuteVariableCoercionContext>;
|
|
248
|
+
/** Tracing channel for `graphql:execute:rootSelectionSet`. */
|
|
249
|
+
executeRootSelectionSet: MinimalTracingChannel<GraphQLExecuteRootSelectionSetContext>;
|
|
250
|
+
/** Tracing channel for `graphql:parse`. */
|
|
251
|
+
parse: MinimalTracingChannel<GraphQLParseContext>;
|
|
252
|
+
/** Tracing channel for `graphql:validate`. */
|
|
253
|
+
validate: MinimalTracingChannel<GraphQLValidateContext>;
|
|
254
|
+
/** Tracing channel for `graphql:resolve`. */
|
|
255
|
+
resolve: MinimalTracingChannel<GraphQLResolveContext>;
|
|
256
|
+
/** Tracing channel for `graphql:subscribe`. */
|
|
257
|
+
subscribe: MinimalTracingChannel<GraphQLSubscribeContext>;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Per-channel handles, resolved once at module load. `undefined` when
|
|
261
|
+
* `node:diagnostics_channel` isn't available. Emission sites read these
|
|
262
|
+
* directly to keep the no-subscriber fast path to a single property access
|
|
263
|
+
* plus a `hasSubscribers` check (no function calls, no closures).
|
|
264
|
+
*
|
|
265
|
+
* @internal
|
|
266
|
+
*/
|
|
267
|
+
export declare const parseChannel: MinimalTracingChannel<GraphQLParseContext> | undefined;
|
|
268
|
+
/** @internal */
|
|
269
|
+
export declare const validateChannel: MinimalTracingChannel<GraphQLValidateContext> | undefined;
|
|
270
|
+
/** @internal */
|
|
271
|
+
export declare const executeChannel: MinimalTracingChannel<GraphQLExecuteContext> | undefined;
|
|
272
|
+
/** @internal */
|
|
273
|
+
export declare const executeVariableCoercionChannel: MinimalTracingChannel<GraphQLExecuteVariableCoercionContext> | undefined;
|
|
274
|
+
/** @internal */
|
|
275
|
+
export declare const executeRootSelectionSetChannel: MinimalTracingChannel<GraphQLExecuteRootSelectionSetContext> | undefined;
|
|
276
|
+
/** @internal */
|
|
277
|
+
export declare const subscribeChannel: MinimalTracingChannel<GraphQLSubscribeContext> | undefined;
|
|
278
|
+
/** @internal */
|
|
279
|
+
export declare const resolveChannel: MinimalTracingChannel<GraphQLResolveContext> | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* Whether emission sites should publish to `channel`. Trusts the
|
|
282
|
+
* `TracingChannel.hasSubscribers` aggregate when the runtime exposes it; if
|
|
283
|
+
* the getter is missing (e.g. Bun's `node:diagnostics_channel`, where
|
|
284
|
+
* `tracingChannel.hasSubscribers` is `undefined`), falls back to checking
|
|
285
|
+
* each of the five underlying lifecycle channels so a subscriber attached
|
|
286
|
+
* via `tracingChannel.subscribe(handlers)` is still observed.
|
|
287
|
+
*
|
|
288
|
+
* @internal
|
|
289
|
+
*/
|
|
290
|
+
export declare function shouldTrace<TContext = unknown>(channel: MinimalTracingChannel<TContext> | undefined): channel is MinimalTracingChannel<TContext>;
|
|
291
|
+
interface TraceLifecycleContext {
|
|
292
|
+
error?: unknown;
|
|
293
|
+
result?: unknown;
|
|
294
|
+
}
|
|
295
|
+
type TraceStartContext<TContext extends TraceLifecycleContext> = Omit<TContext, 'error' | 'result'>;
|
|
296
|
+
/**
|
|
297
|
+
* Publish a traced call that may complete synchronously or with a promise.
|
|
298
|
+
* Caller has already verified that a subscriber is attached. On normal
|
|
299
|
+
* completion, `result` is attached before the terminal `end` or `asyncEnd`
|
|
300
|
+
* event. When the traced call throws or rejects, `error` is attached, the
|
|
301
|
+
* `error` sub-channel fires, and the terminal `end` or `asyncEnd` event is
|
|
302
|
+
* published before the original failure is propagated.
|
|
303
|
+
*
|
|
304
|
+
* @internal
|
|
305
|
+
*/
|
|
306
|
+
export declare function traceMixed<TResult, TContext extends TraceLifecycleContext>(channel: MinimalTracingChannel<TContext>, contextInput: TraceStartContext<TContext>, fn: () => TResult): TResult;
|
|
307
|
+
export {};
|