graphQLErrors is empty in promise chain
See original GitHub issuei am using apollo-client@2.0.4 standalone with the basic setup:
const graphLink = new HttpLink({ uri: 'http://localhost:4001/graphiql' })
const errorLink = onError(({ graphQLErrors }) => {
if (graphQLErrors) {
graphQLErrors.map(
({ message, path, detail }) =>
> graphQLErrors has value here
debug(`[GraphQL error-- ]: ${path} ${message} ${detail}`)
)
}
})
const link = ApolloLink.from([errorLink, graphLink])
const client = new ApolloClient({
link,
cache: new InMemoryCache(),
})
the graphQLErrors result in onError block is right. this is the grahql-playground result:
but the graphQLErrors is empty in the promise-catch block
const QUERY = `
{
allUsers2 {
entries {
username
}
totalCount
pageSiz
}
}
`
const query = gql`
${QUERY}
`
client
.query({
query,
context,
})
.then(data => {
debug(data)
})
.catch(({ graphQLErrors, message }) => {
if (graphQLErrors) {
> graphQLErrors is Empty here
/* debug('【catch graphQLErrors:】 ', graphQLErrors) */
}
})
Issue Analytics
- State:
- Created 6 years ago
- Reactions:18
- Comments:25 (1 by maintainers)
Top Results From Across the Web
Why graphQLErrors are always empty in react components?
I want to show some errors that comes from graphql server to user. Have some component with callback that use some mutation onSave()...
Read more >Handling operation errors - Apollo GraphQL Docs
As a recommended first step, you can add an onError link to your link chain that receives error details and acts on them...
Read more >GraphQL error handling to the max with Typescript, codegen ...
We define a BaseError interface that all concrete Errors implement. Then, we define the query result as a Union type of the expected...
Read more >Top GraphQL Errors and How to fix them
When there is a network error while trying to contact a GraphQL server, due to either the server being down or timeouts etc,...
Read more >GraphQL specification
Otherwise, if the field is not required, then no entry is added to the coerced unordered map. If the value null was provided...
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 found simple fix:
err.networkError.result.errors
, invoking it in catch() handlers will fix problemThanks for reporting this. There hasn’t been any activity here in quite some time, so we’ll close this issue for now. If this is still a problem (using a modern version of Apollo Client), please let us know. Thanks!