-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ErrorOr
does not support null value and ignorable errors
#2050
Comments
I think that receiving a
This is correct I think because of how GraphQL works. If there's an error on that path, there can be no (non-null) value AFAIK. |
I agree that we should patch |
... actually you should read it as "there is no error but the value |
Yes, and since It's possible to have both a value and an error, especially in the case of field errors: https://spec.graphql.org/draft/#sel-HAPHRPNBDAAADdABjoF {
hero(episode: $episode) {
name
heroFriends: friends {
id
name
}
}
} {
"errors": [
{
"message": "Name for character with ID 1002 could not be fetched.",
"locations": [{ "line": 6, "column": 7 }],
"path": ["hero", "heroFriends", 1, "name"]
}
],
"data": {
"hero": {
"name": "R2-D2",
"heroFriends": [
{
"id": "1000",
"name": "Luke Skywalker"
},
{
"id": "1002",
"name": null
},
{
"id": "1003",
"name": "Leia Organa"
}
]
}
}
} @GraphQLClientApi
public interface StarWarsApi {
ErrorOr<Hero> hero(@Name("episodeId") String episodeId);
} In this case I would |
In your example, you should place your |
But I don't want an exception, I want the partial response and the errors. |
The |
I've created a PR, but I don't see the GitHub Action running. Is this new? |
It builds when I create a correct PR 😳 sorry |
I'm using the type-safe API and trying to use
ErrorOr
. In my case, the query can return anull
value (if not found). Sometimes it also returns an error on some random (nested) field, which I would like to log.When using
ErrorOr
I get an exceptionvalue must not be null
, because ErrorOr usesrequireNonNull
. It also does not allow access to the value if there are any errors.Since this class really assumes there is either a value or an error, I'm hesitant to patch it to allow null values. It would probably be better to create a new type that allows access to both without making assumptions.
The text was updated successfully, but these errors were encountered: