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
|
---
title: Missing field annotation Error
---
# Missing field annotation Error
## Description
This error is thrown when a field on a class is missing an annotation, for
example the following code will throw this error:
```python
import strawberry
@strawberry.type
class Query:
name: str
age = strawberry.field(
name="ageInYears"
) # note that here we don't have a type for this field
schema = strawberry.Schema(query=Query)
```
This happens because Strawberry needs to know the type of every field for a type
to be able to generate the correct GraphQL type.
## How to fix this error
You can fix this error by adding an annotation to the field, for example, the
following code will fix this error:
```python
import strawberry
@strawberry.type
class Query:
name: str
age: int = strawberry.field(name="ageInYears")
schema = strawberry.Schema(query=Query)
```
|