This code doesn't work. Because error property is always undefined when error occurs. I'm using server side rendering.
const MY_QUERY = gql`
query WillFail {
badField
goodField
}
`;
const ShowingSomeErrors = () => (
<Query query={MY_QUERY} errorPolicy="all">
{({ error, data, loading }) => {
if (loading) return <span>loading...</span>
return (
<div>
<h2>Good: {data.goodField}</h2>
<pre>Bad: {error.graphQLErrors.map(({ message }, i) => (
<span key={i}>{message}</span>
))}
</pre>
</div>
)
}}
</Query>
);
It's really stupid and not funny, when you get error in GraphQL playground and error: undefined in function in Query component. Who made that? It's so stupid!
It's really a weird behavior. Everything works fine in browser, but in server error is always undefined. How can you explain that?
It's impossible to tell from this bug report what might be wrong, or whether the behavior you're describing is even a bug.
Closing because this is no way to start a conversation. Check your attitude or go away.
I figured out it's an old bug (almost 2 years open issue here - https://github.com/apollographql/react-apollo/issues/615) It's very sad. You make thousands of people nervous.