Open DovydasNavickas opened 1 month ago
As discussed with @michaelstaib in Slack, there were 2 problems:
.AddQueryConventions()
while configuring the GraphQL server.[Error<ModifiedByUserNotFoundError>]
attribute on the resolver returning FieldResult<TResult>
Commit fixing both is here.
The only difference is the resulting query is now a union: And need to be queried as such:
query {
book {
id
title
createdBy {
id
name
}
modifiedBy {
... on Author { # <----------- query on successful result
id
name
}
...on ModifiedByUserNotFoundError { # <----------- query on specific error
message
}
...on Error { # <----------- query on any error
message
}
}
}
}
We also agreed that the error should be a schema error and not the one returned right now.
Product
Hot Chocolate
Version
14.0.0-rc.3.4
Link to minimal reproduction
https://github.com/MartynasZilinskas/hotchocolate-fieldresult-bug-repro/tree/main
Steps to reproduce
createdBy
resolver doesn't useFieldResult<TResult>
and returnsTResult
directly:modifiedBy
resolver returnsFieldResult<TResult>
:What is expected?
I expect
FieldResult<TResult>
to successfully return both in the root field resolver and in a non-root field resolver.What is actually happening?
Query:
Response:
Relevant log output
Additional context
No response