apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.29k stars 2.64k forks source link

Unable to resolve "graphql/language/visitor" from "node_modules/apollo-utilities/lib/bundle.umd.js" #4485

Closed Truemedia closed 3 years ago

Truemedia commented 5 years ago

Intended outcome: Trying to use Apollo client with React native or Vue native using code from this recipe page https://www.apollographql.com/docs/react/recipes/react-native.html

Running the iOS simulator expect to see an app or error messages directly related to my app.

Actual outcome: When running the iOS simulator I get the message:

Unable to resolve "graphql/language/visitor" from "node_modules/apollo-utilities/lib/bundle.umd.js"

Extra message is module does not exist in haste map

How to reproduce the issue: Create a fresh React or vue native instance and try using the apollo client for a simple query

Versions System: OS: macOS High Sierra 10.13.6 Binaries: Node: 10.12.0 - /usr/local/bin/node Yarn: 1.10.1 - /usr/local/bin/yarn npm: 6.8.0 - /usr/local/bin/npm Browsers: Chrome: 72.0.3626.119 Safari: 12.0.3 npmPackages: apollo-client: ^2.4.13 => 2.4.13 react-apollo: ^2.4.1 => 2.4.1

christiansr85 commented 5 years ago

The same is happening to me, but trying to run my application on Windows 10 on an Android emulator and even on my android phone throug Expo(v32.0.0).

dysonpro commented 5 years ago

apollo-utilities v1.1.3 has a dependency on graphql which is not mentioned in its package.json but it is mentioned as a peerDependency for Apollo-client to resolve it, I ran: npm install -s graphql

christiansr85 commented 5 years ago

@dysonpro that's it... I totally forgot to check my installed dependecies...

benjamn commented 5 years ago

The graphql package is a peer dependency of apollo-utilities now, which is our general policy for Apollo packages because we really don't want multiple copies of graphql getting installed, since that throws instanceof for a loop.

ssalbdivad commented 5 years ago

For those still affected by this apollo-cache and graphql-anywhere also depend on graphql but don't list it as a peerDependency. PR with a fix: https://github.com/apollographql/apollo-client/pull/5081

oknoorap commented 4 years ago

hey i still got error, even after installing graphql via yarn add graphql

RuneKR commented 4 years ago

I still have the issue after npm install graphql. Just like #https://github.com/Polymer/pwa-starter-kit/issues/362

mateomarconi commented 4 years ago

hey i still got error, even after installing graphql via yarn add graphql

Here too

RuneKR commented 4 years ago

Hi, everyone. I managed to fix it. Created a Clean PWA Starter kit that works.

Key things i did:

See the webpack config folder. The current webpack config is quite minimal but happy to extend it.

The current project is "clean" so you would have to add graphql yourself. Let me know if you need a full example and i can try to work it out tomorrow

LucHermkens commented 4 years ago

I'm getting the following error:

Failed to compile.

./node_modules/apollo-client/bundle.esm.js
Attempted import error: 'BREAK' is not exported from 'graphql/language/visitor'.

Do you guys have any idea what might cause this issue? I have graphql@^14.5.8, apollo-boost@^0.4.4 and @apollo/react-hooks@^3.1.3. Thanks for the help! :smile:

LucHermkens commented 4 years ago

I'm getting the following error:

Failed to compile.

./node_modules/apollo-client/bundle.esm.js
Attempted import error: 'BREAK' is not exported from 'graphql/language/visitor'.

Do you guys have any idea what might cause this issue? I have graphql@^14.5.8, apollo-boost@^0.4.4 and @apollo/react-hooks@^3.1.3. Thanks for the help! 😄

I managed to fix this by adding '.mjs' to the list of filetypes for Webpack to resolve. Full example:

{
  test: [/\.js$/, /\.mjs$/],
  loader: require.resolve('babel-loader'),
  options: {
    ...
  }
}
ghost commented 4 years ago

Same issue there:

Unable to resolve "../graphql/client/fetchUser.graphql" from "pages/index.tsx" under iOS simulator. Is there any way to fix that issue?

annabfenske commented 4 years ago

Has there been any resolution here? When I install apollo-link-error, I get this error during runtime

Module not found: Error: apollo-utilities tried to access graphql (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

and am only able to silence it by manually updating my yarn.lock file to include graphql as a peerDependency of apollo-link-error - which I reeeally don't want to have to do.

package.json dependencies:

    "dependencies": {
        "@apollo/react-hooks": "3.1.5",
        "@apollo/react-testing": "3.1.4",
        "@types/graphql": "14.5.0",
        "@types/react": "16.9.34",
        "@types/zen-observable": "0.8.0",
        "apollo-cache-inmemory": "1.6.5",
        "apollo-client": "2.6.8",
        "apollo-link": "1.2.14",
        "apollo-link-error": "1.1.5",
        "apollo-link-http": "1.5.17",
        "apollo-link-retry": "2.2.16",
        "apollo-utilities": "1.3.3",
        "graphql": "14.6.0",
        "graphql-tag": "2.10.1",
        "react": "16.13.0",
        "react-dom": "16.13.0",
        "react-router-dom": "5.1.2",
        "zen-observable": "0.8.15"
    },
    "devDependencies": {
        "@hot-loader/react-dom": "16.13.0",
        "@types/jest": "25.2.1",
        "@types/node": "13.13.4",
        "@types/react-dom": "16.9.5",
        "@types/react-router-dom": "5.1.5",
        "@types/react-test-renderer": "16.9.2",
        "apollo": "2.27.0",
        "jest": "25.5.2",
        "react-test-renderer": "16.13.1"
    }
RuneKR commented 4 years ago

@annabfenske - have a look at what i did to my own project to make it work. You can make the same changes to your bundler to make it work.

Mdelacruzmelo commented 3 years ago

I got the error: "Module not found: Can't resolve 'graphql/language/visitor' "

beacuse i was importing "setContext" like this: "import { setContext } from 'apollo-link-context'"

I just changed to this : "import { setContext } from '@apollo/client/link/context'"

Docs: https://www.apollographql.com/docs/react/networking/authentication/

Hope it could help

hwillson commented 3 years ago

This should no longer be an issue in @apollo/client@latest - let us know otherwise, thanks!

atifjkhan commented 2 years ago

i still have this error, i ran nextjs and nodejs on ubuntu server, i know its a very bad way to enable on server but im just testing, im planning to start it using pm2.