Jotai with apollo

I am trying to use Jotai with Apollo Client in Redwood
How can I get the apollo client instantiated by Redwood ? Or should I instantiate a new one (then what about cache sharing) ?


You can use the ‘useApolloClient’ hook that you import from ‘@apollo/client’

Hooks - Apollo GraphQL Docs

Redwood docs

Hi @KrisCoulson

Unfortunately jotai need the Apollo client instance, outside of a hook/react

Can we create the client and pass it to the Apolloredwood context manager instead ?

Yes the info is in the Redwood documentation that I linked you can create a client and pass it into the apollo provider

Hey Kris, I’m dealing with the same thing on my end. As far as I know, the RedwoodApolloProvider can be configured to customize the Apollo client it creates, but it doesn’t seem possible to directly replace it with an existing client instance, unless we switch out the RedwoodApolloProvider.

this is solved by rather passing the client as an atom to feed the the atoms store (outside react) after hydration using useApolloClient. Thanks a lot!

Hello @yassuge
Could you please provide some more information or share the relevant code portions on how you solved this? That would be very useful to me.
Thank you