diff --git a/src/execution/__tests__/variables-test.ts b/src/execution/__tests__/variables-test.ts index de60ea674e..7fe5a8a10d 100644 --- a/src/execution/__tests__/variables-test.ts +++ b/src/execution/__tests__/variables-test.ts @@ -1515,6 +1515,20 @@ describe('Execute: Handles inputs', () => { }); }); + it('when argument passed to a directive on a nested field', () => { + const result = executeQueryWithFragmentArguments(` + query { + ...a(value: true) + } + fragment a($value: Boolean!) on TestType { + nested { echo(input: "echo") @skip(if: $value) } + } + `); + expect(result).to.deep.equal({ + data: { nested: {} }, + }); + }); + it('when a nullable argument to a directive with a field default is not provided and shadowed by an operation variable', () => { // this test uses the @defer directive and incremental delivery because the `if` argument for skip/include have no field defaults const document = parse( diff --git a/src/execution/collectFields.ts b/src/execution/collectFields.ts index 94dd2b50bd..9146312f70 100644 --- a/src/execution/collectFields.ts +++ b/src/execution/collectFields.ts @@ -56,7 +56,6 @@ interface CollectFieldsContext { schema: GraphQLSchema; fragments: ObjMap; variableValues: { [variable: string]: unknown }; - fragmentVariableValues?: FragmentVariables; operation: OperationDefinitionNode; runtimeType: GraphQLObjectType; visitedFragmentNames: Set; @@ -135,14 +134,16 @@ export function collectSubfields( const newDeferUsages: Array = []; for (const fieldDetail of fieldGroup) { - const node = fieldDetail.node; - if (node.selectionSet) { + const selectionSet = fieldDetail.node.selectionSet; + if (selectionSet) { + const { deferUsage, fragmentVariables } = fieldDetail; collectFieldsImpl( context, - node.selectionSet, + selectionSet, subGroupedFieldSet, newDeferUsages, - fieldDetail.deferUsage, + deferUsage, + fragmentVariables, ); } }