graphQLErrors not populated in thrown ApolloError during 400 NetworkError
See original GitHub issueThe graphQlErrors
property of ApolloError
is not populated with the error details when a schema required field is not supplied during a mutation. However, the error is sent correctly to onError()
.
Intended outcome:
ApolloError.graphQLErrors
to be populated with the GraphQL error information
Actual outcome:
ApolloError.graphQLErrors
is an empty array
How to reproduce the issue:
- Begin with the schema:
type Mutation {
someAction(requiredParam: String!): Boolean
}
- Use
apolloClient.mutate(...)
to callsomeAction
without specifying therequiredParam
- In the thrown
ApolloError
, only thenetworkError
property is set.- The
networkError
is:ServerError: Response not successful: Received status code 400
. - The
graphQLErrors
is not set.
- The
- However, when using
onError
inapollo-link-error
, both thenetworkError
and thegraphQLErrors
properties are populated correctly.
Versions
System:
OS: Linux 4.19 Ubuntu 18.04.3 LTS (Bionic Beaver)
Binaries:
Node: 12.13.0 - /usr/bin/node
Yarn: 1.22.4 - ~/.yarn/bin/yarn
npm: 6.12.0 - /usr/bin/npm
Browsers:
Chrome: 81.0.4044.113
npmPackages:
apollo-cache-inmemory: ^1.6.5 => 1.6.5
apollo-client: ^2.6.8 => 2.6.8
apollo-link-error: ^1.1.13 => 1.1.13
apollo-link-http: ^1.5.17 => 1.5.17
apollo-server: ^2.12.0 => 2.12.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Handling operation errors - Apollo GraphQL Docs
If the response includes GraphQL errors, they are returned on error.graphQLErrors and the response data is set to undefined even if the server...
Read more >GraphQL Error Handling with ApolloClient and Apollo-Server ...
This is by design. From the docs: graphQLErrors: An array of errors from the GraphQL endpoint; networkError: Any error during the link ...
Read more >Handling Errors with Apollo Client (React) - YouTube
In this video I talk about handling errors when running queries and ... and networkError ) 10:04 Handling GraphQL errors when running a...
Read more >Hygraph error codes
400 errors are typically thrown when there is a client-side validation error, such as a missing required argument in your GraphQL query, or...
Read more >Automatically handling Apollo Client errors in your React UI
The graphQLErrors property that it provides to the onError error link will be populated with the errors, but the data will be undefined...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can confirm that this happens in version
3.2.5
as well. ThegraphQLErrors
are present in custom theonError(({ graphQLErrors, networkError })
link, but when it is read within theerror
object via auseMutation
hook within a component, it is set to an empty array[]
😢@hwillson Here it is: https://codesandbox.io/s/hardcore-snyder-kifgs?file=/src/App.js
If you were to add an
ErrorLink
into the ApolloClient you would also see thatGraphQLErrors
is correctly populated. It’s only after the errors get basically wrapped by aServerError
inHttpLink
they get lost deeper down in the error object.