I’m using GraphQL, Apollo and React for an app. My App.js
looks like the following:
// imports
const APOLLO_CLIENT = new ApolloClient({
uri: "https://some.uri.io",
cache: new InMemoryCache()
});
const QUERY_ONE = gql`{
querySomething {
something
}
}`;
const QUERY_TWO = gql`{
queryAnother {
something
}
}`;
//Several functional components
function App() {
// state definitions
// here I make a query
const { loading, error, data, refetch } = useQuery(QUERY_TWO)
// some more stuff
return (
<ApolloProvider client={APOLLO_CLIENT}>
<div>
// some stuff here
</div>
</ApolloProvider>
);
}
This is giving the Could not find "client" in the context or passed in as an option. Wrap the root component in an <ApolloProvider>, or pass an ApolloClient instance in via options.
error.
Something probably made the query out of context although I have no clue what; I make another query in a functional component in the same way as I’ve done here in this App
component (maybe that itself caused the error?!), but that didn’t yield an error like this. I’m totally new to GraphQL, Apollo and React so would appreciate any input.
Thanks.
EDIT: SOLVED