Could not find "client" in the context of Apollo(MyComponent). Wrap the root component in an <ApolloProvider>
See original GitHub issueI am getting this error while doing testing. I think it coming because I am testing a component which Query render props and one of child component is using useQuery and useMutation. Are they way to fix this ? or I have to convert that component into hooks/vice-versa
Issue Analytics
- State:
- Created 4 years ago
- Comments:10
Top Results From Across the Web
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. How to reproduce the issue: I have a...
Read more >React Apollo Error: Invariant Violation: Could not find "client ...
Invariant Violation : Could not find "client" in the context or passed in as an option. Wrap the root component in an ,...
Read more >Accessing Apollo client in an Astro + React project without ...
If I try I get this error: Could not find “client” in the context or passed in as an option. Wrap the root...
Read more >Apollo and Graphql Help: "Could not find "client" in the context ...
Wrap the root component in an <ApolloProvider>, or pass an ApolloClient instance in via options." As of right now, my goal is to...
Read more >React Apollo Error: Invariant Violation: Could not find "client ...
Coding example for the question React Apollo Error: Invariant Violation: Could not find "client" in the context or passed in as an option-Reactjs....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

react apollo offers a
MockedProvider- would it be an idea to add aMockedHooksProviderto this package?Hi @Enigma10
If you are testing a component that use useQuery or useMutation you need to wrap the component with the ApolloProvider. You can check an example here: https://github.com/trojanowski/react-apollo-hooks-sample-test/blob/master/src/__tests__/Hello-test.js
If I understood your case correctly you are using both:
react-apolloandreact-apollo-hooksat the same time so, I think you’ll need to wrap your component with both providers. Check how to use the mock provider forreact-apollohere: https://www.apollographql.com/docs/react/recipes/testing/