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

Field renaming causing collisions with names like "_id" #498

Open
TymanWasTaken opened this issue Oct 14, 2024 · 1 comment
Open

Field renaming causing collisions with names like "_id" #498

TymanWasTaken opened this issue Oct 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@TymanWasTaken
Copy link

I am trying to interface with the Canvas LMS GraphQL API, but when I try to create queries in rust with this library, there are name collisions between the id and _id fields present in most types (corresponding to two types of identifiers in the API). After a bit of investigating, it appears that the heck library used by this crate will rename _id to id when running to_snake_case():

Welcome to evcxr. For help, type :help
>> :dep heck
   Compiling heck v0.5.0
>> use heck::ToSnakeCase;
>> "_id".to_snake_case()
"id"

Then, this new name is blindly accepted by graphql-client regardless of if there is already a type named id in the query, causing compiler errors due to field redefinition. I can get around this for now by using the CLI to generate the types and then manually renaming the _id field, but it would be nice if graphql-client could recognize situations like this and adjust. I'm not sure what the best solution to this is, perhaps not renaming a field if doing so would cause a collision could be the simplest fix?

@tomhoule
Copy link
Member

Looks like a bug, thanks for reporting.

@tomhoule tomhoule added the bug Something isn't working label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants