@@ -55,7 +55,7 @@ export function getVariableValues(
55
55
schema : GraphQLSchema ,
56
56
varDefNodes : ReadonlyArray < VariableDefinitionNode > ,
57
57
inputs : { readonly [ variable : string ] : unknown } ,
58
- options ?: { maxErrors ?: number } ,
58
+ options ?: { maxErrors ?: number ; hideSuggestions ?: boolean } ,
59
59
) : VariableValuesOrErrors {
60
60
const errors : Array < GraphQLError > = [ ] ;
61
61
const maxErrors = options ?. maxErrors ;
@@ -72,6 +72,7 @@ export function getVariableValues(
72
72
}
73
73
errors . push ( error ) ;
74
74
} ,
75
+ options ?. hideSuggestions ,
75
76
) ;
76
77
77
78
if ( errors . length === 0 ) {
@@ -89,6 +90,7 @@ function coerceVariableValues(
89
90
varDefNodes : ReadonlyArray < VariableDefinitionNode > ,
90
91
inputs : { readonly [ variable : string ] : unknown } ,
91
92
onError : ( error : GraphQLError ) => void ,
93
+ hideSuggestions ?: Maybe < boolean > ,
92
94
) : VariableValues {
93
95
const sources : ObjMap < VariableValueSource > = Object . create ( null ) ;
94
96
const coerced : ObjMap < unknown > = Object . create ( null ) ;
@@ -105,7 +107,11 @@ function coerceVariableValues(
105
107
const defaultValue = varSignature . defaultValue ;
106
108
if ( defaultValue ) {
107
109
sources [ varName ] = { signature : varSignature } ;
108
- coerced [ varName ] = coerceDefaultValue ( defaultValue , varType ) ;
110
+ coerced [ varName ] = coerceDefaultValue (
111
+ defaultValue ,
112
+ varType ,
113
+ hideSuggestions ,
114
+ ) ;
109
115
} else if ( isNonNullType ( varType ) ) {
110
116
const varTypeStr = inspect ( varType ) ;
111
117
onError (
@@ -149,6 +155,7 @@ function coerceVariableValues(
149
155
} ) ,
150
156
) ;
151
157
} ,
158
+ hideSuggestions ,
152
159
) ;
153
160
}
154
161
@@ -160,6 +167,7 @@ export function getFragmentVariableValues(
160
167
fragmentSignatures : ReadOnlyObjMap < GraphQLVariableSignature > ,
161
168
variableValues : VariableValues ,
162
169
fragmentVariableValues ?: Maybe < VariableValues > ,
170
+ hideSuggestions ?: Maybe < boolean > ,
163
171
) : VariableValues {
164
172
const varSignatures : Array < GraphQLVariableSignature > = [ ] ;
165
173
const sources = Object . create ( null ) ;
@@ -178,6 +186,7 @@ export function getFragmentVariableValues(
178
186
varSignatures ,
179
187
variableValues ,
180
188
fragmentVariableValues ,
189
+ hideSuggestions ,
181
190
) ;
182
191
183
192
return { sources, coerced } ;
@@ -195,15 +204,23 @@ export function getArgumentValues(
195
204
def : GraphQLField < unknown , unknown > | GraphQLDirective ,
196
205
node : FieldNode | DirectiveNode ,
197
206
variableValues ?: Maybe < VariableValues > ,
207
+ hideSuggestions ?: Maybe < boolean > ,
198
208
) : { [ 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
+ ) ;
200
216
}
201
217
202
218
export function experimentalGetArgumentValues (
203
219
node : FieldNode | DirectiveNode | FragmentSpreadNode ,
204
220
argDefs : ReadonlyArray < GraphQLArgument | GraphQLVariableSignature > ,
205
221
variableValues : Maybe < VariableValues > ,
206
222
fragmentVariablesValues ?: Maybe < VariableValues > ,
223
+ hideSuggestions ?: Maybe < boolean > ,
207
224
) : { [ argument : string ] : unknown } {
208
225
const coercedValues : { [ argument : string ] : unknown } = { } ;
209
226
@@ -222,6 +239,7 @@ export function experimentalGetArgumentValues(
222
239
coercedValues [ name ] = coerceDefaultValue (
223
240
argDef . defaultValue ,
224
241
argDef . type ,
242
+ hideSuggestions ,
225
243
) ;
226
244
} else if ( isNonNullType ( argType ) ) {
227
245
throw new GraphQLError (
@@ -251,6 +269,7 @@ export function experimentalGetArgumentValues(
251
269
coercedValues [ name ] = coerceDefaultValue (
252
270
argDef . defaultValue ,
253
271
argDef . type ,
272
+ hideSuggestions ,
254
273
) ;
255
274
} else if ( isNonNullType ( argType ) ) {
256
275
throw new GraphQLError (
@@ -277,6 +296,7 @@ export function experimentalGetArgumentValues(
277
296
argType ,
278
297
variableValues ,
279
298
fragmentVariablesValues ,
299
+ hideSuggestions ,
280
300
) ;
281
301
if ( coercedValue === undefined ) {
282
302
// Note: ValuesOfCorrectTypeRule validation should catch this before
@@ -310,6 +330,7 @@ export function getDirectiveValues(
310
330
node : { readonly directives ?: ReadonlyArray < DirectiveNode > | undefined } ,
311
331
variableValues ?: Maybe < VariableValues > ,
312
332
fragmentVariableValues ?: Maybe < VariableValues > ,
333
+ hideSuggestions ?: Maybe < boolean > ,
313
334
) : undefined | { [ argument : string ] : unknown } {
314
335
const directiveNode = node . directives ?. find (
315
336
( directive ) => directive . name . value === directiveDef . name ,
@@ -321,6 +342,7 @@ export function getDirectiveValues(
321
342
directiveDef . args ,
322
343
variableValues ,
323
344
fragmentVariableValues ,
345
+ hideSuggestions ,
324
346
) ;
325
347
}
326
348
}
0 commit comments