Skip to content

Commit a19e2ca

Browse files
committed
add additional nested fragment tests
1 parent 2d354bc commit a19e2ca

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/execution/__tests__/variables-test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,46 @@ describe('Execute: Handles inputs', () => {
11891189
});
11901190
});
11911191

1192+
it('when a value is required and provided, and the definition spreads another fragment', () => {
1193+
const result = executeQueryWithFragmentArguments(`
1194+
query {
1195+
...a(value: "A")
1196+
}
1197+
fragment a($value: String!) on TestType {
1198+
...b(value: $value)
1199+
}
1200+
fragment b($value: String!) on TestType {
1201+
fieldWithNonNullableStringInput(input: $value)
1202+
}
1203+
`);
1204+
expect(result).to.deep.equal({
1205+
data: {
1206+
fieldWithNonNullableStringInput: '"A"',
1207+
},
1208+
});
1209+
});
1210+
1211+
it('when a value is required and provided, and the definition uses the variable and spreads another fragment with a different value', () => {
1212+
const result = executeQueryWithFragmentArguments(`
1213+
query {
1214+
...a(value: "A")
1215+
}
1216+
fragment a($value: String!) on TestType {
1217+
...b(value: "B")
1218+
fieldInFragmentA: fieldWithNonNullableStringInput(input: $value)
1219+
}
1220+
fragment b($value: String!) on TestType {
1221+
fieldInFragmentB: fieldWithNonNullableStringInput(input: $value)
1222+
}
1223+
`);
1224+
expect(result).to.deep.equal({
1225+
data: {
1226+
fieldInFragmentA: '"A"',
1227+
fieldInFragmentB: '"B"',
1228+
},
1229+
});
1230+
});
1231+
11921232
it('when a value is required and not provided', () => {
11931233
const result = executeQueryWithFragmentArguments(`
11941234
query {

0 commit comments

Comments
 (0)