apollographql / apollo-server

🌍  Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
https://www.apollographql.com/docs/apollo-server/
MIT License
13.71k stars 2.02k forks source link

Cannot use GraphQLNonNull "String!" from another module or realm. #7894

Open DanielAtCosmicDNA opened 6 days ago

DanielAtCosmicDNA commented 6 days ago

Issue Description

When you run the canonical code from: https://github.com/CosmicDNA/neo4j-graphql-example-nextjs/tree/5385e091ce68004de94bda184c940e69a09c7dee,

with yarn run dev and go to /api/graphql path, the following error is thrown:

 ⨯ Error: Cannot use GraphQLNonNull "String!" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.

More details on: https://github.com/apollo-server-integrations/apollo-server-integration-next/issues/200

Link to Reproduction

https://github.com/CosmicDNA/neo4j-graphql-example-nextjs/tree/5385e091ce68004de94bda184c940e69a09c7dee

Reproduction Steps

Cloning

To clone the repository run:

git clone https://github.com/CosmicDNA/neo4j-graphql-example-nextjs.git

Installation

To install the dependencies run:

cd neo4j-graphql-example-nextjs
npm install

Setting database

To set the database up, rename .env.sample to .env and edit the parameters of your Neo4j database accordingly.

Starting the GraphQL server

Finally, to start the Apollo GraphQL server run:

npm run dev
DanielAtCosmicDNA commented 4 days ago

I was able to workaround for the time being with https://github.com/apollo-server-integrations/apollo-server-integration-next/issues/200#issuecomment-2206256997.