Skip to content
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: Duplicate fields in schema #670

Open
tvvignesh opened this issue Oct 6, 2021 · 1 comment
Open

New rule: Duplicate fields in schema #670

tvvignesh opened this issue Oct 6, 2021 · 1 comment
Assignees
Labels
new rule status/parked This task has been temporarily parked - No work is currently underway

Comments

@tvvignesh
Copy link
Contributor

Is your feature request related to a problem? Please describe.

When I duplicate fields in my schema and use codegen, I get errors like these:
image

Looks like this error is coming in from graphql-js and not codegen itself. But I don't find a rule for duplicated fields (in schema) as a rule. There is a rule for documents though.

Describe the solution you'd like
Adding a new rule for duplicated fields in schema in graphql-eslint can address this.

Describe alternatives you've considered
Alternative currently is to rely on codegen for throwing errors like these, but this can be captured in eslint itself.

@dimaMachina
Copy link
Collaborator

dimaMachina commented Oct 14, 2021

Hi @tvvignesh, currently buildSchema from graphql throws an error when find a duplicated field for ObjectTypeDefinition, InterfaceTypeDefinition, EnumTypeDefinition, InputObjectTypeDefinition kinds and same for their extensions ObjectTypeExtension... etc.
I agree with you, we can validate duplication fields before building our schema, the new rule or new option for the existing rule avoid-duplicate-fields will be added 😉

UPDATE:
We have already rules from graphql-js that checks for duplication fields, like unique-field-definition-names, unique-input-field-names, unique-enum-value-names and they work not as expected, when you have split schema for multiple files, I'll try to fix this

@dimaMachina dimaMachina added the status/parked This task has been temporarily parked - No work is currently underway label Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new rule status/parked This task has been temporarily parked - No work is currently underway
Development

No branches or pull requests

2 participants