jlengstorf / gatsby-intermediate

https://frontendmasters.com/courses/intermediate-gatsby/
MIT License
54 stars 48 forks source link

Querying With Apollo Client - error message #11

Open exposuredesign opened 4 years ago

exposuredesign commented 4 years ago

Hi Jason,

Getting an error message when trying to run the look up site once we add results component:-

`Generating SSR bundle failed

Can't resolve '@apollo/client' in ...node_modules/gatsby-plugin-apollo'`

Has there been some changes to apollo? What package versions were you using?

`"dependencies": {

"@apollo/react-common": "^3.1.4",
"@apollo/react-hooks": "^3.1.5",
"gatsby": "^2.21.0",
"gatsby-plugin-apollo": "^3.0.1",
"graphql-tag": "^2.10.3",
"react": "^16.13.1",
"react-dom": "^16.13.1"

}`

jlengstorf commented 4 years ago

hi there! this workshop used gatsby-plugin-apollo@0.1.1, so it looks like they've shipped some breaking changes since then

I just recorded an episode of Learn With Jason with @stemmlerjs where we went over Apollo Client v3, so maybe that will help fill in the gaps? https://www.learnwithjason.dev/let-s-learn-apollo-client-v3 (video will be at this link tomorrow; for now it's on Twitch)

jacine commented 4 years ago

Hi! 👋

I just ran into this, and was able to fix by:

  1. yarn remove gatsby-plugin-apollo graphql-tag @apollo/react-common @apollo/react-hooks
  2. yarn add gatsby-plugin-apollo @apollo/client
  3. In src/components/results.js:

    - import { useQuery } from '@apollo/react-hooks';
    - import gql from 'graphql-tag';
    + import { gql, useQuery } from '@apollo/client';

HTH.

jlengstorf commented 4 years ago

excellent, thank you so much for sharing @jacine!

I'm going to leave this issue open to hopefully help future googlers 💜

jacine commented 4 years ago

Thank YOU @jlengstorf! The course was fantastic. I really enjoyed it. 👏