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.
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.
Apologies for the late response. For what it's worth, updating to apollo 2.16.0 fixed the issue.
For me removing node_modules folder worked, I am using apollo 2.18 and graphql 14.4.2.
@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:
npx apollo service:download --endpoint=http://localhost:4000I 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?
Most helpful comment
Apologies for the late response. For what it's worth, updating to apollo 2.16.0 fixed the issue.