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
So here my example with SQLModel class SomeExtensionSQLModel witch transforms to strawberry.typeSomeExtension by using strawberry.experimental.pydantic.type decorator
import strawberry
from dataclasses import dataclass
from sqlmodel import SQLModel
class SomeExtensionSQLModel(SQLModel):
login: str
@strawberry.experimental.pydantic.type(SomeExtensionSQLModel, all_fields=True)
class SomeExtension:
...
@dataclass
class UserRow(SomeExtension):
id_: str
@strawberry.type
class User(SomeExtension):
@strawberry.field
@staticmethod
async def name(parent: strawberry.Parent[UserRow]) -> str:
return f"User Number {parent.id_}"
@strawberry.type
class Query:
@strawberry.field
def user(self) -> User:
return UserRow(id_="1234", login='123')
And I got error:
Traceback (most recent call last):
File "/Users/19653277/Library/Caches/pypoetry/virtualenvs/datamarket-backend-NWPanlm1-py3.10/lib/python3.10/site-packages/graphql/execution/execute.py", line 540, in execute_field
completed = self.complete_value(
File "/Users/19653277/Library/Caches/pypoetry/virtualenvs/datamarket-backend-NWPanlm1-py3.10/lib/python3.10/site-packages/graphql/execution/execute.py", line 612, in complete_value
completed = self.complete_value(
File "/Users/19653277/Library/Caches/pypoetry/virtualenvs/datamarket-backend-NWPanlm1-py3.10/lib/python3.10/site-packages/graphql/execution/execute.py", line 650, in complete_value
return self.complete_object_value(
File "/Users/19653277/Library/Caches/pypoetry/virtualenvs/datamarket-backend-NWPanlm1-py3.10/lib/python3.10/site-packages/graphql/execution/execute.py", line 924, in complete_object_value
raise invalid_return_type_error(return_type, result, field_nodes)
graphql.error.graphql_error.GraphQLError: Expected value of type 'User' but got: <UserRow instance>```
But if the class SomeExtension declared like this:
@strawberry.type
class SomeExtension:
login: str
everything is alright
Upvote & Fund
We're using Polar.sh so you can upvote and help fund this issue.
We receive the funding once the issue is completed & confirmed by you.
Thank you in advance for helping prioritize & fund our backlog.
The text was updated successfully, but these errors were encountered:
Hi everyone!
I found in docs example of using type Parent https://strawberry.rocks/docs/types/resolvers#defining-resolvers-as-methods, so I followed the docs and saw that it works only @strawberry.type
So here my example with SQLModel class
SomeExtensionSQLModel
witch transforms tostrawberry.type
SomeExtension
by usingstrawberry.experimental.pydantic.type
decoratorAnd I got error:
But if the class
SomeExtension
declared like this:everything is alright
Upvote & Fund
The text was updated successfully, but these errors were encountered: