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
You can avoid such naming conflicts by using the name parameter. You just name the field differently, but pass name='type' in your field definition. So in your case:
classItem(Interface):
id=Int()
type_=Field(Color, name='type') # notice the underscore in type_@classmethoddefresolve_type_(cls, instance, info):
ifinstance.type==Color.red.value:
returnRedItemelifinstance.type==Color.green.value:
returnGreenItemelifinstance.type==Color.blue.value:
returnBlueItem
Typically, you can do the same for other names like id where pylint usually complains about using a reserved keyword as variable name.
@norman-thomas
The resolve_type of ObjectType has been rename to _resolve_type in 7340d80 。
I suggest that Interface.resolve_type can do the same thing to avoid such naming conflicts.
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.
The resolve_type method on Interface conflicts with actually resolving a field called type.
The below test fails with
GraphQLError('Expected a value of type "Color" but received: RedItem',)
.The text was updated successfully, but these errors were encountered: