apollo@client whole query is defiened but single item undefiened

Viewed 23

I am making graphql application and using apollo client for it. in frontend i use reactjs and appollo/client.

I am getting query with following code:

  const TEST_QUERY = gql`
    {
      hello
    }
  `;

  const { data } = useQuery(TEST_QUERY);

when i try to console.log(data) it gives me whole query result (query result is

{
 hello: "hello world"
}

)

but when i try to console.log(data.hello) it gives me following error in console:

TypeError: Cannot read properties of undefined (reading 'hello')

help? thanks.

0 Answers
Related