Skip to content

Fix overlapping fields validator edge case #1497

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

Open
wants to merge 7 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,34 @@ describe('Validate: Overlapping fields can be merged', () => {
);
});

it('allows different args where no conflict is possible on fragments', () => {
// This is valid since no object can be both a "Dog" and a "Cat", thus
// these fields can never overlap.
expectPassesRule(
OverlappingFieldsCanBeMerged,
`
{
pet {
... on Dog {
...X
}
... on Cat {
...Y
}
}
}

fragment X on Pet {
name(surname: true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example currently fails on the Facebook GraphQL server (which does not depend on graphql-js for validation).

I would need to think about this example and whether it can be valid. I'm not sure whether it's a bug in both graphql-js and the Facebook server, or if it's intended behavior.

}

fragment Y on Pet {
name
}
`,
);
});

it('different args, second missing an argument', () => {
expectFailsRule(
OverlappingFieldsCanBeMerged,
Expand Down
Loading