question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema download failing again with graphql 14.4.2 ("Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm")

See original GitHub issue

Intended outcome:

Schema download succeeds.

Actual outcome:

Schema download fails:

Error: Cannot use GraphQLSchema "[object GraphQLSchema]" 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.
    at instanceOf (/opt/app/node_modules/apollo/node_modules/graphql/jsutils/instanceOf.js:28:13)
    at isSchema (/opt/app/node_modules/apollo/node_modules/graphql/type/schema.js:34:34)
    at assertSchema (/opt/app/node_modules/apollo/node_modules/graphql/type/schema.js:38:4)
    at validateSchema (/opt/app/node_modules/apollo/node_modules/graphql/type/validate.js:44:28)
    at assertValidSchema (/opt/app/node_modules/apollo/node_modules/graphql/type/validate.js:68:16)
    at assertValidExecutionArguments (/opt/app/node_modules/apollo/node_modules/graphql/execution/execute.js:163:35)
    at executeImpl (/opt/app/node_modules/apollo/node_modules/graphql/execution/execute.js:84:3)
    at execute (/opt/app/node_modules/apollo/node_modules/graphql/execution/execute.js:62:63)
    at Object.introspectionFromSchema (/opt/app/node_modules/apollo/node_modules/graphql/utilities/introspectionFromSchema.js:31:37)
    at Task.task (/opt/app/node_modules/apollo/lib/commands/service/download.js:21:82)

How to reproduce the issue:

Run yarn apollo service:download schema.json --endpoint {endpoint_url}.

Versions

I’m on apollo 2.15.0. I got the same error on 2.12.3, as described here, but this PR temporarily fixed it. But now after upgrading from graphql 14.4.0 to 14.4.2, I’m getting the error again.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
adamrnearycommented, Sep 3, 2020

@JakeDawkins (how’s it going?) I am now seeing this error pretty much no matter what. I tried a fresh install, tried hardcoding apollo 2.18 and graphql 14.4.2. Nothing seems to be working. Is it possible some dependency got messed up in an associated repo? Are you seeing this on a fresh install?

Repro for me:

  1. Follow instructions https://www.apollographql.com/docs/apollo-server/getting-started
  2. Run npx apollo service:download --endpoint=http://localhost:4000

I tried yarn and npm. I can confirm with package-lock.json and yarn lock that the same version of graphql is being used everywhere. Tried resolutions in the package.json.

  ✖ Saving schema to schema.json
    → spurious results.
    Error: Cannot use GraphQLSchema "[object GraphQLSchema]" 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.

Any ideas?

2reactions
moladukescommented, Sep 17, 2021

Was dealing this issues. My fix was to add the resolution and yarn upgrade. Versioning thing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot use GraphQLSchema "[object ... - Stack Overflow
I get this error: Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm. Ensure that there is only one instance ...
Read more >
How to fix the error: “Cannot use GraphQLSchema “[object ...
Failure: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm. Ensure that there is only one instance of "graphql" ...
Read more >
GraphQL Content API - Contentful
Schema generation fails when: Two or more content type IDs would be transformed to the same type name. Two or more field IDs...
Read more >
Get started with Apollo Server - Apollo GraphQL Docs
Define a GraphQL schema that represents the structure of your data set; Run an instance of Apollo Server that lets you execute queries...
Read more >
Ben Awad on Twitter: "Love seeing "Cannot use ...
Love seeing "Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm." every time I upgrade the graphql package. ... as peerDependency. We ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found