The same query in GraphiQL returns data, but returns null in React-Apollo.
Problem (so far) is only with this query. I've used a "Signup" mutation that returns data when tried from both React-Apollo and GraphiQL. This leads me to think the problem is with the query, but I can't find anything wrong.
I did notice that request from Apollo has slightly different Header info. I'm not sure if that's the issue and, if so, how to change it.
GraphiQL vs Apollo request/response
Snippet in class component:
render() {
return (
<Query query={currentUser} >
{({ loading, error, data }) => {
if (loading) return "Loading...";
if (error) return `Error! ${error.message}`;
return (
<UsersContext.Provider
value={{ ...this.state }}
>
{console.log('data', data)}
{this.props.children}
</UsersContext.Provider >
)
}}
</Query>
)
}
I also tried calling query by export default graphql(currentUser)(UserProvider)
but it failed the same.
Query code:
import gql from 'graphql-tag';
const currentUser = gql`
{
user {
id
email
username
}
}
`;
export default currentUser;
Query is exact same as in GraphiQL: Query and response in GraphiQL