Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnwalraven committed Jun 10, 2021
1 parent dd9b1e7 commit 14acb4c
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions gateway-js/src/__tests__/executeQueryPlan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1118,4 +1118,64 @@ describe('executeQueryPlan', () => {
}
`);
});

it(`can execute queries with @include on inline fragment with extension field`, async () => {
const operationString = `#graphql
query {
topProducts(first: 5) {
... on Book @include(if: true) {
price
inStock
}
... on Furniture {
price
inStock
}
}
}
`;

const operationDocument = gql(operationString);

const operationContext = buildOperationContext({
schema,
operationDocument,
});

const queryPlan = queryPlanner.buildQueryPlan(operationContext);

const response = await executeQueryPlan(
queryPlan,
serviceMap,
buildRequestContext(),
operationContext,
);

expect(response.data).toMatchInlineSnapshot(`
Object {
"topProducts": Array [
Object {
"inStock": true,
"price": "899",
},
Object {
"inStock": false,
"price": "1299",
},
Object {
"inStock": true,
"price": "54",
},
Object {
"inStock": true,
"price": "39",
},
Object {
"inStock": false,
"price": "29",
},
],
}
`);
});
});

0 comments on commit 14acb4c

Please sign in to comment.