Node ID
annotation errors
Description
This error is thrown when a relay.Node
implemented type canβt resolve its id
field, due to it being missing or multiple annotated fields being found.
The following code will throw this error:
import strawberryfrom strawberry import relay
@strawberry.typeclass Fruit(relay.Node): code: str name: str
This happens because relay.Node
donβt know which field should be used to
resolve to generate its GlobalID
field.
The following would also throw this errors because multiple candidates were found:
import strawberryfrom strawberry import relay
@strawberry.typeclass Fruit(relay.Node): code: relay.NodeID[str] name: relay.NodeID[str]
How to fix this error
When inheriting from relay.Node
, you should annotate exactly one NodeID
field in the type, like:
import strawberryfrom strawberry import relay
@strawberry.typeclass Fruit(relay.Node): code: relay.NodeID[str] name: str