Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple versions of graphql #14

Open
laradevitt opened this issue Apr 5, 2020 · 10 comments
Open

Multiple versions of graphql #14

laradevitt opened this issue Apr 5, 2020 · 10 comments

Comments

@laradevitt
Copy link
Contributor

laradevitt commented Apr 5, 2020

Problem

I'm not sure how this came up, I started getting the error below on my projects that depend on gatsby-source-prismic-graphql.

 ERROR #11321  PLUGIN

"gatsby-source-prismic-graphql" threw an error while running the sourceNodes lifecycle:

Cannot use GraphQLDirective "@include" 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.

  78 |       if (!sdl) {
  79 |         introspectionSchema = yield introspectSchema(link);
> 80 |         sdl = printSchema(introspectionSchema);
     |               ^
  81 |       } else {
  82 |         introspectionSchema = buildSchema(sdl);
  83 |       }

File: ..\..\node_modules\gatsby-source-graphql-universal\gatsby-node.js:80:15

This indicates multiple versions of graphql which is obviously not allowed.

A couple of other issues posted in the last few days:

birkir/gatsby-source-prismic-graphql#176
gatsbyjs/gatsby#22645

Output of yarn why graphql:

$ yarn why graphql
yarn why v1.22.4
[1/4] Why do we have the module "graphql"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "graphql"
info Reasons this module exists
   - "workspace-aggregator-b6900ab3-b030-4197-a37e-fa5763949305" depends on it
   - Hoisted from "_project_#gatsby-theme-prismic-blog#gatsby#graphql"
   - Hoisted from "_project_#gatsby-theme-prismic-core#gatsby-source-prismic-graphql#gatsby-source-graphql#graphql"
info Disk size without dependencies: "3.06MB"
info Disk size with unique dependencies: "3.16MB"
info Disk size with transitive dependencies: "3.16MB"
info Number of shared dependencies: 1
=> Found "gatsby-source-graphql-universal#[email protected]"
info This module exists because "_project_#gatsby-theme-prismic-core#gatsby-source-prismic-graphql#gatsby-source-graphql-universal" depends on it.
info Disk size without dependencies: "3.18MB"
info Disk size with unique dependencies: "3.18MB"
info Disk size with transitive dependencies: "3.18MB"
info Number of shared dependencies: 0
=> Found "@types/graphql#[email protected]"
info This module exists because "_project_#gatsby-theme-prismic-core#gatsby-source-prismic-graphql#gatsby-source-graphql-universal#@types#graphql" depends on it.
info Disk size without dependencies: "3.18MB"
info Disk size with unique dependencies: "3.18MB"
info Disk size with transitive dependencies: "3.18MB"
info Number of shared dependencies: 0
Done in 1.19s.

Looking at the source for the latest version of this package (3.1.11) in node_modules/ (which, weirdly, doesn't appear to be in sync with this repo), the given version for graphql is "*" which seems wrong?

Workaround

My workaround is to delete node_modules/ and yarn.lock, then add a resolution to package.json in the project root (or workspaces root if that is your set-up):

  "resolutions": {
    "graphql": "^14.6.0"
  }

Then reinstall with yarn.

Thanks -

Edit: Expanding on workaround.

@lqze
Copy link

lqze commented Apr 6, 2020

I am also getting this issue.
From my package.json

"dependencies": {
    "babel-plugin-styled-components": "^1.10.7",
    "gatsby": "^2.19.25",
    "gatsby-background-image": "^1.0.1",
    "gatsby-cli": "^2.11.5",
    "gatsby-image": "^2.3.1",
    "gatsby-plugin-google-analytics": "^2.2.2",
    "gatsby-plugin-manifest": "^2.3.3",
    "gatsby-plugin-netlify": "^2.2.1",
    "gatsby-plugin-offline": "^3.1.2",
    "gatsby-plugin-react-helmet": "^3.2.1",
    "gatsby-plugin-sass": "^2.2.1",
    "gatsby-plugin-sharp": "^2.5.4",
    "gatsby-plugin-sitemap": "^2.3.1",
    "gatsby-plugin-styled-components": "^3.2.1",
    "gatsby-source-filesystem": "^2.2.2",
    "gatsby-source-graphql": "^2.3.1",
    "gatsby-source-prismic-graphql": "^3.4.0-beta.2",
    "gatsby-transformer-sharp": "^2.4.4",
    "intersection-observer": "^0.7.0",
    "moment": "^2.24.0",
    "node-sass": "^4.13.1",
    "outdated": "^0.1.1",
    "prismic-reactjs": "^1.3.0",
    "prop-types": "^15.7.2",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-helmet": "^5.2.1",
    "react-intersection-observer": "^8.25.2",
    "react-spring": "^8.0.27",
    "styled-components": "^5.0.1"
  },

@laradevitt
Copy link
Contributor Author

Did you try the workaround?

@lqze
Copy link

lqze commented Apr 8, 2020

@laradevitt Sorry, I forgot to mention that. Yes, used workaround and fixed the issue.

@lqze
Copy link

lqze commented Apr 8, 2020

I've also realised you've put this issue under the gatsby-source-graphql-universal repo, not under gatsby-source-prismic-graphql. Should this be moved?

@laradevitt
Copy link
Contributor Author

@lqze

Yes, used workaround and fixed the issue.

Ah, glad that worked for you.

Should this be moved?

I can see how it might be confusing but indeed this is the correct project. The problematic dependency on graphql lies with gatsby-source-graphql-universal (this project), which is a dependency of gatsby-source-prismic-graphql.

@elias-thok
Copy link

The same issue happens when using PNPM.

I assume this is because of the multiple versions of graphql that are potentially stored in the global node_modules folder.

The workaround didn't solve the issue, same as before. Reverting back to npm for now.

@laradevitt
Copy link
Contributor Author

@elias-thok Hi there. You need to delete node_modules/ and yarn.lock and install again. I'll note that in the main post. And yes, it doesn't seem to be exclusive to this module.

@elias-thok
Copy link

@laradevitt Since I was using PNPM there is no yarn.lock but a pnpm-lock.json.

Unfortunately deleting node_modules & pnpm-lock.json did not solve the issue.
I suspect this is because PNPM uses symlinks to a shared node_modules directory where, by design, there will possibly be several graphql packages from other projects.

But npm is fine for now :-)

@laradevitt
Copy link
Contributor Author

@elias-thok - Of course that makes sense. Sorry, not familiar with pnpm!

codingwithchris added a commit to the-nerve/nerve.web that referenced this issue Apr 12, 2020
Temporarily resolve an issue with `gatsby-source-graphql-universal` dependency:
birkir/gatsby-source-graphql-universal#14
codingwithchris added a commit to the-nerve/nerve.web that referenced this issue Jun 12, 2020
* Begin Implementing SEO on Show Pages

* Build Re-useable Config Context

* Wrap Application in Config Context

* Use New Config Context Instead of Direct Static Query

* Create Simpler Method for Accessing Context in Our Application

* Add Props Validation for Schemas

* Move Fragments to GraphQL Root

* Add Next Season Variable To Context

* Remove Un-needed Index

* Improve Destructuring of UseConfig Returned Data

* Begin Reorganizing/ Rebuilding Schemas

* Update Component To Get Gatsby Compiling

* Begin Rebuilding SEO Schema Component Structure

* Convert Schema to Typescript

* Reorg SEO & New ESLint Configs Project for Project

* Remove Errant “S”

* Implement Zeit Now & Update All Dependencies

* Re-lint All Project FIles

* Remove Deprecated NOW Properties

* Remove References to SEO — Temp

* Prep For Ticket Receipt Email

* Migreate Back to Netlify & Remove API Routes

* Update Dependencies

* Update Readme with Nerve Theatre Data

* Clean Up Global Context

* Fix File Import Case

* Resolve GraphQL Dependency Issue + Update Dependencies

Temporarily resolve an issue with `gatsby-source-graphql-universal` dependency:
birkir/gatsby-source-graphql-universal#14

* Update Netlify Config with Proper Redirect Value Type

* Improve Git Ignore Layout

* Temporarily Resolve Broken Functionality

* Update Snipcart to 3.0.11

* Remove Duplicate Plugins

* Integrate Ascend ESLint Config

* Remove Node Engines

* Continue Typescript Migration & App Refactor + Move to CSS Variables

* Continue Massive Refactor

* Add Keys to SSR List items

* Remove Invalid Theme Prop

* Update Config Query Name

* Finish Converting Legacy Components to Typescript

* Temp Add Typescript Rule

* Add Return Types for Site Config Query

* Remove Slices from Season Type

* Begin Building Link Map

* Build Out Super-Dope Link Map

Give us direct access to all site links/pages/shows/seasons etc. Can you feel the power?

* Remove All Seasons URL from Node

* Set Up Proper Link Map Fallbacks

* Temporarily Fix Issue with `gatsby-source-prismic-graphql` Plugin

birkir/gatsby-source-prismic-graphql#162

* Refactor Query, Type, & Component Structure

* Build Poster Grid & Show Poster Component

* Improve Show Poster Stylings

* Update Packages To Latest

* Completey Convert Codebase to better Gatsby Source Prismic

- Migrating away from gatsby-source-prismic-graphql due to poor support and continued unadressed stability issues like:

birkir/gatsby-source-prismic-graphql#217

birkir/gatsby-source-prismic-graphql#77

birkir/gatsby-source-prismic-graphql#162

* Upgrade to Snipcart 3.0.15
@blicker
Copy link

blicker commented Jun 30, 2020

Just want to add a note on how I solved this issue. I did the workaround but it did not work until I also ran npm dedupe. Does this make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants