Skip to content

fix(validation): catch OverlappingFieldsCanBeMergedRule violations with nested fragments #4168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,33 @@ describe('Validate: Overlapping fields can be merged', () => {
]);
});

it('reports deep conflict after nested fragments', () => {
expectErrors(`
fragment F on T {
...G
}
fragment G on T {
...H
}
fragment H on T {
x: a
}
{
x: b
...F
}
`).toDeepEqual([
{
message:
'Fields "x" conflict because "b" and "a" are different fields. Use different aliases on the fields to fetch both if this was intentional.',
locations: [
{ line: 12, column: 9 },
{ line: 9, column: 9 },
],
},
]);
});

it('ignores unknown fragments', () => {
expectValid(`
{
Expand Down Expand Up @@ -1138,4 +1165,31 @@ describe('Validate: Overlapping fields can be merged', () => {
},
]);
});

it('does not infinite loop on recursive fragments separated by fields', () => {
expectValid(`
{
...fragA
...fragB
}

fragment fragA on T {
x {
...fragA
x {
...fragA
}
}
}

fragment fragB on T {
x {
...fragB
x {
...fragB
}
}
}
`);
});
});
Loading
Loading