Schema:
async def load_sub_field() -> SubField:
return SubField(id=1, name="name")
@strawberry.type
class FieldResponse:
id: str
name: str
@strawberry.field
async def sub_field(self, root: Any, info: Info) -> SubField:
print("Sub field initiated...")
loader = DataLoader(load_fn=load_sub_field)
response = await loader.load(key=root.field_id)
return response
@strawberry.type
class Query:
@strawberry.field
def get_field(self, info, params: FieldParams) -> FieldResponse:
response = resolve_my_field()
return response
Query:
query GetField($params: FieldParams!) {
getField(params: $params) {
__typename
... on FieldResponse {
name
Id
subField {
name
}
}
}
}
Response:
{
"errors": [
{
"message": "Unexpected token '<', \"<!DOCTYPE \"... is not valid JSON",
"stack": "SyntaxError: Unexpected token '<', \"<!DOCTYPE \"... is not valid JSON"
}
]
}
Additional Info:
Sub field initiated
log but when I remove the async from the method sub_field
I'm at least getting this logsub_field
field from the Schema, it works fine, and getting the FieldResponse
Am I doing anything wrong?
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too