I'm new to Apollo Client React. I was reading the docs and i found this <ApolloProvider> wrapper which seems scary to me. My question is why do we need <ApolloProvider> if we can make queries directly and mutations using vanilla js.. I mean why don't we just make queries for example like this:
...
const client = new ApolloClient({
uri: "http://localhost:3001/graphql",
cache: new InMemoryCache(),
});
...
client
.query({
query: gql`
{
books {
name
id
author {
name
}
}
}
`,
})
.then((result) => console.log(result.data));
and then store the results in a state. I'm not actually asking Why? per say. I'm looking for the advantages of this approach of a wrapper <ApolloProvider> over making queries and store them in redux-state. Making mutations directly by calling client.mutate(...) without bothering using the useQuery() apollo hooks.