eddeee888 / graphql-code-generator-plugins

List of GraphQL Code Generator plugins that complements the official plugins.
MIT License
44 stars 10 forks source link

Remove prefix in generated resolvers file? #227

Open alecrobertson1 opened 5 months ago

alecrobertson1 commented 5 months ago

The resolvers fill imports the queries and mutations with aliases

Screenshot 2024-01-30 at 17 21 12

but this seems redundant as they just get assigned with the original names again:

Screenshot 2024-01-30 at 17 21 27

Can this feature be customised or removed?

eddeee888 commented 4 months ago

Hi @alecrobertson1 ,

Unfortunately, we to alias resolvers with its "location" (in this case Query_*) so it's uniquely named in the file. Otherwise, there could be a rare scenario where a query and a mutation may have the same name e.g.

extend type Query {
  book(id: ID!): BookPayload!
}
extend type Mutation {
  book(id: ID!): BookPayload!
}

This does not happen in every GraphQL schema. But the current implementation avoids it in the simplest way possible, making the codegen implementation easy to manage. 🙂


Is it causing issues in your codebase or is it just a stylistic concern?