graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Error on duplicate queries/mutations defined in multiple resolvers

Open snawaz opened this issue 4 years ago • 2 comments

Is there an existing issue that is already proposing this?

  • [X] I have searched the existing issues

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

If two more resolvers define a query (or mutation) with same name, I dont get any error or even warning.

const schema = await gqlSchemaFactory.create([
  RecipesResolver,
  AuthorsResolver,
  PostsResolvers,
]);

Describe the solution you'd like

So can we please have a flag to detect duplicate queries/mutations and give errors accordingly?

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

Better diagnostics!

snawaz avatar Apr 20 '22 12:04 snawaz

Could you please provide a minimum reproduction repository? This will help us to fix & address this issue quicker

kamilmysliwiec avatar Apr 21 '22 09:04 kamilmysliwiec

Could you please provide a minimum reproduction repository? This will help us to fix & address this issue quicker

The code snippet I have shared in the original post is from the graphql docs itself. Here it is again:

const schema = await gqlSchemaFactory.create([
  RecipesResolver,
  AuthorsResolver,
  PostsResolvers,
]);

In this code, if two or more resolvers define a query (or a mutation) with same name, then the graphql code generator is not designed to give any error as of now. That is my concern. In my opinion, it should give an error.

snawaz avatar Apr 21 '22 10:04 snawaz