-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
New rule request: union subtypes with conflicting field value type #2008
Comments
Accepted, this seems could be fixed by integrating federation validation rules into graphql-eslint #1824 If somebody want to give a try to integrate it, feel free, i’ll review it |
@caccialdo After some searching, seems your lint error in Apollo Studio goes not from federation rules but from graphql-js rules, use @graphql-eslint/overlapping-fields-can-be-merged rule and you can try it in playground https://the-guild.dev/graphql/eslint/play?or=overlapping-fields-can-be-merged |
Thanks @dimaMachina ! It does look like this is the linting rule used in the playground indeed (cf. original screenshot in the ticket description). I'll look into leveraging it in our clients. I think the feature request is still valid though as enforcing it on the server-side at the schema level (vs. operation level) would be valuable for clients lacking linting capabilities. |
@caccialdo this rule is accepted, if you want you can work on it and send a PR |
Thanks! I'll give it a shot in the new year if nobody attempts it before me |
Is your feature request related to a problem? Please describe.
When 2 subtypes of the same union type share a field but with a different value type, it's possible to run into query-time errors like below if the client doesn't alias the field with conflicting value types:
Minimal reproducible setup where a
Book
is either aNovel
or aPoem
but theirid
field isDrn
andInt
respectively.Sample schema
Describe the solution you'd like
Creating such scenario in a schema isn't forbidden per se but it would be nice to have the option of enforcing a linting rule preventing it in the first place. The rule would suggest renaming the field(s) in the conflicting subtype(s).
Describe alternatives you've considered
apollographql/eslint-plugin-graphql
but the tool is also missing a rule for this scenario.Additional context
–
The text was updated successfully, but these errors were encountered: