Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why graphQLErrors are always empty in react components?

Tags:

I want to show some errors that comes from graphql server to user.

Have some component with callback that use some mutation

onSave() => {
    this.props.mutate({
        mutation: CHANGE_ORDER_MUTATION,
        variables: {
            ids,
        },
    }).catch((e) => {
        console.log(e.graphQLErrors) <--- e.graphQLErrors is always empty array = []
    })
}

While I'm able to see the graphQLErrors error with apollo-link-error link.

const errorLink = onError(({ graphQLErrors, networkError }) => { console.log(graphQLErrors) <--- errors from server });

like image 955
comalex3 Avatar asked Mar 13 '19 17:03

comalex3


1 Answers

Migration to apollo-server instead of express-graphql solve the problem.

Or you can access errors by e.networkError.result.errors

like image 63
comalex3 Avatar answered Oct 11 '22 17:10

comalex3