@@ -54,14 +54,14 @@ export function fragmentArgumentSubstitutions(
54
54
}
55
55
56
56
for ( const variableDefinition of variableDefinitions ) {
57
- const argumentName = variableDefinition . variable . name . value ;
58
- if ( substitutions . has ( argumentName ) ) {
57
+ const variableName = variableDefinition . variable . name . value ;
58
+ if ( substitutions . has ( variableName ) ) {
59
59
continue ;
60
60
}
61
61
62
62
const defaultValue = variableDefinition . defaultValue ;
63
63
if ( defaultValue ) {
64
- substitutions . set ( argumentName , defaultValue ) ;
64
+ substitutions . set ( variableName , defaultValue ) ;
65
65
} else {
66
66
// We need a way to allow unset arguments without accidentally
67
67
// replacing an unset fragment argument with an operation
@@ -72,9 +72,11 @@ export function fragmentArgumentSubstitutions(
72
72
// - make unset fragment arguments invalid
73
73
// Requiring the spread to pass all non-default-defined arguments is nice,
74
74
// but makes field argument default values impossible to use.
75
- substitutions . set ( argumentName , {
75
+ substitutions . set ( variableName , {
76
76
kind : Kind . VARIABLE ,
77
- name : { kind : Kind . NAME , value : '__UNSET' } ,
77
+ // We set the variable name to something that is "guaranteed" to be unset
78
+ // so that we can leverage default field arguments when defined.
79
+ name : { kind : Kind . NAME , value : variableName + '__UNSET' } ,
78
80
} ) ;
79
81
}
80
82
}
0 commit comments