You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ObjectType.resolve_type classmethod makes it impossible to have a field named 'type' #50
The resolve_type method on ObjectType conflicts with actually resolving a field called type. Given the importance of resolve method names, I think great care should be taken to make sure graphene's codebase does not use these method names unless necessary.
The below test fails with GraphQLError("'Location' object has no attribute 'T'",); renaming the resolve_type method to _resolve_type solves the problem.
@syrusakbary should probably rename the function to _resolve_type and do it soon since it's now documented. I guess it's technically a breaking change but I don't think it's extensively used so we can probably get away with releasing it in 2.2 version
Using type as a variable is an anti-pattern in Python as it overwrites a built-in function, not to mention the use of type in GraphQL Schemas. The better alternative, in my opinion, would be to rename the field as location_type or type_.
Using type as a variable in Python code and using type as a field in a schema to send data between several systems, many of which may not be written in Python, are two different scenarios.
Reacted by Wei Yen, Tomáš Linhart and Pearce Hayward
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
syrusakbary commentedon Nov 25, 2015
Thanks for such a detailed example @inklesspen.
Will fix this in the next commit.
Merge pull request graphql-python#50 from yamat124/master
svilendobrev commentedon Jun 21, 2018
this is still a problem on graphene.Interface - resolve_type is a classmethod there..
jkimbo commentedon Jun 21, 2018
Ha, that is a good point @svilendobrev !
@syrusakbary should probably rename the function to
_resolve_typeand do it soon since it's now documented. I guess it's technically a breaking change but I don't think it's extensively used so we can probably get away with releasing it in 2.2 versioncherls commentedon Nov 22, 2018
Using type as a variable is an anti-pattern in Python as it overwrites a built-in function, not to mention the use of
typein GraphQL Schemas. The better alternative, in my opinion, would be to rename the field aslocation_typeortype_.inklesspen commentedon Nov 22, 2018
Using type as a variable in Python code and using type as a field in a schema to send data between several systems, many of which may not be written in Python, are two different scenarios.
stale commentedon Jul 29, 2019
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.