strawberry
strawberry copied to clipboard
De-shadow resolver arguments that have the same name as builtin functions
this:
@strawberry.field
def my_resolver(self, id_: strawberry.ID) -> ...:
...
should change the id_ name to be id on the schema.
This should also work with arguments with the same name as Python keywords
Similar in function to #725. Potentially one of the solutions will rely on the other
Not sure this is a good idea because it feels like too much magic to me. What if you want to have an argument with a trailing underscore? I think being able to override the name of an argument (#725) is a better solution than automagically renaming arguments.
Would having this be a feature that can be enabled/disabled work?
Would having this be a feature that can be enabled/disabled work?
I think this might be a good trade-off.
By the way we should to the same for autoCamecasing, so we could do both at once (post-refactor I'd say).
What do you think @jkimbo?
Being able to enable/disable would definitely be better but I worry that itโs something that could cause some confusion when someone comes across it for the first time since itโs not that obvious. Maybe itโs opt in behaviour?
Yes, Iโd make it opt-in :)
This would be a great addition. Same issue with mutation arguments:
@strawberry.mutation
def order_create(input: OrderCreateInput) -> ...:
...
input is often used for mutations, which conflicts with Python's input() function.
@saschametz please have a look at https://github.com/strawberry-graphql/strawberry/issues/725. This should be supported already ๐
I'm going to close this issue, we have support for renaming arguments and we didn't have people asking for something like this ๐ We can always revisit it in future :)