Skip to content

npm link with graphql package breaks application #4113

@chdanielmueller

Description

@chdanielmueller

Hi there,

I get an error while developing a package which adds functionality to graphql.
My issue is the check to verify that only one instance of graphql is in use.
If I npm link my package to my graphql server it does no longer run since the error gets thrown.
npm link does (as far as I understand) also use the node_modules of my linked package.
Which results in another instance of graphql which I want in this specific case.

The error in question:

Cannot use ${className} "${stringifiedValue}" 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.

Source of the error:
https://github.com/graphql/graphql-js/blob/main/src/jsutils/instanceOf.ts

I was wondering if an environment variable which circumvents this exception would be something that can be considered.
I am opening a PR with the change.

Thanks,
Daniel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions