graphql 16.14.2 → 16.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/error/GraphQLError.d.ts +5 -1
- package/error/GraphQLError.js +12 -7
- package/error/GraphQLError.mjs +13 -6
- package/error/locatedError.d.ts +6 -4
- package/error/locatedError.js +6 -4
- package/error/locatedError.mjs +6 -4
- package/execution/collectFields.d.ts +1 -0
- package/execution/collectFields.js +9 -0
- package/execution/collectFields.mjs +9 -0
- package/execution/execute.d.ts +9 -10
- package/execution/execute.js +44 -29
- package/execution/execute.mjs +44 -29
- package/execution/mapAsyncIterator.js +12 -11
- package/execution/mapAsyncIterator.mjs +12 -11
- package/execution/subscribe.d.ts +5 -2
- package/execution/subscribe.js +5 -2
- package/execution/subscribe.mjs +5 -2
- package/execution/values.d.ts +43 -21
- package/execution/values.js +52 -24
- package/execution/values.mjs +51 -23
- package/graphql.d.ts +8 -14
- package/graphql.js +16 -15
- package/graphql.mjs +11 -15
- package/jsutils/SetMap.d.ts +14 -0
- package/jsutils/SetMap.js +48 -0
- package/jsutils/SetMap.mjs +39 -0
- package/jsutils/isIterableObject.d.ts +2 -0
- package/jsutils/isIterableObject.js +2 -0
- package/jsutils/isIterableObject.mjs +2 -0
- package/jsutils/keyMap.d.ts +2 -0
- package/jsutils/keyMap.js +2 -0
- package/jsutils/keyMap.mjs +2 -0
- package/jsutils/keyValMap.d.ts +3 -3
- package/jsutils/keyValMap.js +3 -3
- package/jsutils/keyValMap.mjs +3 -3
- package/language/ast.d.ts +2 -6
- package/language/ast.js +2 -6
- package/language/ast.mjs +2 -6
- package/language/lexer.d.ts +6 -0
- package/language/lexer.js +22 -0
- package/language/lexer.mjs +22 -0
- package/language/location.d.ts +8 -3
- package/language/location.js +57 -17
- package/language/location.mjs +56 -16
- package/language/parser.d.ts +27 -13
- package/language/parser.js +31 -9
- package/language/parser.mjs +31 -9
- package/language/predicates.d.ts +10 -3
- package/language/predicates.js +10 -3
- package/language/predicates.mjs +10 -3
- package/language/printLocation.d.ts +2 -6
- package/language/printLocation.js +2 -6
- package/language/printLocation.mjs +2 -6
- package/language/printer.d.ts +22 -3
- package/language/printer.js +394 -308
- package/language/printer.mjs +394 -308
- package/language/reducer.d.ts +32 -0
- package/language/reducer.js +95 -0
- package/language/reducer.mjs +86 -0
- package/language/source.d.ts +4 -5
- package/language/source.js +4 -5
- package/language/source.mjs +4 -5
- package/language/visitor.d.ts +16 -10
- package/language/visitor.js +15 -7
- package/language/visitor.mjs +15 -7
- package/package.json +1 -4
- package/type/definition.d.ts +170 -102
- package/type/definition.js +169 -96
- package/type/definition.mjs +168 -95
- package/type/directives.d.ts +12 -6
- package/type/directives.js +12 -6
- package/type/directives.mjs +12 -6
- package/type/scalars.js +8 -11
- package/type/scalars.mjs +1 -1
- package/type/schema.d.ts +36 -11
- package/type/schema.js +35 -10
- package/type/schema.mjs +35 -10
- package/type/validate.d.ts +1 -3
- package/type/validate.js +1 -3
- package/type/validate.mjs +1 -3
- package/utilities/TypeInfo.d.ts +15 -11
- package/utilities/TypeInfo.js +15 -11
- package/utilities/TypeInfo.mjs +15 -11
- package/utilities/assertValidName.d.ts +1 -1
- package/utilities/assertValidName.js +1 -1
- package/utilities/assertValidName.mjs +1 -1
- package/utilities/astFromValue.d.ts +3 -1
- package/utilities/astFromValue.js +3 -1
- package/utilities/astFromValue.mjs +3 -1
- package/utilities/buildASTSchema.d.ts +8 -8
- package/utilities/buildASTSchema.js +9 -20
- package/utilities/buildASTSchema.mjs +9 -20
- package/utilities/buildClientSchema.d.ts +6 -2
- package/utilities/buildClientSchema.js +6 -2
- package/utilities/buildClientSchema.mjs +6 -2
- package/utilities/coerceInputValue.d.ts +9 -3
- package/utilities/coerceInputValue.js +60 -13
- package/utilities/coerceInputValue.mjs +58 -13
- package/utilities/concatAST.d.ts +4 -1
- package/utilities/concatAST.js +4 -1
- package/utilities/concatAST.mjs +4 -1
- package/utilities/extendSchema.d.ts +7 -4
- package/utilities/extendSchema.js +7 -4
- package/utilities/extendSchema.mjs +7 -4
- package/utilities/findBreakingChanges.d.ts +2 -2
- package/utilities/findBreakingChanges.js +2 -2
- package/utilities/findBreakingChanges.mjs +2 -2
- package/utilities/getIntrospectionQuery.d.ts +9 -9
- package/utilities/getIntrospectionQuery.js +8 -8
- package/utilities/getIntrospectionQuery.mjs +8 -8
- package/utilities/getOperationAST.d.ts +2 -2
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.d.ts +3 -1
- package/utilities/getOperationRootType.js +3 -1
- package/utilities/getOperationRootType.mjs +3 -1
- package/utilities/introspectionFromSchema.d.ts +12 -4
- package/utilities/introspectionFromSchema.js +12 -4
- package/utilities/introspectionFromSchema.mjs +12 -4
- package/utilities/lexicographicSortSchema.d.ts +17 -13
- package/utilities/lexicographicSortSchema.js +17 -13
- package/utilities/lexicographicSortSchema.mjs +17 -13
- package/utilities/printSchema.d.ts +7 -4
- package/utilities/printSchema.js +7 -4
- package/utilities/printSchema.mjs +7 -4
- package/utilities/resolveSchemaCoordinate.d.ts +9 -8
- package/utilities/resolveSchemaCoordinate.js +9 -8
- package/utilities/resolveSchemaCoordinate.mjs +9 -8
- package/utilities/separateOperations.d.ts +2 -2
- package/utilities/separateOperations.js +2 -2
- package/utilities/separateOperations.mjs +2 -2
- package/utilities/stripIgnoredCharacters.d.ts +19 -5
- package/utilities/stripIgnoredCharacters.js +19 -5
- package/utilities/stripIgnoredCharacters.mjs +19 -5
- package/utilities/typeComparators.d.ts +1 -5
- package/utilities/typeComparators.js +1 -5
- package/utilities/typeComparators.mjs +1 -5
- package/utilities/valueFromAST.js +4 -4
- package/utilities/valueFromAST.mjs +4 -4
- package/utilities/valueFromASTUntyped.d.ts +1 -3
- package/utilities/valueFromASTUntyped.js +1 -3
- package/utilities/valueFromASTUntyped.mjs +1 -3
- package/validation/ValidationContext.d.ts +22 -3
- package/validation/ValidationContext.js +84 -27
- package/validation/ValidationContext.mjs +82 -27
- package/validation/rules/ExecutableDefinitionsRule.d.ts +6 -4
- package/validation/rules/ExecutableDefinitionsRule.js +6 -4
- package/validation/rules/ExecutableDefinitionsRule.mjs +6 -4
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +4 -4
- package/validation/rules/FieldsOnCorrectTypeRule.js +10 -6
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +12 -6
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +6 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.js +6 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +6 -4
- package/validation/rules/KnownArgumentNamesRule.d.ts +4 -4
- package/validation/rules/KnownArgumentNamesRule.js +26 -17
- package/validation/rules/KnownArgumentNamesRule.mjs +21 -11
- package/validation/rules/KnownDirectivesRule.d.ts +1 -3
- package/validation/rules/KnownDirectivesRule.js +1 -3
- package/validation/rules/KnownDirectivesRule.mjs +1 -3
- package/validation/rules/KnownFragmentNamesRule.d.ts +4 -4
- package/validation/rules/KnownFragmentNamesRule.js +4 -4
- package/validation/rules/KnownFragmentNamesRule.mjs +4 -4
- package/validation/rules/KnownTypeNamesRule.d.ts +1 -3
- package/validation/rules/KnownTypeNamesRule.js +7 -7
- package/validation/rules/KnownTypeNamesRule.mjs +7 -7
- package/validation/rules/LoneAnonymousOperationRule.d.ts +6 -4
- package/validation/rules/LoneAnonymousOperationRule.js +6 -4
- package/validation/rules/LoneAnonymousOperationRule.mjs +6 -4
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +6 -4
- package/validation/rules/MaxIntrospectionDepthRule.js +44 -19
- package/validation/rules/MaxIntrospectionDepthRule.mjs +44 -19
- package/validation/rules/NoFragmentCyclesRule.d.ts +1 -3
- package/validation/rules/NoFragmentCyclesRule.js +1 -3
- package/validation/rules/NoFragmentCyclesRule.mjs +1 -3
- package/validation/rules/NoUndefinedVariablesRule.d.ts +4 -4
- package/validation/rules/NoUndefinedVariablesRule.js +4 -4
- package/validation/rules/NoUndefinedVariablesRule.mjs +4 -4
- package/validation/rules/NoUnusedFragmentsRule.d.ts +4 -4
- package/validation/rules/NoUnusedFragmentsRule.js +10 -14
- package/validation/rules/NoUnusedFragmentsRule.mjs +10 -14
- package/validation/rules/NoUnusedVariablesRule.d.ts +4 -4
- package/validation/rules/NoUnusedVariablesRule.js +4 -4
- package/validation/rules/NoUnusedVariablesRule.mjs +4 -4
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +8 -6
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +552 -354
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +545 -352
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +6 -4
- package/validation/rules/PossibleFragmentSpreadsRule.js +6 -4
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.js +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +6 -4
- package/validation/rules/ScalarLeafsRule.d.ts +1 -3
- package/validation/rules/ScalarLeafsRule.js +1 -3
- package/validation/rules/ScalarLeafsRule.mjs +1 -3
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +6 -4
- package/validation/rules/SingleFieldSubscriptionsRule.js +50 -9
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +50 -9
- package/validation/rules/UniqueArgumentNamesRule.d.ts +4 -4
- package/validation/rules/UniqueArgumentNamesRule.js +4 -4
- package/validation/rules/UniqueArgumentNamesRule.mjs +4 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +6 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.js +6 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +6 -4
- package/validation/rules/UniqueFragmentNamesRule.d.ts +4 -4
- package/validation/rules/UniqueFragmentNamesRule.js +4 -4
- package/validation/rules/UniqueFragmentNamesRule.mjs +4 -4
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +6 -4
- package/validation/rules/UniqueInputFieldNamesRule.js +6 -4
- package/validation/rules/UniqueInputFieldNamesRule.mjs +6 -4
- package/validation/rules/UniqueOperationNamesRule.d.ts +4 -4
- package/validation/rules/UniqueOperationNamesRule.js +4 -4
- package/validation/rules/UniqueOperationNamesRule.mjs +4 -4
- package/validation/rules/UniqueVariableNamesRule.d.ts +4 -4
- package/validation/rules/UniqueVariableNamesRule.js +4 -4
- package/validation/rules/UniqueVariableNamesRule.mjs +4 -4
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +4 -4
- package/validation/rules/ValuesOfCorrectTypeRule.js +29 -23
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +24 -14
- package/validation/rules/VariablesAreInputTypesRule.d.ts +6 -4
- package/validation/rules/VariablesAreInputTypesRule.js +6 -4
- package/validation/rules/VariablesAreInputTypesRule.mjs +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.js +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.mjs +6 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +4 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.js +4 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +4 -4
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +7 -5
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +7 -5
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +7 -5
- package/validation/validate.d.ts +2 -0
- package/validation/validate.js +14 -2
- package/validation/validate.mjs +13 -2
- package/validation/validationAbortedError.d.ts +3 -0
- package/validation/validationAbortedError.js +14 -0
- package/validation/validationAbortedError.mjs +4 -0
- package/version.js +3 -3
- package/version.mjs +3 -3
package/execution/subscribe.js
CHANGED
|
@@ -121,7 +121,10 @@ var _values = require('./values.js');
|
|
|
121
121
|
* 'subscription Greeting($locale: String) { greeting(locale: $locale) }',
|
|
122
122
|
* ),
|
|
123
123
|
* rootValue: {
|
|
124
|
-
* greeting: (
|
|
124
|
+
* greeting: (
|
|
125
|
+
* args: { locale?: string },
|
|
126
|
+
* contextValue: { defaultLocale: string },
|
|
127
|
+
* ) => {
|
|
125
128
|
* const locale = args.locale ?? contextValue.defaultLocale;
|
|
126
129
|
* return locale === 'fr' ? frenchGreetings() : defaultGreetings();
|
|
127
130
|
* },
|
|
@@ -161,7 +164,7 @@ var _values = require('./values.js');
|
|
|
161
164
|
*
|
|
162
165
|
* assert('errors' in result);
|
|
163
166
|
*
|
|
164
|
-
* result.errors[0].message; // => 'Schema is not configured to execute subscription operation.'
|
|
167
|
+
* result.errors?.[0].message; // => 'Schema is not configured to execute subscription operation.'
|
|
165
168
|
* ```
|
|
166
169
|
*/
|
|
167
170
|
async function subscribe(args) {
|
package/execution/subscribe.mjs
CHANGED
|
@@ -109,7 +109,10 @@ import { getArgumentValues } from './values.mjs';
|
|
|
109
109
|
* 'subscription Greeting($locale: String) { greeting(locale: $locale) }',
|
|
110
110
|
* ),
|
|
111
111
|
* rootValue: {
|
|
112
|
-
* greeting: (
|
|
112
|
+
* greeting: (
|
|
113
|
+
* args: { locale?: string },
|
|
114
|
+
* contextValue: { defaultLocale: string },
|
|
115
|
+
* ) => {
|
|
113
116
|
* const locale = args.locale ?? contextValue.defaultLocale;
|
|
114
117
|
* return locale === 'fr' ? frenchGreetings() : defaultGreetings();
|
|
115
118
|
* },
|
|
@@ -149,7 +152,7 @@ import { getArgumentValues } from './values.mjs';
|
|
|
149
152
|
*
|
|
150
153
|
* assert('errors' in result);
|
|
151
154
|
*
|
|
152
|
-
* result.errors[0].message; // => 'Schema is not configured to execute subscription operation.'
|
|
155
|
+
* result.errors?.[0].message; // => 'Schema is not configured to execute subscription operation.'
|
|
153
156
|
* ```
|
|
154
157
|
*/
|
|
155
158
|
|
package/execution/values.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ declare type CoercedVariableValues =
|
|
|
26
26
|
* @internal
|
|
27
27
|
*/
|
|
28
28
|
export interface GetVariableValuesOptions {
|
|
29
|
+
/** Omit suggestions from input coercion errors. */
|
|
30
|
+
hideSuggestions?: boolean;
|
|
29
31
|
/**
|
|
30
32
|
* Maximum number of variable coercion errors before coercion stops.
|
|
31
33
|
* @internal
|
|
@@ -47,8 +49,9 @@ export interface GetVariableValuesOptions {
|
|
|
47
49
|
* @returns Coerced variable values, or request errors.
|
|
48
50
|
* @example
|
|
49
51
|
* ```ts
|
|
52
|
+
* import assert from 'node:assert/strict';
|
|
50
53
|
* // Coerce provided variables and apply operation defaults.
|
|
51
|
-
* import { parse } from 'graphql/language';
|
|
54
|
+
* import { parse, Kind } from 'graphql/language';
|
|
52
55
|
* import { buildSchema } from 'graphql/utilities';
|
|
53
56
|
* import { getVariableValues } from 'graphql/execution';
|
|
54
57
|
*
|
|
@@ -63,19 +66,19 @@ export interface GetVariableValuesOptions {
|
|
|
63
66
|
* }
|
|
64
67
|
* `);
|
|
65
68
|
* const operation = document.definitions[0];
|
|
69
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
66
70
|
*
|
|
67
|
-
* const result = getVariableValues(
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* { stars: '5' },
|
|
71
|
-
* );
|
|
71
|
+
* const result = getVariableValues(schema, operation.variableDefinitions ?? [], {
|
|
72
|
+
* stars: 5,
|
|
73
|
+
* });
|
|
72
74
|
*
|
|
73
75
|
* result; // => { coerced: { stars: 5, limit: 10 } }
|
|
74
76
|
* ```
|
|
75
77
|
* @example
|
|
76
78
|
* ```ts
|
|
79
|
+
* import assert from 'node:assert/strict';
|
|
77
80
|
* // This variant uses maxErrors to cap reported coercion errors.
|
|
78
|
-
* import { parse } from 'graphql/language';
|
|
81
|
+
* import { parse, Kind } from 'graphql/language';
|
|
79
82
|
* import { buildSchema } from 'graphql/utilities';
|
|
80
83
|
* import { getVariableValues } from 'graphql/execution';
|
|
81
84
|
*
|
|
@@ -95,16 +98,17 @@ export interface GetVariableValuesOptions {
|
|
|
95
98
|
* }
|
|
96
99
|
* `);
|
|
97
100
|
* const operation = document.definitions[0];
|
|
101
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
98
102
|
*
|
|
99
103
|
* const result = getVariableValues(
|
|
100
104
|
* schema,
|
|
101
|
-
* operation.variableDefinitions,
|
|
105
|
+
* operation.variableDefinitions ?? [],
|
|
102
106
|
* { first: { stars: 'bad' }, second: { stars: 'also bad' } },
|
|
103
107
|
* { maxErrors: 1 },
|
|
104
108
|
* );
|
|
105
109
|
*
|
|
106
|
-
* result.errors
|
|
107
|
-
* result.errors[1].message; //
|
|
110
|
+
* result.errors?.length; // => 2
|
|
111
|
+
* result.errors?.[1].message.includes('error limit reached'); // => true
|
|
108
112
|
* ```
|
|
109
113
|
*/
|
|
110
114
|
export declare function getVariableValues(
|
|
@@ -128,8 +132,9 @@ export declare function getVariableValues(
|
|
|
128
132
|
* @returns Coerced argument values keyed by argument name.
|
|
129
133
|
* @example
|
|
130
134
|
* ```ts
|
|
135
|
+
* import assert from 'node:assert/strict';
|
|
131
136
|
* // Read literal argument values and defaults.
|
|
132
|
-
* import { parse } from 'graphql/language';
|
|
137
|
+
* import { parse, Kind } from 'graphql/language';
|
|
133
138
|
* import { buildSchema } from 'graphql/utilities';
|
|
134
139
|
* import { getArgumentValues } from 'graphql/execution';
|
|
135
140
|
*
|
|
@@ -138,16 +143,21 @@ export declare function getVariableValues(
|
|
|
138
143
|
* reviews(stars: Int!, limit: Int = 10): [String]
|
|
139
144
|
* }
|
|
140
145
|
* `);
|
|
141
|
-
* const fieldDef = schema.getQueryType()
|
|
146
|
+
* const fieldDef = schema.getQueryType()?.getFields().reviews;
|
|
147
|
+
* assert(fieldDef);
|
|
142
148
|
* const document = parse('{ reviews(stars: 5) }');
|
|
143
|
-
* const
|
|
149
|
+
* const operation = document.definitions[0];
|
|
150
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
151
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
152
|
+
* assert(fieldNode.kind === Kind.FIELD);
|
|
144
153
|
*
|
|
145
154
|
* getArgumentValues(fieldDef, fieldNode); // => { stars: 5, limit: 10 }
|
|
146
155
|
* ```
|
|
147
156
|
* @example
|
|
148
157
|
* ```ts
|
|
158
|
+
* import assert from 'node:assert/strict';
|
|
149
159
|
* // This variant resolves argument values from operation variables.
|
|
150
|
-
* import { parse } from 'graphql/language';
|
|
160
|
+
* import { parse, Kind } from 'graphql/language';
|
|
151
161
|
* import { buildSchema } from 'graphql/utilities';
|
|
152
162
|
* import { getArgumentValues } from 'graphql/execution';
|
|
153
163
|
*
|
|
@@ -156,9 +166,13 @@ export declare function getVariableValues(
|
|
|
156
166
|
* reviews(stars: Int!): [String]
|
|
157
167
|
* }
|
|
158
168
|
* `);
|
|
159
|
-
* const fieldDef = schema.getQueryType()
|
|
169
|
+
* const fieldDef = schema.getQueryType()?.getFields().reviews;
|
|
170
|
+
* assert(fieldDef);
|
|
160
171
|
* const document = parse('query ($stars: Int!) { reviews(stars: $stars) }');
|
|
161
|
-
* const
|
|
172
|
+
* const operation = document.definitions[0];
|
|
173
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
174
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
175
|
+
* assert(fieldNode.kind === Kind.FIELD);
|
|
162
176
|
*
|
|
163
177
|
* getArgumentValues(fieldDef, fieldNode, { stars: 5 }); // => { stars: 5 }
|
|
164
178
|
* getArgumentValues(fieldDef, fieldNode, {}); // throws an error
|
|
@@ -198,25 +212,33 @@ export interface DirectiveValuesNode {
|
|
|
198
212
|
* @returns Coerced directive argument values keyed by argument name.
|
|
199
213
|
* @example
|
|
200
214
|
* ```ts
|
|
215
|
+
* import assert from 'node:assert/strict';
|
|
201
216
|
* // Read literal directive arguments from a node.
|
|
202
|
-
* import { parse } from 'graphql/language';
|
|
217
|
+
* import { parse, Kind } from 'graphql/language';
|
|
203
218
|
* import { GraphQLSkipDirective } from 'graphql/type';
|
|
204
219
|
* import { getDirectiveValues } from 'graphql/execution';
|
|
205
220
|
*
|
|
206
221
|
* const document = parse('{ name @skip(if: true) }');
|
|
207
|
-
* const
|
|
222
|
+
* const operation = document.definitions[0];
|
|
223
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
224
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
208
225
|
*
|
|
209
226
|
* getDirectiveValues(GraphQLSkipDirective, fieldNode); // => { if: true }
|
|
210
227
|
* ```
|
|
211
228
|
* @example
|
|
212
229
|
* ```ts
|
|
230
|
+
* import assert from 'node:assert/strict';
|
|
213
231
|
* // This variant resolves directive arguments from variables and handles absent directives.
|
|
214
|
-
* import { parse } from 'graphql/language';
|
|
232
|
+
* import { parse, Kind } from 'graphql/language';
|
|
215
233
|
* import { GraphQLIncludeDirective } from 'graphql/type';
|
|
216
234
|
* import { getDirectiveValues } from 'graphql/execution';
|
|
217
235
|
*
|
|
218
|
-
* const document = parse(
|
|
219
|
-
*
|
|
236
|
+
* const document = parse(
|
|
237
|
+
* 'query ($includeName: Boolean!) { name @include(if: $includeName) }',
|
|
238
|
+
* );
|
|
239
|
+
* const operation = document.definitions[0];
|
|
240
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
241
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
220
242
|
*
|
|
221
243
|
* getDirectiveValues(GraphQLIncludeDirective, fieldNode, {
|
|
222
244
|
* includeName: false,
|
package/execution/values.js
CHANGED
|
@@ -44,8 +44,9 @@ var _valueFromAST = require('../utilities/valueFromAST.js');
|
|
|
44
44
|
* @returns Coerced variable values, or request errors.
|
|
45
45
|
* @example
|
|
46
46
|
* ```ts
|
|
47
|
+
* import assert from 'node:assert/strict';
|
|
47
48
|
* // Coerce provided variables and apply operation defaults.
|
|
48
|
-
* import { parse } from 'graphql/language';
|
|
49
|
+
* import { parse, Kind } from 'graphql/language';
|
|
49
50
|
* import { buildSchema } from 'graphql/utilities';
|
|
50
51
|
* import { getVariableValues } from 'graphql/execution';
|
|
51
52
|
*
|
|
@@ -60,19 +61,19 @@ var _valueFromAST = require('../utilities/valueFromAST.js');
|
|
|
60
61
|
* }
|
|
61
62
|
* `);
|
|
62
63
|
* const operation = document.definitions[0];
|
|
64
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
63
65
|
*
|
|
64
|
-
* const result = getVariableValues(
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* { stars: '5' },
|
|
68
|
-
* );
|
|
66
|
+
* const result = getVariableValues(schema, operation.variableDefinitions ?? [], {
|
|
67
|
+
* stars: 5,
|
|
68
|
+
* });
|
|
69
69
|
*
|
|
70
70
|
* result; // => { coerced: { stars: 5, limit: 10 } }
|
|
71
71
|
* ```
|
|
72
72
|
* @example
|
|
73
73
|
* ```ts
|
|
74
|
+
* import assert from 'node:assert/strict';
|
|
74
75
|
* // This variant uses maxErrors to cap reported coercion errors.
|
|
75
|
-
* import { parse } from 'graphql/language';
|
|
76
|
+
* import { parse, Kind } from 'graphql/language';
|
|
76
77
|
* import { buildSchema } from 'graphql/utilities';
|
|
77
78
|
* import { getVariableValues } from 'graphql/execution';
|
|
78
79
|
*
|
|
@@ -92,16 +93,17 @@ var _valueFromAST = require('../utilities/valueFromAST.js');
|
|
|
92
93
|
* }
|
|
93
94
|
* `);
|
|
94
95
|
* const operation = document.definitions[0];
|
|
96
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
95
97
|
*
|
|
96
98
|
* const result = getVariableValues(
|
|
97
99
|
* schema,
|
|
98
|
-
* operation.variableDefinitions,
|
|
100
|
+
* operation.variableDefinitions ?? [],
|
|
99
101
|
* { first: { stars: 'bad' }, second: { stars: 'also bad' } },
|
|
100
102
|
* { maxErrors: 1 },
|
|
101
103
|
* );
|
|
102
104
|
*
|
|
103
|
-
* result.errors
|
|
104
|
-
* result.errors[1].message; //
|
|
105
|
+
* result.errors?.length; // => 2
|
|
106
|
+
* result.errors?.[1].message.includes('error limit reached'); // => true
|
|
105
107
|
* ```
|
|
106
108
|
*/
|
|
107
109
|
function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
@@ -123,6 +125,7 @@ function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
|
123
125
|
|
|
124
126
|
errors.push(error);
|
|
125
127
|
},
|
|
128
|
+
options === null || options === void 0 ? void 0 : options.hideSuggestions,
|
|
126
129
|
);
|
|
127
130
|
|
|
128
131
|
if (errors.length === 0) {
|
|
@@ -139,7 +142,13 @@ function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
|
139
142
|
};
|
|
140
143
|
}
|
|
141
144
|
|
|
142
|
-
function coerceVariableValues(
|
|
145
|
+
function coerceVariableValues(
|
|
146
|
+
schema,
|
|
147
|
+
varDefNodes,
|
|
148
|
+
inputs,
|
|
149
|
+
onError,
|
|
150
|
+
hideSuggestions,
|
|
151
|
+
) {
|
|
143
152
|
const coercedValues = Object.create(null);
|
|
144
153
|
|
|
145
154
|
for (const varDefNode of varDefNodes) {
|
|
@@ -149,7 +158,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
149
158
|
if (!(0, _definition.isInputType)(varType)) {
|
|
150
159
|
// Must use input types for variables. This should be caught during
|
|
151
160
|
// validation, however is checked again here for safety.
|
|
152
|
-
const varTypeStr = (0, _printer.
|
|
161
|
+
const varTypeStr = (0, _printer.printForError)(varDefNode.type);
|
|
153
162
|
onError(
|
|
154
163
|
new _GraphQLError.GraphQLError(
|
|
155
164
|
`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`,
|
|
@@ -218,6 +227,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
218
227
|
}),
|
|
219
228
|
);
|
|
220
229
|
},
|
|
230
|
+
hideSuggestions,
|
|
221
231
|
);
|
|
222
232
|
}
|
|
223
233
|
|
|
@@ -236,8 +246,9 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
236
246
|
* @returns Coerced argument values keyed by argument name.
|
|
237
247
|
* @example
|
|
238
248
|
* ```ts
|
|
249
|
+
* import assert from 'node:assert/strict';
|
|
239
250
|
* // Read literal argument values and defaults.
|
|
240
|
-
* import { parse } from 'graphql/language';
|
|
251
|
+
* import { parse, Kind } from 'graphql/language';
|
|
241
252
|
* import { buildSchema } from 'graphql/utilities';
|
|
242
253
|
* import { getArgumentValues } from 'graphql/execution';
|
|
243
254
|
*
|
|
@@ -246,16 +257,21 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
246
257
|
* reviews(stars: Int!, limit: Int = 10): [String]
|
|
247
258
|
* }
|
|
248
259
|
* `);
|
|
249
|
-
* const fieldDef = schema.getQueryType()
|
|
260
|
+
* const fieldDef = schema.getQueryType()?.getFields().reviews;
|
|
261
|
+
* assert(fieldDef);
|
|
250
262
|
* const document = parse('{ reviews(stars: 5) }');
|
|
251
|
-
* const
|
|
263
|
+
* const operation = document.definitions[0];
|
|
264
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
265
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
266
|
+
* assert(fieldNode.kind === Kind.FIELD);
|
|
252
267
|
*
|
|
253
268
|
* getArgumentValues(fieldDef, fieldNode); // => { stars: 5, limit: 10 }
|
|
254
269
|
* ```
|
|
255
270
|
* @example
|
|
256
271
|
* ```ts
|
|
272
|
+
* import assert from 'node:assert/strict';
|
|
257
273
|
* // This variant resolves argument values from operation variables.
|
|
258
|
-
* import { parse } from 'graphql/language';
|
|
274
|
+
* import { parse, Kind } from 'graphql/language';
|
|
259
275
|
* import { buildSchema } from 'graphql/utilities';
|
|
260
276
|
* import { getArgumentValues } from 'graphql/execution';
|
|
261
277
|
*
|
|
@@ -264,9 +280,13 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
264
280
|
* reviews(stars: Int!): [String]
|
|
265
281
|
* }
|
|
266
282
|
* `);
|
|
267
|
-
* const fieldDef = schema.getQueryType()
|
|
283
|
+
* const fieldDef = schema.getQueryType()?.getFields().reviews;
|
|
284
|
+
* assert(fieldDef);
|
|
268
285
|
* const document = parse('query ($stars: Int!) { reviews(stars: $stars) }');
|
|
269
|
-
* const
|
|
286
|
+
* const operation = document.definitions[0];
|
|
287
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
288
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
289
|
+
* assert(fieldNode.kind === Kind.FIELD);
|
|
270
290
|
*
|
|
271
291
|
* getArgumentValues(fieldDef, fieldNode, { stars: 5 }); // => { stars: 5 }
|
|
272
292
|
* getArgumentValues(fieldDef, fieldNode, {}); // throws an error
|
|
@@ -363,7 +383,7 @@ function getArgumentValues(def, node, variableValues) {
|
|
|
363
383
|
// execution. This is a runtime check to ensure execution does not
|
|
364
384
|
// continue with an invalid argument value.
|
|
365
385
|
throw new _GraphQLError.GraphQLError(
|
|
366
|
-
`Argument "${name}" has invalid value ${(0, _printer.
|
|
386
|
+
`Argument "${name}" has invalid value ${(0, _printer.printForError)(
|
|
367
387
|
valueNode,
|
|
368
388
|
)}.`,
|
|
369
389
|
{
|
|
@@ -398,25 +418,33 @@ function getArgumentValues(def, node, variableValues) {
|
|
|
398
418
|
* @returns Coerced directive argument values keyed by argument name.
|
|
399
419
|
* @example
|
|
400
420
|
* ```ts
|
|
421
|
+
* import assert from 'node:assert/strict';
|
|
401
422
|
* // Read literal directive arguments from a node.
|
|
402
|
-
* import { parse } from 'graphql/language';
|
|
423
|
+
* import { parse, Kind } from 'graphql/language';
|
|
403
424
|
* import { GraphQLSkipDirective } from 'graphql/type';
|
|
404
425
|
* import { getDirectiveValues } from 'graphql/execution';
|
|
405
426
|
*
|
|
406
427
|
* const document = parse('{ name @skip(if: true) }');
|
|
407
|
-
* const
|
|
428
|
+
* const operation = document.definitions[0];
|
|
429
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
430
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
408
431
|
*
|
|
409
432
|
* getDirectiveValues(GraphQLSkipDirective, fieldNode); // => { if: true }
|
|
410
433
|
* ```
|
|
411
434
|
* @example
|
|
412
435
|
* ```ts
|
|
436
|
+
* import assert from 'node:assert/strict';
|
|
413
437
|
* // This variant resolves directive arguments from variables and handles absent directives.
|
|
414
|
-
* import { parse } from 'graphql/language';
|
|
438
|
+
* import { parse, Kind } from 'graphql/language';
|
|
415
439
|
* import { GraphQLIncludeDirective } from 'graphql/type';
|
|
416
440
|
* import { getDirectiveValues } from 'graphql/execution';
|
|
417
441
|
*
|
|
418
|
-
* const document = parse(
|
|
419
|
-
*
|
|
442
|
+
* const document = parse(
|
|
443
|
+
* 'query ($includeName: Boolean!) { name @include(if: $includeName) }',
|
|
444
|
+
* );
|
|
445
|
+
* const operation = document.definitions[0];
|
|
446
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
447
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
420
448
|
*
|
|
421
449
|
* getDirectiveValues(GraphQLIncludeDirective, fieldNode, {
|
|
422
450
|
* includeName: false,
|
package/execution/values.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { keyMap } from '../jsutils/keyMap.mjs';
|
|
|
4
4
|
import { printPathArray } from '../jsutils/printPathArray.mjs';
|
|
5
5
|
import { GraphQLError } from '../error/GraphQLError.mjs';
|
|
6
6
|
import { Kind } from '../language/kinds.mjs';
|
|
7
|
-
import { print } from '../language/printer.mjs';
|
|
7
|
+
import { printForError as print } from '../language/printer.mjs';
|
|
8
8
|
import { isInputType, isNonNullType } from '../type/definition.mjs';
|
|
9
9
|
import { coerceInputValue } from '../utilities/coerceInputValue.mjs';
|
|
10
10
|
import { typeFromAST } from '../utilities/typeFromAST.mjs';
|
|
@@ -25,8 +25,9 @@ import { valueFromAST } from '../utilities/valueFromAST.mjs';
|
|
|
25
25
|
* @returns Coerced variable values, or request errors.
|
|
26
26
|
* @example
|
|
27
27
|
* ```ts
|
|
28
|
+
* import assert from 'node:assert/strict';
|
|
28
29
|
* // Coerce provided variables and apply operation defaults.
|
|
29
|
-
* import { parse } from 'graphql/language';
|
|
30
|
+
* import { parse, Kind } from 'graphql/language';
|
|
30
31
|
* import { buildSchema } from 'graphql/utilities';
|
|
31
32
|
* import { getVariableValues } from 'graphql/execution';
|
|
32
33
|
*
|
|
@@ -41,19 +42,19 @@ import { valueFromAST } from '../utilities/valueFromAST.mjs';
|
|
|
41
42
|
* }
|
|
42
43
|
* `);
|
|
43
44
|
* const operation = document.definitions[0];
|
|
45
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
44
46
|
*
|
|
45
|
-
* const result = getVariableValues(
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* { stars: '5' },
|
|
49
|
-
* );
|
|
47
|
+
* const result = getVariableValues(schema, operation.variableDefinitions ?? [], {
|
|
48
|
+
* stars: 5,
|
|
49
|
+
* });
|
|
50
50
|
*
|
|
51
51
|
* result; // => { coerced: { stars: 5, limit: 10 } }
|
|
52
52
|
* ```
|
|
53
53
|
* @example
|
|
54
54
|
* ```ts
|
|
55
|
+
* import assert from 'node:assert/strict';
|
|
55
56
|
* // This variant uses maxErrors to cap reported coercion errors.
|
|
56
|
-
* import { parse } from 'graphql/language';
|
|
57
|
+
* import { parse, Kind } from 'graphql/language';
|
|
57
58
|
* import { buildSchema } from 'graphql/utilities';
|
|
58
59
|
* import { getVariableValues } from 'graphql/execution';
|
|
59
60
|
*
|
|
@@ -73,16 +74,17 @@ import { valueFromAST } from '../utilities/valueFromAST.mjs';
|
|
|
73
74
|
* }
|
|
74
75
|
* `);
|
|
75
76
|
* const operation = document.definitions[0];
|
|
77
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
76
78
|
*
|
|
77
79
|
* const result = getVariableValues(
|
|
78
80
|
* schema,
|
|
79
|
-
* operation.variableDefinitions,
|
|
81
|
+
* operation.variableDefinitions ?? [],
|
|
80
82
|
* { first: { stars: 'bad' }, second: { stars: 'also bad' } },
|
|
81
83
|
* { maxErrors: 1 },
|
|
82
84
|
* );
|
|
83
85
|
*
|
|
84
|
-
* result.errors
|
|
85
|
-
* result.errors[1].message; //
|
|
86
|
+
* result.errors?.length; // => 2
|
|
87
|
+
* result.errors?.[1].message.includes('error limit reached'); // => true
|
|
86
88
|
* ```
|
|
87
89
|
*/
|
|
88
90
|
export function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
@@ -104,6 +106,7 @@ export function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
|
104
106
|
|
|
105
107
|
errors.push(error);
|
|
106
108
|
},
|
|
109
|
+
options === null || options === void 0 ? void 0 : options.hideSuggestions,
|
|
107
110
|
);
|
|
108
111
|
|
|
109
112
|
if (errors.length === 0) {
|
|
@@ -120,7 +123,13 @@ export function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
|
120
123
|
};
|
|
121
124
|
}
|
|
122
125
|
|
|
123
|
-
function coerceVariableValues(
|
|
126
|
+
function coerceVariableValues(
|
|
127
|
+
schema,
|
|
128
|
+
varDefNodes,
|
|
129
|
+
inputs,
|
|
130
|
+
onError,
|
|
131
|
+
hideSuggestions,
|
|
132
|
+
) {
|
|
124
133
|
const coercedValues = Object.create(null);
|
|
125
134
|
|
|
126
135
|
for (const varDefNode of varDefNodes) {
|
|
@@ -193,6 +202,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
193
202
|
}),
|
|
194
203
|
);
|
|
195
204
|
},
|
|
205
|
+
hideSuggestions,
|
|
196
206
|
);
|
|
197
207
|
}
|
|
198
208
|
|
|
@@ -211,8 +221,9 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
211
221
|
* @returns Coerced argument values keyed by argument name.
|
|
212
222
|
* @example
|
|
213
223
|
* ```ts
|
|
224
|
+
* import assert from 'node:assert/strict';
|
|
214
225
|
* // Read literal argument values and defaults.
|
|
215
|
-
* import { parse } from 'graphql/language';
|
|
226
|
+
* import { parse, Kind } from 'graphql/language';
|
|
216
227
|
* import { buildSchema } from 'graphql/utilities';
|
|
217
228
|
* import { getArgumentValues } from 'graphql/execution';
|
|
218
229
|
*
|
|
@@ -221,16 +232,21 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
221
232
|
* reviews(stars: Int!, limit: Int = 10): [String]
|
|
222
233
|
* }
|
|
223
234
|
* `);
|
|
224
|
-
* const fieldDef = schema.getQueryType()
|
|
235
|
+
* const fieldDef = schema.getQueryType()?.getFields().reviews;
|
|
236
|
+
* assert(fieldDef);
|
|
225
237
|
* const document = parse('{ reviews(stars: 5) }');
|
|
226
|
-
* const
|
|
238
|
+
* const operation = document.definitions[0];
|
|
239
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
240
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
241
|
+
* assert(fieldNode.kind === Kind.FIELD);
|
|
227
242
|
*
|
|
228
243
|
* getArgumentValues(fieldDef, fieldNode); // => { stars: 5, limit: 10 }
|
|
229
244
|
* ```
|
|
230
245
|
* @example
|
|
231
246
|
* ```ts
|
|
247
|
+
* import assert from 'node:assert/strict';
|
|
232
248
|
* // This variant resolves argument values from operation variables.
|
|
233
|
-
* import { parse } from 'graphql/language';
|
|
249
|
+
* import { parse, Kind } from 'graphql/language';
|
|
234
250
|
* import { buildSchema } from 'graphql/utilities';
|
|
235
251
|
* import { getArgumentValues } from 'graphql/execution';
|
|
236
252
|
*
|
|
@@ -239,9 +255,13 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
239
255
|
* reviews(stars: Int!): [String]
|
|
240
256
|
* }
|
|
241
257
|
* `);
|
|
242
|
-
* const fieldDef = schema.getQueryType()
|
|
258
|
+
* const fieldDef = schema.getQueryType()?.getFields().reviews;
|
|
259
|
+
* assert(fieldDef);
|
|
243
260
|
* const document = parse('query ($stars: Int!) { reviews(stars: $stars) }');
|
|
244
|
-
* const
|
|
261
|
+
* const operation = document.definitions[0];
|
|
262
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
263
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
264
|
+
* assert(fieldNode.kind === Kind.FIELD);
|
|
245
265
|
*
|
|
246
266
|
* getArgumentValues(fieldDef, fieldNode, { stars: 5 }); // => { stars: 5 }
|
|
247
267
|
* getArgumentValues(fieldDef, fieldNode, {}); // throws an error
|
|
@@ -360,25 +380,33 @@ export function getArgumentValues(def, node, variableValues) {
|
|
|
360
380
|
* @returns Coerced directive argument values keyed by argument name.
|
|
361
381
|
* @example
|
|
362
382
|
* ```ts
|
|
383
|
+
* import assert from 'node:assert/strict';
|
|
363
384
|
* // Read literal directive arguments from a node.
|
|
364
|
-
* import { parse } from 'graphql/language';
|
|
385
|
+
* import { parse, Kind } from 'graphql/language';
|
|
365
386
|
* import { GraphQLSkipDirective } from 'graphql/type';
|
|
366
387
|
* import { getDirectiveValues } from 'graphql/execution';
|
|
367
388
|
*
|
|
368
389
|
* const document = parse('{ name @skip(if: true) }');
|
|
369
|
-
* const
|
|
390
|
+
* const operation = document.definitions[0];
|
|
391
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
392
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
370
393
|
*
|
|
371
394
|
* getDirectiveValues(GraphQLSkipDirective, fieldNode); // => { if: true }
|
|
372
395
|
* ```
|
|
373
396
|
* @example
|
|
374
397
|
* ```ts
|
|
398
|
+
* import assert from 'node:assert/strict';
|
|
375
399
|
* // This variant resolves directive arguments from variables and handles absent directives.
|
|
376
|
-
* import { parse } from 'graphql/language';
|
|
400
|
+
* import { parse, Kind } from 'graphql/language';
|
|
377
401
|
* import { GraphQLIncludeDirective } from 'graphql/type';
|
|
378
402
|
* import { getDirectiveValues } from 'graphql/execution';
|
|
379
403
|
*
|
|
380
|
-
* const document = parse(
|
|
381
|
-
*
|
|
404
|
+
* const document = parse(
|
|
405
|
+
* 'query ($includeName: Boolean!) { name @include(if: $includeName) }',
|
|
406
|
+
* );
|
|
407
|
+
* const operation = document.definitions[0];
|
|
408
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
409
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
382
410
|
*
|
|
383
411
|
* getDirectiveValues(GraphQLIncludeDirective, fieldNode, {
|
|
384
412
|
* includeName: false,
|
package/graphql.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ import type { ExecutionResult } from './execution/execute';
|
|
|
14
14
|
* @category Request Pipeline
|
|
15
15
|
*/
|
|
16
16
|
export interface GraphQLArgs {
|
|
17
|
+
/** Omit suggestions from validation and input coercion errors. */
|
|
18
|
+
hideSuggestions?: Maybe<boolean>;
|
|
17
19
|
/** The GraphQL type system to use when validating and executing a query. */
|
|
18
20
|
schema: GraphQLSchema;
|
|
19
21
|
/**
|
|
@@ -84,13 +86,11 @@ export interface GraphQLArgs {
|
|
|
84
86
|
* schema,
|
|
85
87
|
* source: 'query SayHello($name: String!) { greeting(name: $name) }',
|
|
86
88
|
* rootValue: {
|
|
87
|
-
* greeting: ({ name }) => `Hello, ${name}!`,
|
|
89
|
+
* greeting: ({ name }: { name: string }) => `Hello, ${name}!`,
|
|
88
90
|
* },
|
|
89
91
|
* variableValues: { name: 'Ada' },
|
|
90
92
|
* operationName: 'SayHello',
|
|
91
|
-
* });
|
|
92
|
-
*
|
|
93
|
-
* result; // => { data: { greeting: 'Hello, Ada!' } }
|
|
93
|
+
* }); // => { data: { greeting: 'Hello, Ada!' } }
|
|
94
94
|
* ```
|
|
95
95
|
* @example
|
|
96
96
|
* ```ts
|
|
@@ -123,9 +123,7 @@ export interface GraphQLArgs {
|
|
|
123
123
|
* typeResolver: (value) => {
|
|
124
124
|
* return value.kind === 'user' ? 'User' : undefined;
|
|
125
125
|
* },
|
|
126
|
-
* });
|
|
127
|
-
*
|
|
128
|
-
* result; // => { data: { viewer: { __typename: 'User', name: 'Ada' } } }
|
|
126
|
+
* }); // => { data: { viewer: { __typename: 'User', name: 'Ada' } } }
|
|
129
127
|
* ```
|
|
130
128
|
* @category Request Pipeline
|
|
131
129
|
*/
|
|
@@ -154,13 +152,11 @@ export declare function graphql(args: GraphQLArgs): Promise<ExecutionResult>;
|
|
|
154
152
|
* schema,
|
|
155
153
|
* source: 'query SayHello($name: String!) { greeting(name: $name) }',
|
|
156
154
|
* rootValue: {
|
|
157
|
-
* greeting: ({ name }) => `Hello, ${name}!`,
|
|
155
|
+
* greeting: ({ name }: { name: string }) => `Hello, ${name}!`,
|
|
158
156
|
* },
|
|
159
157
|
* variableValues: { name: 'Ada' },
|
|
160
158
|
* operationName: 'SayHello',
|
|
161
|
-
* });
|
|
162
|
-
*
|
|
163
|
-
* result; // => { data: { greeting: 'Hello, Ada!' } }
|
|
159
|
+
* }); // => { data: { greeting: 'Hello, Ada!' } }
|
|
164
160
|
* ```
|
|
165
161
|
* @example
|
|
166
162
|
* ```ts
|
|
@@ -180,9 +176,7 @@ export declare function graphql(args: GraphQLArgs): Promise<ExecutionResult>;
|
|
|
180
176
|
* return contextValue.defaultGreeting;
|
|
181
177
|
* },
|
|
182
178
|
* contextValue: { defaultGreeting: 'Hello' },
|
|
183
|
-
* });
|
|
184
|
-
*
|
|
185
|
-
* result; // => { data: { greeting: 'Hello' } }
|
|
179
|
+
* }); // => { data: { greeting: 'Hello' } }
|
|
186
180
|
* ```
|
|
187
181
|
* @category Request Pipeline
|
|
188
182
|
*/
|