Skip to content
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

How to pass graphQLErrors to component? #2880

Closed
gilbert opened this issue Jan 17, 2018 · 3 comments
Closed

How to pass graphQLErrors to component? #2880

gilbert opened this issue Jan 17, 2018 · 3 comments

Comments

@gilbert
Copy link

gilbert commented Jan 17, 2018

I'm trying to set up apollo to handle 401 errors in my apollo react component. Here's what I have so far.

My setup looks something like the following. On a 401, graphQLErrors is populated within the onError link. Good so far.

var link = ApolloLink.from([
  onError(({networkError, graphQLErrors}) => {
    graphQLErrors //=> Populated! This is good.
  }),
  new HttpLink({...})
])

However, when I receive the error in a react component, graphQLErrors is empty! Like so:

export const USER_QUERY = gql`query {
  signed_in_user { id, name }
}`

const withUserData = graphql(USER_QUERY, {
  options: {
    errorPolicy: 'all'
  }
})

export default Component => withUserData( props => {
  var { data: { loading, error, self } } = props

  if (loading) return <div>Loading...</div>
  if (error) {
    error.graphQLErrors //=> Empty! :(
  }
  return <div>Loaded.</div>
})

Is there a way to pass the populated graphQLErrors array to the component? Thanks.

Version

  • apollo-client-preset@1.0.6
@gilbert
Copy link
Author

gilbert commented Jan 19, 2018

Any ideas on this? I spent the time updating to apollo 2.0, and this is the last missing piece. I hope I don't have to revert to 1.x =/

@KevinHewson
Copy link

I'm having the same issue as this. Any updates? It looks like the error exists in the networkErrors but not in the graphQLErrors.

@hwillson
Copy link
Member

To help provide a more clear separation between feature requests / discussions and bugs, and to help clean up the feature request / discussion backlog, Apollo Client feature requests / discussions are now being managed under the https://github.com/apollographql/apollo-feature-requests repository.

This feature request / discussion will be closed here, but anyone interested in migrating this issue to the new repository (to make sure it stays active), can click here to start the migration process. This manual migration process is intended to help identify which of the older feature requests are still considered to be of value to the community. Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants