11---
2- title : Relay wrong resolver annotation Error
2+ title : Connection wrong resolver annotation Error
33---
44
5- # Relay wrong resolver annotation error
5+ # Connection wrong resolver annotation error
66
77## Description
88
9- This error is thrown when a field on a relay connection was defined with a
10- resolver that returns something that is not compatible with pagination.
9+ This error is thrown when a field on a connection was defined with a resolver
10+ that returns something that is not compatible with pagination.
1111
1212For example, the following code would throw this error:
1313
1414``` python
1515from typing import Any
1616
1717import strawberry
18- from strawberry import relay
18+ from strawberry.pagination import connection
1919
2020
2121@strawberry.type
22- class MyType (relay . Node ): ...
22+ class MyType (Node ): ...
2323
2424
2525@strawberry.type
2626class Query :
27- @relay. connection (relay. Connection[MyType])
27+ @connection (Connection[MyType])
2828 def some_connection_returning_mytype (self ) -> MyType: ...
2929
30- @relay. connection (relay. Connection[MyType])
30+ @connection (Connection[MyType])
3131 def some_connection_returning_any (self ) -> Any: ...
3232```
3333
@@ -53,22 +53,22 @@ For example:
5353from typing import Any
5454
5555import strawberry
56- from strawberry import relay
56+ from strawberry.pagination import connection, Connection
5757
5858
5959@strawberry.type
60- class MyType ( relay . Node ) : ...
60+ class MyType : ...
6161
6262
6363@strawberry.type
6464class Query :
65- @relay. connection (relay. Connection[MyType])
65+ @connection (Connection[MyType])
6666 def some_connection (self ) -> Iterable[MyType]: ...
6767```
6868
6969<Note >
7070 Note that if you are returning a type different than the connection type, you
7171 will need to subclass the connection type and override its ` resolve_node `
72- method to convert it to the correct type, as explained in the [ relay
73- guide] ( ../guides/relay ) .
72+ method to convert it to the correct type, as explained in the [ pagination
73+ guide] ( ../guides/pagination ) .
7474</Note >
0 commit comments