@@ -61,21 +61,30 @@ export function getArgumentValues(
61
61
62
62
if ( valueNode . kind === Kind . VARIABLE ) {
63
63
const variableName = valueNode . name . value ;
64
- if ( variableValues == null || ! hasOwnProperty ( variableValues , variableName ) ) {
65
- if ( defaultValue !== undefined ) {
64
+ if ( fragmentArgValues != null && hasOwnProperty ( fragmentArgValues , variableName ) ) {
65
+ isNull = fragmentArgValues [ variableName ] == null ;
66
+ if ( isNull && defaultValue !== undefined ) {
66
67
coercedValues [ name ] = defaultValue ;
67
- } else if ( isNonNullType ( argType ) ) {
68
- throw createGraphQLError (
69
- `Argument "${ name } " of required type "${ inspect ( argType ) } " ` +
70
- `was provided the variable "$${ variableName } " which was not provided a runtime value.` ,
71
- {
72
- nodes : [ valueNode ] ,
73
- } ,
74
- ) ;
68
+ continue ;
75
69
}
70
+ } else if ( variableValues != null && hasOwnProperty ( variableValues , variableName ) ) {
71
+ isNull = variableValues [ variableName ] == null ;
72
+ if ( isNull && defaultValue !== undefined ) {
73
+ coercedValues [ name ] = defaultValue ;
74
+ continue ;
75
+ }
76
+ } else if ( defaultValue !== undefined ) {
77
+ coercedValues [ name ] = defaultValue ;
78
+ continue ;
79
+ } else if ( isNonNullType ( argType ) ) {
80
+ throw createGraphQLError (
81
+ `Argument "${ name } " of required type "${ inspect ( argType ) } " ` +
82
+ `was provided the variable "$${ variableName } " which was not provided a runtime value.` ,
83
+ { nodes : valueNode } ,
84
+ ) ;
85
+ } else {
76
86
continue ;
77
87
}
78
- isNull = variableValues [ variableName ] == null ;
79
88
}
80
89
81
90
if ( isNull && isNonNullType ( argType ) ) {
@@ -87,7 +96,10 @@ export function getArgumentValues(
87
96
) ;
88
97
}
89
98
90
- const coercedValue = valueFromAST ( valueNode , argType , variableValues ) ;
99
+ const coercedValue = valueFromAST ( valueNode , argType , {
100
+ ...variableValues ,
101
+ ...fragmentArgValues ,
102
+ } ) ;
91
103
if ( coercedValue === undefined ) {
92
104
// Note: ValuesOfCorrectTypeRule validation should catch this before
93
105
// execution. This is a runtime check to ensure execution does not
0 commit comments