@@ -98,15 +98,21 @@ const collectSubfields = memoize3(
98
98
returnType : GraphQLObjectType ,
99
99
fieldGroup : FieldGroup ,
100
100
) => {
101
- const { schema, fragments, operation, variableValues } =
102
- validatedExecutionArgs ;
101
+ const {
102
+ schema,
103
+ fragments,
104
+ operation,
105
+ variableValues,
106
+ shouldProvideSuggestions,
107
+ } = validatedExecutionArgs ;
103
108
return _collectSubfields (
104
109
schema ,
105
110
fragments ,
106
111
variableValues ,
107
112
operation ,
108
113
returnType ,
109
114
fieldGroup ,
115
+ shouldProvideSuggestions ,
110
116
) ;
111
117
} ,
112
118
) ;
@@ -148,6 +154,7 @@ export interface ValidatedExecutionArgs {
148
154
typeResolver : GraphQLTypeResolver < any , any > ;
149
155
subscribeFieldResolver : GraphQLFieldResolver < any , any > ;
150
156
enableEarlyExecution : boolean ;
157
+ shouldProvideSuggestions : boolean ;
151
158
}
152
159
153
160
export interface ExecutionContext {
@@ -172,6 +179,7 @@ export interface ExecutionArgs {
172
179
typeResolver ?: Maybe < GraphQLTypeResolver < any , any > > ;
173
180
subscribeFieldResolver ?: Maybe < GraphQLFieldResolver < any , any > > ;
174
181
enableEarlyExecution ?: Maybe < boolean > ;
182
+ shouldProvideSuggestions ?: Maybe < boolean > ;
175
183
}
176
184
177
185
export interface StreamUsage {
@@ -280,8 +288,14 @@ function executeOperation(
280
288
cancellableStreams : undefined ,
281
289
} ;
282
290
try {
283
- const { schema, fragments, rootValue, operation, variableValues } =
284
- validatedExecutionArgs ;
291
+ const {
292
+ schema,
293
+ fragments,
294
+ rootValue,
295
+ operation,
296
+ variableValues,
297
+ shouldProvideSuggestions,
298
+ } = validatedExecutionArgs ;
285
299
const rootType = schema . getRootType ( operation . operation ) ;
286
300
if ( rootType == null ) {
287
301
throw new GraphQLError (
@@ -296,6 +310,7 @@ function executeOperation(
296
310
variableValues ,
297
311
rootType ,
298
312
operation ,
313
+ shouldProvideSuggestions ,
299
314
) ;
300
315
301
316
const { groupedFieldSet, newDeferUsages } = collectedFields ;
@@ -472,6 +487,7 @@ export function validateExecutionArgs(
472
487
typeResolver,
473
488
subscribeFieldResolver,
474
489
enableEarlyExecution,
490
+ shouldProvideSuggestions,
475
491
} = args ;
476
492
477
493
// If the schema used for execution is invalid, throw an error.
@@ -527,7 +543,10 @@ export function validateExecutionArgs(
527
543
schema ,
528
544
variableDefinitions ,
529
545
rawVariableValues ?? { } ,
530
- { maxErrors : 50 } ,
546
+ {
547
+ maxErrors : 50 ,
548
+ shouldProvideSuggestions : shouldProvideSuggestions ?? true ,
549
+ } ,
531
550
) ;
532
551
533
552
if ( variableValuesOrErrors . errors ) {
@@ -545,6 +564,7 @@ export function validateExecutionArgs(
545
564
typeResolver : typeResolver ?? defaultTypeResolver ,
546
565
subscribeFieldResolver : subscribeFieldResolver ?? defaultFieldResolver ,
547
566
enableEarlyExecution : enableEarlyExecution === true ,
567
+ shouldProvideSuggestions : shouldProvideSuggestions ?? true ,
548
568
} ;
549
569
}
550
570
@@ -728,7 +748,8 @@ function executeField(
728
748
deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
729
749
) : PromiseOrValue < GraphQLWrappedResult < unknown > > | undefined {
730
750
const validatedExecutionArgs = exeContext . validatedExecutionArgs ;
731
- const { schema, contextValue, variableValues } = validatedExecutionArgs ;
751
+ const { schema, contextValue, variableValues, shouldProvideSuggestions } =
752
+ validatedExecutionArgs ;
732
753
const fieldName = fieldGroup [ 0 ] . node . name . value ;
733
754
const fieldDef = schema . getField ( parentType , fieldName ) ;
734
755
if ( ! fieldDef ) {
@@ -755,6 +776,7 @@ function executeField(
755
776
fieldGroup [ 0 ] . node ,
756
777
fieldDef . args ,
757
778
variableValues ,
779
+ shouldProvideSuggestions ,
758
780
fieldGroup [ 0 ] . fragmentVariableValues ,
759
781
) ;
760
782
@@ -1058,12 +1080,14 @@ function getStreamUsage(
1058
1080
. _streamUsage ;
1059
1081
}
1060
1082
1061
- const { operation, variableValues } = validatedExecutionArgs ;
1083
+ const { operation, variableValues, shouldProvideSuggestions } =
1084
+ validatedExecutionArgs ;
1062
1085
// validation only allows equivalent streams on multiple fields, so it is
1063
1086
// safe to only check the first fieldNode for the stream directive
1064
1087
const stream = getDirectiveValues (
1065
1088
GraphQLStreamDirective ,
1066
1089
fieldGroup [ 0 ] . node ,
1090
+ shouldProvideSuggestions ,
1067
1091
variableValues ,
1068
1092
fieldGroup [ 0 ] . fragmentVariableValues ,
1069
1093
) ;
@@ -2023,6 +2047,7 @@ function executeSubscription(
2023
2047
contextValue,
2024
2048
operation,
2025
2049
variableValues,
2050
+ shouldProvideSuggestions,
2026
2051
} = validatedExecutionArgs ;
2027
2052
2028
2053
const rootType = schema . getSubscriptionType ( ) ;
@@ -2039,6 +2064,7 @@ function executeSubscription(
2039
2064
variableValues ,
2040
2065
rootType ,
2041
2066
operation ,
2067
+ shouldProvideSuggestions ,
2042
2068
) ;
2043
2069
2044
2070
const firstRootField = groupedFieldSet . entries ( ) . next ( ) . value as [
@@ -2072,7 +2098,12 @@ function executeSubscription(
2072
2098
2073
2099
// Build a JS object of arguments from the field.arguments AST, using the
2074
2100
// variables scope to fulfill any variable references.
2075
- const args = getArgumentValues ( fieldDef , fieldNodes [ 0 ] , variableValues ) ;
2101
+ const args = getArgumentValues (
2102
+ fieldDef ,
2103
+ fieldNodes [ 0 ] ,
2104
+ validatedExecutionArgs . shouldProvideSuggestions ,
2105
+ variableValues ,
2106
+ ) ;
2076
2107
2077
2108
// Call the `subscribe()` resolver or the default resolver to produce an
2078
2109
// AsyncIterable yielding raw payloads.
0 commit comments