\"@apollo/react-hooks\": \"^3.1.3\",
\"apollo-client\": \"^2.6.8\",
Apollo client return undefined on react app but return the data on gql playgrou
something that might help, you know where you call {data} you can also look for error and console.log('Error:',error)
check the apollo client query docs
something like this , and look at the error message, it should help !
import { useQuery } from '@apollo/react-hooks';
import gql from 'graphql-tag';
const GET_GREETING = gql`
query getGreeting($language: String!) {
greeting(language: $language) {
message
}
}
`;
function Hello() {
const { loading, error, data } = useQuery(GET_GREETING, {
variables: { language: 'english' },
});
if (loading) return 'Loading...';
if (error) return `Error! ${error.message}`;
return Hello {data.greeting.message}!
;
}