-
Notifications
You must be signed in to change notification settings - Fork 645
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
Regression after upgrading from 4.0.0-beta.2 to 4.0.0-beta.3 #5598
Comments
Hi 👋 This is intentional. Error handling in GraphQL is not easy but latest versions of 4.0.0 betas add support for nullability directives, which I hope can clarify the situation. Especially, if you want GraphQL errors to set # Import the `@catch` directive definition.
# When it is imported, parsers generate extra code to deal with errors.
extend schema @link(
url: "https://specs.apollo.dev/nullability/v0.1",
import: ["@catch", "CatchTo"]
)
# Errors stop the parsing. The data never contains error. Use `@catch` in operations to let partial data through
extend schema @catch(to: THROW) Hope this helps, let us know how that goes! PS: another good read about error handling is here |
Hi @martinbonnin 👋 Thank you for the quick response, if this is the intended behavior, I'll close the issue and update our error handling logic to take into account a |
👍 By default, I recommend handling errors like this: if (response.data != null) {
// Handle (potentially partial) data
} else {
// Something wrong happened
if (response.exception != null) {
// Handle non-GraphQL errors
} else {
// Handle GraphQL errors in response.errors
}
} This default exposes partial data which may make writing UI logic more cumbersome.
|
One more question: do you know if it could still happen that an instance of I just want to know if I need to do a check like this: response.exception == null && response.hasErrors() || response.exception is ApolloGraphQLException -> Err(AuthCallError.ApiError.Generic(last.errors?.map { it.message })) or if I can skip the |
PS: you can also drop the |
Version
4.0.0-beta.4 (the issue started with 4.0.0-beta.3)
Summary
After upgrading from
4.0.0-beta.2
our unit tests are failing because theapolloClient.enqueueTestResponse()
doesn't seem to work the same as before: when we enqueue an error theexception
property of the response is nownull
when, up to version4.0.0-beta.2
, it was set toApolloGraphQLException
.Is this change intentional?
Steps to reproduce the behavior
We are using the
apolloClient.enqueueTestResponse()
like this:Logs
No response
The text was updated successfully, but these errors were encountered: