apollographql / react-apollo

:recycle: React integration for Apollo Client
https://www.apollographql.com/docs/react/
MIT License
6.85k stars 787 forks source link

Apollo Client 3 useQuery & useMutation preventing Gatsby Build #3950

Open mplayer78 opened 4 years ago

mplayer78 commented 4 years ago

Whilst my app will run in dev, whenever I go to build I am getting a ``` WebpackError: Invariant Violation: Invariant Violation: 46 (see https://github.com/apollographql/invariant-packages)

bcwatson22 commented 4 years ago

I had something similar to this - fixed by duplicating /gatsby-browser.js content in /gatsby-ssr.js - you can create a module to import the client etc into each file to keep things DRY.

This helped me work a few bits out when I was using Apollo with Gatbsy: https://github.com/jlengstorf/gatsby-with-apollo

mstephano commented 4 years ago

@bcwatson22 Thank you for your solution. Copying the same to both gatsby-browser.js and gatsby-ssr.js fixed my issue of invariant violation while building gatsby with @apollo/react-hooks.

mplayer78 commented 4 years ago

Thankyou, this seems to have sorted the problem. Thanks for taking the time.