@@ -98,15 +98,21 @@ const collectSubfields = memoize3(
9898 returnType : GraphQLObjectType ,
9999 fieldGroup : FieldGroup ,
100100 ) => {
101- const { schema, fragments, operation, variableValues } =
102- validatedExecutionArgs ;
101+ const {
102+ schema,
103+ fragments,
104+ operation,
105+ variableValues,
106+ shouldProvideSuggestions,
107+ } = validatedExecutionArgs ;
103108 return _collectSubfields (
104109 schema ,
105110 fragments ,
106111 variableValues ,
107112 operation ,
108113 returnType ,
109114 fieldGroup ,
115+ shouldProvideSuggestions ,
110116 ) ;
111117 } ,
112118) ;
@@ -148,6 +154,7 @@ export interface ValidatedExecutionArgs {
148154 typeResolver : GraphQLTypeResolver < any , any > ;
149155 subscribeFieldResolver : GraphQLFieldResolver < any , any > ;
150156 enableEarlyExecution : boolean ;
157+ shouldProvideSuggestions : boolean ;
151158}
152159
153160export interface ExecutionContext {
@@ -172,6 +179,7 @@ export interface ExecutionArgs {
172179 typeResolver ?: Maybe < GraphQLTypeResolver < any , any > > ;
173180 subscribeFieldResolver ?: Maybe < GraphQLFieldResolver < any , any > > ;
174181 enableEarlyExecution ?: Maybe < boolean > ;
182+ shouldProvideSuggestions ?: Maybe < boolean > ;
175183}
176184
177185export interface StreamUsage {
@@ -280,8 +288,14 @@ function executeOperation(
280288 cancellableStreams : undefined ,
281289 } ;
282290 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 ;
285299 const rootType = schema . getRootType ( operation . operation ) ;
286300 if ( rootType == null ) {
287301 throw new GraphQLError (
@@ -296,6 +310,7 @@ function executeOperation(
296310 variableValues ,
297311 rootType ,
298312 operation ,
313+ shouldProvideSuggestions ,
299314 ) ;
300315
301316 const { groupedFieldSet, newDeferUsages } = collectedFields ;
@@ -472,6 +487,7 @@ export function validateExecutionArgs(
472487 typeResolver,
473488 subscribeFieldResolver,
474489 enableEarlyExecution,
490+ shouldProvideSuggestions,
475491 } = args ;
476492
477493 // If the schema used for execution is invalid, throw an error.
@@ -527,7 +543,10 @@ export function validateExecutionArgs(
527543 schema ,
528544 variableDefinitions ,
529545 rawVariableValues ?? { } ,
530- { maxErrors : 50 } ,
546+ {
547+ maxErrors : 50 ,
548+ shouldProvideSuggestions : shouldProvideSuggestions ?? true ,
549+ } ,
531550 ) ;
532551
533552 if ( variableValuesOrErrors . errors ) {
@@ -545,6 +564,7 @@ export function validateExecutionArgs(
545564 typeResolver : typeResolver ?? defaultTypeResolver ,
546565 subscribeFieldResolver : subscribeFieldResolver ?? defaultFieldResolver ,
547566 enableEarlyExecution : enableEarlyExecution === true ,
567+ shouldProvideSuggestions : shouldProvideSuggestions ?? true ,
548568 } ;
549569}
550570
@@ -728,7 +748,8 @@ function executeField(
728748 deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
729749) : PromiseOrValue < GraphQLWrappedResult < unknown > > | undefined {
730750 const validatedExecutionArgs = exeContext . validatedExecutionArgs ;
731- const { schema, contextValue, variableValues } = validatedExecutionArgs ;
751+ const { schema, contextValue, variableValues, shouldProvideSuggestions } =
752+ validatedExecutionArgs ;
732753 const fieldName = fieldGroup [ 0 ] . node . name . value ;
733754 const fieldDef = schema . getField ( parentType , fieldName ) ;
734755 if ( ! fieldDef ) {
@@ -755,6 +776,7 @@ function executeField(
755776 fieldGroup [ 0 ] . node ,
756777 fieldDef . args ,
757778 variableValues ,
779+ shouldProvideSuggestions ,
758780 fieldGroup [ 0 ] . fragmentVariableValues ,
759781 ) ;
760782
@@ -1058,12 +1080,14 @@ function getStreamUsage(
10581080 . _streamUsage ;
10591081 }
10601082
1061- const { operation, variableValues } = validatedExecutionArgs ;
1083+ const { operation, variableValues, shouldProvideSuggestions } =
1084+ validatedExecutionArgs ;
10621085 // validation only allows equivalent streams on multiple fields, so it is
10631086 // safe to only check the first fieldNode for the stream directive
10641087 const stream = getDirectiveValues (
10651088 GraphQLStreamDirective ,
10661089 fieldGroup [ 0 ] . node ,
1090+ shouldProvideSuggestions ,
10671091 variableValues ,
10681092 fieldGroup [ 0 ] . fragmentVariableValues ,
10691093 ) ;
@@ -2023,6 +2047,7 @@ function executeSubscription(
20232047 contextValue,
20242048 operation,
20252049 variableValues,
2050+ shouldProvideSuggestions,
20262051 } = validatedExecutionArgs ;
20272052
20282053 const rootType = schema . getSubscriptionType ( ) ;
@@ -2039,6 +2064,7 @@ function executeSubscription(
20392064 variableValues ,
20402065 rootType ,
20412066 operation ,
2067+ shouldProvideSuggestions ,
20422068 ) ;
20432069
20442070 const firstRootField = groupedFieldSet . entries ( ) . next ( ) . value as [
@@ -2072,7 +2098,12 @@ function executeSubscription(
20722098
20732099 // Build a JS object of arguments from the field.arguments AST, using the
20742100 // 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+ ) ;
20762107
20772108 // Call the `subscribe()` resolver or the default resolver to produce an
20782109 // AsyncIterable yielding raw payloads.
0 commit comments