Description
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?