Open unutoiul opened 4 years ago
const errorLink: any = onError( ({ operation, forward, graphQLErrors, networkError }) => { const { dispatchModal } = useContext<IModalContext>(ModalContext); console.log(operation); console.log(forward); if (graphQLErrors) { graphQLErrors.forEach(({ message, locations, path }) => console.log( `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}` ) ); } if (networkError) { console.log(`[Network error]: ${networkError}`); } } );
in the code above I will like to get set the useContext of another react component but I get
Error: Invalid hook call. Hooks can only be called inside of the body of a function component
which is normal, but how can I actually display an error in a component or change the state of another component from onError function with apollo?
@unutoiul did you found an workaround for this issue?
I have not, Did u find any?
a silly hack
return new Observable((observer) => { return observer.error([...graphQLErrors, networkError]); });
in the code above I will like to get set the useContext of another react component but I get
which is normal, but how can I actually display an error in a component or change the state of another component from onError function with apollo?