js-graphql-intellij-plugin
js-graphql-intellij-plugin copied to clipboard
Merging schema causes the error "... tried to redefine existing type Mutation"
Describe the bug When using the graphql-tools mergeSchemas function and presumably other tools that provide the same function, the error "... tried to redefine existing type Mutation" is set when mutations are defined in separate locations.
To Reproduce
- Create two mutations in separate statements.
- Use graphQlTools.mergeSchemas() to merge the two mutations.
- Observe the error.
Expected behavior An option should be provided to disable this error.
I had exactly same problem, but I found this example and everything works great now! For more info please take a look into docs.
Add the generated schema as Excluded with right click and Mark as > Excluded
I have dozens of files that define mutations or queries with
gql`
type Mutation {
zhuliDoTheThing(...) Varrik
}
`;
I do not have generated schema.
The plugin flags all of them with errors. Excluding the majority of my schema removes the usefulness of the plugin, and I'm not restructuring my project to make this plugin happy. I have instead removed the plugin.
@bumpusfrancus I'm preparing a new v3 release now, where it would be possible to disable these inspections (type redefinitions and field redefinitions) completely or suppress on a file/definition level with a comment. It's a bit experimental and not guaranteed to work excellent because the release is huge, but it should help in a case like yours. So, give it a try when it will be released pls 🙏 . I hope a release will happen the next week.
Thanks @vepanimas. I was really impressed with how smoothly the plugin worked in general, and if my project had a more conventional structure I would have loved to use it. Thanks for all your hard work.
We're facing the same issue. Did anyone manage to solve it?
Hi @bfelbo! You can try to disable that kind of error completely now. Conflicting declarations will be merged under the hood and it should work:
That's perfect, thanks for the quick response @vepanimas!
Is there a way to add this into the GraphQL config file? Otherwise anyone else on the project will have to go edit this in their settings.
@bfelbo in general, settings (e.g., inspection profiles, code style) are under the .idea folder. So you can commit inspectionProfiles
to the repo and you will have the same configuration for the whole team.
![commit settings](https://user-images.githubusercontent.com/10243762/145457155-09dad18e-f0ff-4e5c-8596-f849ee092c6d.png)
Ah, that makes sense. I'm just starting to use IntelliJ IDEs so that was likely a noob question. Thanks for explaining this in detail!