Client.query is not a function

Hi, I keep getting the error client.query is not a function when trying to just console log a query to my database while doing apollo client set up in my react app just as described in the tutorial. Does anyone have any clue why i am seeing issues like my app cannot see ApolloClient or is not initializing new ApolloClient with the data i am passing. i have checked graphql and updated to node 14.16.0 to support graphql in my app and still no luck. Any help is greatly appreciated. Thanks

@concishareadmin can you share your code that shows where you’re calling new ApolloClient()?

const client = () => new ApolloClient({
    link: new HttpLink({
        uri: 'url',
        headers: {
          Authorization: 'Bearer JWT_TOKEN'
        }
      }),
        cache: new InMemoryCache(),
    });```

Thanks @concishareadmin - in your code sample you’re actually storing a function in your client variable, which is why when you call client.query the query function can’t be called. You can either rewrite this as:

const client = new ApolloClient({
  link: new HttpLink({
    uri: 'url',
    headers: {
      Authorization: 'Bearer JWT_TOKEN'
    }
  }),
  cache: new InMemoryCache(),
});

or run the function you’re storing first, like:

client().query()

ok yeah that was a oversight on my part. thanks for the clarification.