graphql-mesh icon indicating copy to clipboard operation
graphql-mesh copied to clipboard

Yarn 2.0 support

Open snikch opened this issue 2 years ago β€’ 5 comments

Describe the bug

GraphQL Mesh does not appear to have correctly defined dependencies in its packages, and as such will not run out of the box with Yarn 2.0+. Some of the issues come from upstream packages, but some are also @graphql-mesh packages.

To Reproduce Steps to reproduce the behavior:

> yarn init
yarn init v1.22.11
question name (mesh2):
question version (1.0.0):
question description:
question entry point (index.js):
question repository url:
question author:
question license (MIT):
question private:
success Saved package.json
✨  Done in 2.56s.

> yarn set version berry
Resolving berry to a url...
Downloading https://github.com/yarnpkg/berry/raw/master/packages/berry-cli/bin/berry.js...
Saving it into /Users/mal/Code/src/gitlab.inmusicbrands.com/cloud/mesh2/.yarn/releases/yarn-berry.cjs...
Updating /Users/mal/Code/src/gitlab.inmusicbrands.com/cloud/mesh2/.yarnrc.yml...
Done!

> yarn add @graphql-mesh/cli
➀ YN0000: β”Œ Resolution step
➀ YN0002: β”‚ @graphql-mesh/cli@npm:0.41.0 [b4b5a] doesn't provide graphql-tag (p5841b), requested by @graphql-codegen/typescript-generic-sdk
➀ YN0002: β”‚ mesh2@workspace:. doesn't provide graphql (p19ff9), requested by @graphql-mesh/cli
➀ YN0000: β”‚ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➀ YN0000: β”” Completed in 7s 805ms
➀ YN0000: β”Œ Fetch step
➀ YN0013: β”‚ yargs-parser@npm:18.1.3 can't be found in the cache and will be fetched from the remote registry
➀ YN0013: β”‚ yargs-parser@npm:20.2.9 can't be found in the cache and will be fetched from the remote registry
➀ YN0013: β”‚ yargs@npm:15.4.1 can't be found in the cache and will be fetched from the remote registry
➀ YN0013: β”‚ yargs@npm:17.2.1 can't be found in the cache and will be fetched from the remote registry
➀ YN0013: β”‚ yocto-queue@npm:0.1.0 can't be found in the cache and will be fetched from the remote registry
➀ YN0000: β”” Completed in 3s 489ms
➀ YN0000: β”Œ Link step
➀ YN0000: β”” Completed in 0s 411ms
➀ YN0000: Done with warnings in 11s 785ms
yarn add @graphql-mesh/cli  10.25s user 2.24s system 86% cpu 14.507 total

> yarn run mesh dev
/Users/mal/Code/src/gitlab.inmusicbrands.com/cloud/mesh2/.pnp.cjs:14675
    throw firstError;
    ^

Error: @graphql-tools/utils tried to access graphql (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.

Required package: graphql
Required by: @graphql-tools/utils@virtual:d76146c6a6cf1026eae6a659b42ea73a5ac6ef5c4ab43e1d1c3836adaf2d4c8c39297d580f36f1574a206fb01b2810a246ddde8ccdde86f74d9a1c9c0ae22e9c#npm:8.2.5 (via /Users/mal/Code/src/gitlab.inmusicbrands.com/cloud/mesh2/.yarn/__virtual__/@graphql-tools-utils-virtual-5edbf7bf35/0/cache/@graphql-tools-utils-npm-8.2.5-2667229970-421147485c.zip/node_modules/@graphql-tools/utils/)
Ancestor breaking the chain: mesh2@workspace:.


Require stack:
- /Users/mal/Code/src/gitlab.inmusicbrands.com/cloud/mesh2/.yarn/__virtual__/@graphql-tools-utils-virtual-5edbf7bf35/0/cache/@graphql-tools-utils-npm-8.2.5-2667229970-421147485c.zip/node_modules/@graphql-tools/utils/index.js
- /Users/mal/Code/src/gitlab.inmusicbrands.com/cloud/mesh2/.yarn/__virtual__/@graphql-mesh-utils-virtual-2a9b48df9a/0/cache/@graphql-mesh-utils-npm-0.17.2-3892945af8-bdc94b382e.zip/node_modules/@graphql-mesh/utils/index.js
- /Users/mal/Code/src/gitlab.inmusicbrands.com/cloud/mesh2/.yarn/__virtual__/@graphql-mesh-cli-virtual-d76146c6a6/0/cache/@graphql-mesh-cli-npm-0.41.0-e52b17b839-1913166ec6.zip/node_modules/@graphql-mesh/cli/bin.js
    at Function.external_module_.Module._resolveFilename (/Users/mal/Code/src/gitlab.inmusicbrands.com/cloud/mesh2/.pnp.cjs:14674:55)
    at Function.external_module_.Module._load (/Users/mal/Code/src/gitlab.inmusicbrands.com/cloud/mesh2/.pnp.cjs:14473:48)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (/Users/mal/Code/src/gitlab.inmusicbrands.com/cloud/mesh2/.yarn/__virtual__/@graphql-tools-utils-virtual-5edbf7bf35/0/cache/@graphql-tools-utils-npm-8.2.5-2667229970-421147485c.zip/node_modules/@graphql-tools/utils/index.js:5:17)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.external_module_.Module._load (/Users/mal/Code/src/gitlab.inmusicbrands.com/cloud/mesh2/.pnp.cjs:14523:14)
    at Module.require (node:internal/modules/cjs/loader:1005:19)

This can be manually worked around by adding the following to .yarnrc.yml.

packageExtensions:
  "@graphql-tools/[email protected]":
    dependencies:
      graphql: "*"
  "@graphql-mesh/[email protected]":
    dependencies:
      "@graphql-mesh/types": "*"
      "@graphql-mesh/cache-inmemory-lru": "*"
  "@graphql-mesh/[email protected]":
    dependencies:
      graphql: "*"

Environment:

  • OS: Mac
  • @graphql-mesh/cli: 0.41.0
  • NodeJS: v16.8.0

Additional context

snikch avatar Oct 07 '21 04:10 snikch

Do you have graphql package installed in your project?

ardatan avatar Dec 28 '21 09:12 ardatan

I have the same issue.

$ yarn mesh dev
~/my-project/.pnp.cjs:26238
throw firstError;
    ^

Error: @graphql-mesh/cli tried to access @graphql-mesh/types, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @graphql-mesh/types
Required by: @graphql-mesh/cli@virtual:5696cc1addee22c455c87f56d44478f4b95fd689d8455b88c642a128b6a6bb307ed2876bdee9944574c8e0b61cc4cddc3daf3a4ea899ca0365edb0f54870e82c#npm:0.45.0 (via ~/my-project/.yarn/__virtual__/@graphql-mesh-cli-virtual-66fea35a1d/0/cache/@graphql-mesh-cli-npm-0.45.0-044085497b-63641f552c.zip/node_modules/@graphql-mesh/cli/)

Then I tried to add the package mentioned above:

➀ YN0000: β”Œ Resolution step
➀ YN0002: β”‚ @endemolshinegroup/cosmiconfig-typescript-loader@npm:3.0.2 [fd1fb] doesn't provide typescript (p51d8a), requested by ts-node
➀ YN0002: β”‚ @graphql-mesh/cli@npm:0.45.0 [957eb] doesn't provide graphql-jit (paa5ba), requested by @graphql-codegen/typescript-jit-sdk
➀ YN0002: β”‚ @graphql-mesh/cli@npm:0.45.0 [957eb] doesn't provide graphql-tag (pa72d2), requested by @graphql-codegen/typescript-jit-sdk
➀ YN0060: β”‚ @my-project/schema@workspace:packages/schema provides graphql (p49a81) with version 16.2.0, which doesn't satisfy what @graphql-codegen/typescript-resolvers and some of its descendants request
➀ YN0060: β”‚ @my-project/server@workspace:packages/server provides graphql (pa98f0) with version 16.2.0, which doesn't satisfy what @graphql-mesh/cli and some of its descendants request
➀ YN0060: β”‚ @my-project/server@workspace:packages/server provides graphql (pc30c6) with version 16.2.0, which doesn't satisfy what apollo-server-core and some of its descendants request
➀ YN0000: β”‚ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➀ YN0000: β”” Completed
➀ YN0000: β”Œ Fetch step
➀ YN0000: β”” Completed in 0s 388ms
➀ YN0000: β”Œ Link step
➀ YN0000: β”‚ ESM support for PnP uses the experimental loader API and is therefore experimental
➀ YN0000: β”” Completed
➀ YN0000: Done with warnings in 0s 892ms

And tried again:

$ yarn packages/server mesh dev
~/my-project/.pnp.cjs:24936
    throw firstError;
    ^

Error: @graphql-mesh/cli tried to access @graphql-mesh/types, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @graphql-mesh/types
Required by: @graphql-mesh/cli@virtual:957ebe0bb439cda0610c18e00060d3a56bcfa29f074da0ba599e90494e26c64af27f7863017f4141a3cea89009ee32ac6c94b1b41db9137ab0cb3f54b05b5b1b#npm:0.45.0 (via ~/my-project/.yarn/__virtual__/@graphql-mesh-cli-virtual-dc675481bf/0/cache/@graphql-mesh-cli-npm-0.45.0-044085497b-63641f552c.zip/node_modules/@graphql-mesh/cli/)

My env:

$ node -v
v17.3.0

$ yarn -v
3.1.1

package.json:

"devDependencies": {
    "@graphql-mesh/cache-inmemory-lru": "0.5.37",
    "@graphql-mesh/cli": "0.45.0",
    "@graphql-mesh/openapi": "0.23.1",
    "@graphql-mesh/types": "0.57.1",
    "@graphql-mesh/utils": "0.24.2",
    "graphql": "16.2.0"
  }

tamacti avatar Jan 06 '22 16:01 tamacti

Same problem. This works:

in package.json:

  "packageManager": "[email protected]",
  "dependencies": {
    "@graphql-mesh/cli": "^0.88.1",
    "@graphql-mesh/graphql": "^0.96.0",
    "graphql": "^16.8.1"
  }

in .yarnrc.yaml

yarnPath: .yarn/releases/yarn-4.0.2.cjs
nodeLinker: "pnp"
packageExtensions:
  "@graphql-mesh/cli@^0.88.1":
    dependencies:
      "@types/node": "*"
      "graphql-tag": "*"
  "@graphql-mesh/config@^0.98.1":
    dependencies:
      "graphql-yoga": "^5.0.0"
  "@graphql-mesh/merger-bare@^0.96.0":
    dependencies:
      "@graphql-mesh/store": "^0.96.0"
      "@graphql-mesh/cross-helpers": "^0.4.1"
  "@graphql-mesh/graphql@^0.96.0":
    dependencies:
      "@graphql-mesh/cross-helpers": "*"
      "@graphql-mesh/store": "^0.96.0"
      "@graphql-mesh/types": "^0.96.0"
      "@graphql-mesh/utils": "^0.96.0"
      "@graphql-tools/utils": "^9.2.1"
      "tslib": "^2.4.0"

tdsfugal avatar Nov 26 '23 22:11 tdsfugal

Thanks for the reports!

Can someone create a simple reproduction?

Sorry but I'm not adding a lot here but just labeling it according to our new Contribution Guide and issue flow.

It seems already got into stage 0.

Now in order to advance to stage 1 we'll need a simple reproduction, maybe in code-sandbox?

Later to progress to stage 2, a failing test would be needed, would be great if someone could help progress the issues through the stages.

Thank you and sorry that this comment is not a complete solution (yet).

Urigo avatar Dec 02 '23 17:12 Urigo

+1

Yarn 1.x versions (which supports node_modules) is in EOL maintenance. With Corepack since Node 18 there's been a large push to use plug and play, which is what yarn 2.x >= uses. PNP is much more explicity with its dependencies, so it would be nice to see this advance and garner native support from the main maintainers.

robigan avatar Feb 29 '24 17:02 robigan