@@ -55,7 +55,7 @@ export function getVariableValues(
5555 schema : GraphQLSchema ,
5656 varDefNodes : ReadonlyArray < VariableDefinitionNode > ,
5757 inputs : { readonly [ variable : string ] : unknown } ,
58- options ?: { maxErrors ?: number } ,
58+ options ?: { maxErrors ?: number ; hideSuggestions ?: boolean } ,
5959) : VariableValuesOrErrors {
6060 const errors : Array < GraphQLError > = [ ] ;
6161 const maxErrors = options ?. maxErrors ;
@@ -72,6 +72,7 @@ export function getVariableValues(
7272 }
7373 errors . push ( error ) ;
7474 } ,
75+ options ?. hideSuggestions ,
7576 ) ;
7677
7778 if ( errors . length === 0 ) {
@@ -89,6 +90,7 @@ function coerceVariableValues(
8990 varDefNodes : ReadonlyArray < VariableDefinitionNode > ,
9091 inputs : { readonly [ variable : string ] : unknown } ,
9192 onError : ( error : GraphQLError ) => void ,
93+ hideSuggestions ?: Maybe < boolean > ,
9294) : VariableValues {
9395 const sources : ObjMap < VariableValueSource > = Object . create ( null ) ;
9496 const coerced : ObjMap < unknown > = Object . create ( null ) ;
@@ -105,7 +107,11 @@ function coerceVariableValues(
105107 const defaultValue = varSignature . defaultValue ;
106108 if ( defaultValue ) {
107109 sources [ varName ] = { signature : varSignature } ;
108- coerced [ varName ] = coerceDefaultValue ( defaultValue , varType ) ;
110+ coerced [ varName ] = coerceDefaultValue (
111+ defaultValue ,
112+ varType ,
113+ hideSuggestions ,
114+ ) ;
109115 } else if ( isNonNullType ( varType ) ) {
110116 const varTypeStr = inspect ( varType ) ;
111117 onError (
@@ -149,6 +155,7 @@ function coerceVariableValues(
149155 } ) ,
150156 ) ;
151157 } ,
158+ hideSuggestions ,
152159 ) ;
153160 }
154161
@@ -160,6 +167,7 @@ export function getFragmentVariableValues(
160167 fragmentSignatures : ReadOnlyObjMap < GraphQLVariableSignature > ,
161168 variableValues : VariableValues ,
162169 fragmentVariableValues ?: Maybe < VariableValues > ,
170+ hideSuggestions ?: Maybe < boolean > ,
163171) : VariableValues {
164172 const varSignatures : Array < GraphQLVariableSignature > = [ ] ;
165173 const sources = Object . create ( null ) ;
@@ -178,6 +186,7 @@ export function getFragmentVariableValues(
178186 varSignatures ,
179187 variableValues ,
180188 fragmentVariableValues ,
189+ hideSuggestions ,
181190 ) ;
182191
183192 return { sources, coerced } ;
@@ -195,15 +204,23 @@ export function getArgumentValues(
195204 def : GraphQLField < unknown , unknown > | GraphQLDirective ,
196205 node : FieldNode | DirectiveNode ,
197206 variableValues ?: Maybe < VariableValues > ,
207+ hideSuggestions ?: Maybe < boolean > ,
198208) : { [ argument : string ] : unknown } {
199- return experimentalGetArgumentValues ( node , def . args , variableValues ) ;
209+ return experimentalGetArgumentValues (
210+ node ,
211+ def . args ,
212+ variableValues ,
213+ undefined ,
214+ hideSuggestions ,
215+ ) ;
200216}
201217
202218export function experimentalGetArgumentValues (
203219 node : FieldNode | DirectiveNode | FragmentSpreadNode ,
204220 argDefs : ReadonlyArray < GraphQLArgument | GraphQLVariableSignature > ,
205221 variableValues : Maybe < VariableValues > ,
206222 fragmentVariablesValues ?: Maybe < VariableValues > ,
223+ hideSuggestions ?: Maybe < boolean > ,
207224) : { [ argument : string ] : unknown } {
208225 const coercedValues : { [ argument : string ] : unknown } = { } ;
209226
@@ -222,6 +239,7 @@ export function experimentalGetArgumentValues(
222239 coercedValues [ name ] = coerceDefaultValue (
223240 argDef . defaultValue ,
224241 argDef . type ,
242+ hideSuggestions ,
225243 ) ;
226244 } else if ( isNonNullType ( argType ) ) {
227245 throw new GraphQLError (
@@ -251,6 +269,7 @@ export function experimentalGetArgumentValues(
251269 coercedValues [ name ] = coerceDefaultValue (
252270 argDef . defaultValue ,
253271 argDef . type ,
272+ hideSuggestions ,
254273 ) ;
255274 } else if ( isNonNullType ( argType ) ) {
256275 throw new GraphQLError (
@@ -277,6 +296,7 @@ export function experimentalGetArgumentValues(
277296 argType ,
278297 variableValues ,
279298 fragmentVariablesValues ,
299+ hideSuggestions ,
280300 ) ;
281301 if ( coercedValue === undefined ) {
282302 // Note: ValuesOfCorrectTypeRule validation should catch this before
@@ -310,6 +330,7 @@ export function getDirectiveValues(
310330 node : { readonly directives ?: ReadonlyArray < DirectiveNode > | undefined } ,
311331 variableValues ?: Maybe < VariableValues > ,
312332 fragmentVariableValues ?: Maybe < VariableValues > ,
333+ hideSuggestions ?: Maybe < boolean > ,
313334) : undefined | { [ argument : string ] : unknown } {
314335 const directiveNode = node . directives ?. find (
315336 ( directive ) => directive . name . value === directiveDef . name ,
@@ -321,6 +342,7 @@ export function getDirectiveValues(
321342 directiveDef . args ,
322343 variableValues ,
323344 fragmentVariableValues ,
345+ hideSuggestions ,
324346 ) ;
325347 }
326348}
0 commit comments