question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

graphQLErrors is empty in promise chain

See original GitHub issue

i 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:

image

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:closed
  • Created 6 years ago
  • Reactions:18
  • Comments:25 (1 by maintainers)

github_iconTop GitHub Comments

15reactions
Mati365commented, Jul 2, 2018

I found simple fix: err.networkError.result.errors, invoking it in catch() handlers will fix problem

14reactions
jbaxleyiiicommented, Jul 9, 2019

Thanks 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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found