graphiql icon indicating copy to clipboard operation
graphiql copied to clipboard

@graphiql/toolkit tried to access graphql-ws (a peer dependency) but it isn't provided by its ancestors

Open simPod opened this issue 3 years ago • 3 comments

According to https://github.com/graphql/graphiql/issues/2405#issuecomment-1133928930 it should probably work somehow?

I'm using Yarn PnP. I require "graphiql": "^1.9.1", and use it as

import GraphiQLComponent from 'graphiql';

...

export const GraphiQL: React.FC = () => (
  <GraphiQLComponent
    fetcher={graphQLFetcher}
    editorTheme="material"
  />
);

also @graphiql/toolkit 0.5.0 is in lockfile:

"@graphiql/toolkit@npm:^0.5.0":
  version: 0.5.0
  resolution: "@graphiql/toolkit@npm:0.5.0"
  dependencies:
    "@n1ru4l/push-pull-async-iterable-iterator": ^3.1.0
    meros: ^1.1.4
  peerDependencies:
    graphql: ^15.5.0 || ^16.0.0
    graphql-ws: ">= 4.5.0"
  checksum: cc4b7497f2dd96ab11f826e2ea35a8b6c053801a048a103c48402dad98f459c785565e934e83c26b23d6e950ad7f3a04b605250037bbd07d058c177073f5f833
  languageName: node
  linkType: hard

but I'm getting a warning:

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

I tried requiring "graphql-ws": "^5.8.2", but still getting the warning mentioned above.

simPod avatar May 22 '22 16:05 simPod

WARNING in ../.yarn/__virtual__/@graphiql-toolkit-virtual-952b477400/0/cache/@graphiql-toolkit-npm-0.6.0-d39851cf7b-19878d8e3c.zip/node_modules/@graphiql/toolkit/esm/create-fetcher/lib.js 60:33-54
Module not found: Error: @graphiql/toolkit tried to access graphql-ws (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

Required package: graphql-ws
Required by: @graphiql/toolkit@virtual:22ab0d1b83eb161bbd7dde395d359b0a00e8e887a3f5ba23729464c46528174ca7c44c861ee8083e3f40cd5361dd691963288c38d15ee155f6e455c41ad01e40#npm:0.6.0 (via /.../.yarn/__virtual__/@graphiql-toolkit-virtual-952b477400/0/cache/@graphiql-toolkit-npm-0.6.0-d39851cf7b-19878d8e3c.zip/node_modules/@graphiql/toolkit/esm/create-fetcher/)

Ancestor breaking the chain: @graphiql/react@virtual:22ab0d1b83eb161bbd7dde395d359b0a00e8e887a3f5ba23729464c46528174ca7c44c861ee8083e3f40cd5361dd691963288c38d15ee155f6e455c41ad01e40#npm:0.4.2
Ancestor breaking the chain: graphiql@virtual:656141524fab26d76b9a0de37412b0bd8d68b112a7ae5bb3607d411763274ecb93d754bd2292ee7cee1844b867cae11a6a7be00b96f1e87fd47684b593faaa6e#npm:1.9.9

simPod avatar Jun 16 '22 07:06 simPod

Running yarn install

➤ YN0000: ┌ Post-resolution validation
➤ YN0069: │ @graphiql/toolkit ➤ peerDependencies ➤ graphql-ws: This rule seems redundant when applied on the original package; the extension may have been applied upstream.

simPod avatar Jun 16 '22 07:06 simPod

Tmp fix is yarn add graphql-ws + in .yarnrc.yml

packageExtensions:
  # awaiting fix: https://github.com/graphql/graphiql/issues/2428
  "graphiql@*":
    peerDependenciesMeta:
      graphql-ws:
        optional: true

simPod avatar Jun 16 '22 08:06 simPod

@simPod Are you still having the same issue? I can't reproduce this issue in exactly the same way. I get the same warning message without yarn add graphql-ws while getting no warning message with it.

yoshiakis avatar Sep 28 '22 13:09 yoshiakis

@yoshiakis just tried and still getting that issue graphql-ws is required but also need to have the package extension. Do you use pnp?

simPod avatar Sep 28 '22 19:09 simPod

@simPod I understand this issue now, and was able to reproduce your situation completely. Actually, graphql-ws has been an optional peer dependency for @graphiql/toolkit since the release of the version of 0.7.2 of @graphiql/toolkit. I guess you can remove the unnecessary waring message when you upgrade graphiql to the version of 2.0.5 or more than that.

related: #2753

yoshiakis avatar Sep 30 '22 07:09 yoshiakis

Yes, in v2 this issue is no more

simPod avatar Sep 30 '22 07:09 simPod

@acao @yoshiakis this is an issue again in v3

simPod avatar Jun 27 '23 08:06 simPod