Skip to content

List "graphql" as a peer dependency #2185

Description

@alessbell

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 18 or higher

Browsers

No response

Reproduction repository

https://github.com/apollographql/graphql-testing-library

Reproduction steps

When installing msw, graphql is installed as a transitive dependency at v16. This goes against the expectation in the GraphQL ecosystem that graphql always be treated as a peer dependency: graphql/graphql-js#594 (comment)

From the graphql source:

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.

This cannot be trivially overridden with all package managers (e.g. npm overrides has open issues), and causes surprising behavior.

Current behavior

graphql is a dependency of MSW.

Here's an example of a project using a number of packages that rely on graphql. All of them list it as a peer dependency with the range of 15 || 16, except for MSW.

CleanShot 2024-06-18 at 15 10 56

The result is my MSW GraphQL handler returning errors about unsupported GraphQL features for a version of GraphQL I haven't installed and don't expect to be executing my queries:
CleanShot 2024-06-18 at 15 12 34

Expected behavior

I'd expect MSW to treat it as a peer dependency.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions