Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
m1010j opened this issue Jul 8, 2019 · 8 comments

Comments

@m1010j
Copy link

m1010j commented Jul 8, 2019

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.

@JakeDawkins
Copy link
Contributor

I can't reproduce this issue locally with the latest version of apollo. Can you provide a simple repo/codesandbox/glitch with a project where this happens? I'll close until there is a way to reproduce this.

@m1010j
Copy link
Author

m1010j commented Jul 22, 2019

Apologies for the late response. For what it's worth, updating to apollo 2.16.0 fixed the issue.

@asifsaho
Copy link

asifsaho commented Aug 30, 2019

For me removing node_modules folder worked, I am using apollo 2.18 and graphql 14.4.2.

@adamrneary
Copy link

@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?

@rumanHuq
Copy link

rumanHuq commented Mar 7, 2021

Problem still persists with "graphql": "^15.5.0", "apollo": "2.32.5"

@eunchurnpark
Copy link

eunchurnpark commented Mar 20, 2021

Problem still persists with "graphql": "^15.5.0", "apollo": "2.32.5"

in case "graphql": "^15.5.0", "apollo": "2.32.5"

insert resolutions field in your package.json

{
  "dependencies": {
     "graphql": "15.5.0"
   },
  "resolutions": {
    "apollo/graphql": "15.4.0"
  }
}

and remove node_modules and package-lock.json or yarn.lock file.
install dependencies again.

working for me.

@danjenson
Copy link

Still and issue with graphql 15.5.0 and apollo 2.33.6

@moladukes
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants