1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
---
title: Node ID annotation error
---
# 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:
```python
import strawberry
from strawberry import relay
@strawberry.type
class 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:
```python
import strawberry
from strawberry import relay
@strawberry.type
class 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:
```python
import strawberry
from strawberry import relay
@strawberry.type
class Fruit(relay.Node):
code: relay.NodeID[str]
name: str
```
|