dotansimha / graphql-code-generator-community

MIT License
112 stars 143 forks source link

[RTK-Query] Hook generator does not match InjectedAPI typings when typings are not in pascalCase #705

Open charlieforward9 opened 4 months ago

charlieforward9 commented 4 months ago

Which packages are impacted by your issue?

@graphql-codegen/typescript-rtk-query

Describe the bug

Either straight up remove or add a toggle to disable the automatic pascal-casing that the hook is given, which conflicts with the injectedRtkApi.

For example, I have a graphql query named ordersByAccountID, but then the hook generates as getOrderesByAccountIdQuery, throwing an error because the D is generated as lowercase, when the API object returns it as a capitalized D.

Your Example Website or App

https://stackblitz.com/~/github.com/charlieforward9/graphql-codegen-typescript-rtk-query-hook-name-bug

Steps to Reproduce the Bug or Issue

  1. Go to types.ts
  2. See comment on bottom line about changing the singular character to fix the problem

Experiment changing the config.namingConvention, I was unable to figure it out with this.

Expected behavior

I expect to either, either:

I just read that Pascal Case is industry standard, but I do also find it helpful to allow developers to customize to their liking if the config's are already there

Screenshots or Videos

Screenshot 2024-05-07 at 3 34 16 AM

This is the problem as it appears in our full scale codebase - many operations are showing as errors due to ending with ID

Platform

Codegen Config File

No response

Additional context

No response

charlieforward9 commented 4 months ago

I was able to work around this by changing my schema to conform to pascalCase. However, I believe this is a limitation of the parser that should be AT LEAST mentioned as a limitation.