You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
require-selections does not check all possible types of union types #2963
1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox
2. A failing test has been provided
3. A local solution has been provided
4. A pull request is pending review
Describe the bug
This feels related to #2318, only with inline fragments. On a union type where at least one selected type selects an available id, all other selected types are not all checked.
To Reproduce Steps to reproduce the behavior: npm run lint in this stackblitz summarized below:
typeUser {
id: IDname: String
}
typePost {
id: IDtitle: String
}
unionUserOrPost = User | PosttypeQuery {
user: UseruserOrPost: UserOrPost
}
query {
userOrPost {
...onUser { id }
# no error reported, though inline fragment does not select `id` from Post...onPost { title }
}
}
Expected behavior
All available id fields are required to be selected from all types of a union that make one available
Environment:
OS: Linux
@graphql-eslint/eslint-plugin: 4.4.0
Node.js: 22.22.3
Additional context
This is an edge case that we found at Twitch some years back and I added support for it to our custom gql validation tooling. I'd like to migrate off that custom stack to this eslint plugin, but this is a gap in coverage that we need to fix first. I'll be following this up with a PR shortly.
Activity