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

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

Open
2 tasks
charlieforward9 opened this issue May 7, 2024 · 1 comment

Comments

@charlieforward9
Copy link

charlieforward9 commented May 7, 2024

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:

  • Get a hook that matches the default value of the GraphQL operation
  • Have the ability to modify the hook naming convention with the config.namingConvention object.

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

  • OS: macOS
  • NodeJS: 20.0.9
  • graphql version: 16.8.1
  • @graphql-codegen/cli: 5.0.2
  • @graphql-codegen/typescript-rtk-query: ^3.1.1

Codegen Config File

No response

Additional context

No response

@charlieforward9 charlieforward9 changed the title [RTK-Query] InjectedAPI does not properly name hooks [RTK-Query] Hook generator does match InjectedAPI typings May 7, 2024
@charlieforward9
Copy link
Author

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.

@charlieforward9 charlieforward9 changed the title [RTK-Query] Hook generator does match InjectedAPI typings [RTK-Query] Hook generator does not match InjectedAPI typings May 7, 2024
@charlieforward9 charlieforward9 changed the title [RTK-Query] Hook generator does not match InjectedAPI typings [RTK-Query] Hook generator does not match InjectedAPI typings when typings are not in pascalCase May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant