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

GraphiQL produces error: Cannot use e "__Schema" from another module or realm. #677

Closed
1 task done
slikts opened this issue Jan 30, 2018 · 19 comments
Closed
1 task done

Comments

@slikts
Copy link

slikts commented Jan 30, 2018

I'm submitting a ...

  • bug report

PostGraphQL version: 3.5.5

Steps to reproduce:

I run postgraphql -c postgres://user@localhost/db

I've tried with postgraphql installed globally or locally; possibly related to minifaction graphql/graphql-js#1182

Current behavior:

Uncaught Error: Cannot use e "__Schema" 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 n (instanceOf.js:17)```
@benjie
Copy link
Member

benjie commented Jan 30, 2018

Ugh; it worked locally. I'll get another release shipped.

@benjie
Copy link
Member

benjie commented Jan 30, 2018

3.5.6 is out which fixes this; I've specifically installed graphql v0.11 locally before building/publishing.

@benjie
Copy link
Member

benjie commented Jan 30, 2018

And postgraphile@4.0.0-alpha2.30

@benjie benjie closed this as completed Jan 30, 2018
@baldwinchang
Copy link

baldwinchang commented Jan 31, 2018

Hi @benjie, what would be the ETA on the docker image build also reflecting the update?

Thanks!


Update: The error still seems to be showing for me on /graphiql on fix-send and latest tags on Docker Hub.

@benjie
Copy link
Member

benjie commented Jan 31, 2018

The docker images will need manual fixing to pin graphql to v0.11 as v0.12 breaks minification. I would pin it in the package.json, but doing so would be a breaking change. Paging @angelosarto

@angelosarto
Copy link
Collaborator

angelosarto commented Jan 31, 2018 via email

@benjie
Copy link
Member

benjie commented Feb 1, 2018

Thanks @angelosarto! 🙏

angelosarto added a commit to angelosarto/postgraphql that referenced this issue Feb 2, 2018
GraphiQL produces error: Cannot use e "__Schema" from another module or realm. graphile#677

Pin the version of graphql to < 0.12 in the package.json right before the npm build.
@angelosarto
Copy link
Collaborator

If the above PR is merged - docker should automatically rebuild and it will temporary pin the version before the package is built. I tried it locally and it seems fine.

benjie pushed a commit that referenced this issue Feb 2, 2018
GraphiQL produces error: Cannot use e "__Schema" from another module or realm. #677

Pin the version of graphql to < 0.12 in the package.json right before the npm build.
@benjie
Copy link
Member

benjie commented Feb 2, 2018

Merged 👍

@idkjs
Copy link

idkjs commented Mar 7, 2018

Getting the same, above noted error, with version "postgraphile@4.0.0-alpha2.33"

Im running through the tutorial and trying to run the following command postgraphile -c postgres://forum_example_postgraphile:xyz@localhost:5432/mydb from the POSTGRES ROLES Section.

Im getting this error in the console:

postgraphile -c postgres://forum_example_postgraphile:xyz@localhost:5432/forum

PostGraphQL server listening on port 5000 🚀

  ‣ Connected to Postgres instance postgres://localhost:5432/forum
  ‣ Introspected Postgres schema(s) public
  ‣ GraphQL endpoint served at http://localhost:5000/graphql
  ‣ GraphiQL endpoint served at http://localhost:5000/graphiql

* * *

Failed to add function 'public.crypt'; run with 'DEBUG="graphile-build-pg:warn"' to view the error
Failed to add function 'public.dearmor'; run with 'DEBUG="graphile-build-pg:warn"' to view the error
Failed to add function 'public.decrypt'; run with 'DEBUG="graphile-build-pg:warn"' to view the error
Failed to add function 'public.decrypt_iv'; run with 'DEBUG="graphile-build-pg:warn"' to view the error
Failed to add function 'public.encrypt'; run with 'DEBUG="graphile-build-pg:warn"' to view the error
Failed to add function 'public.encrypt_iv'; run with 'DEBUG="graphile-build-pg:warn"' to view the error
Failed to add function 'public.pgp_key_id'; run with 'DEBUG="graphile-build-pg:warn"' to view the error
An error occurred, it might be okay but it doesn't look like the error we were expecting... run with envvar 'DEBUG="graphile-build:warn"' to view the error
    Error: Cannot use GraphQLSchema "[object Object]" 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 (/Users/prisc_000/.config/yarn/global/node_modules/postgraphile/node_modules/graphql/jsutils/instanceOf.js:17:13)
    at isSchema (/Users/prisc_000/.config/yarn/global/node_modules/postgraphile/node_modules/graphql/type/schema.js:48:35)
    at validateSchema (/Users/prisc_000/.config/yarn/global/node_modules/postgraphile/node_modules/graphql/type/validate.js:51:25)
    at assertValidSchema (/Users/prisc_000/.config/yarn/global/node_modules/postgraphile/node_modules/graphql/type/validate.js:76:16)
    at Object.validate (/Users/prisc_000/.config/yarn/global/node_modules/postgraphile/node_modules/graphql/validation/validate.js:61:35)
    at Object.<anonymous> (/Users/prisc_000/.config/yarn/global/node_modules/postgraphile/build/postgraphql/http/createPostGraphQLHttpRequestHandler.js:333:50)
    at step (/Users/prisc_000/.config/yarn/global/node_modules/tslib/tslib.js:133:27)
    at Object.next (/Users/prisc_000/.config/yarn/global/node_modules/tslib/tslib.js:114:57)
    at fulfilled (/Users/prisc_000/.config/yarn/global/node_modules/tslib/tslib.js:104:62)
    at <anonymous>
1 error(s) in 51.61ms :: query IntrospectionQuery { __schema { queryType { name } mutationType { name } subscriptionType { name } types { ...FullType } directives { name description locations args { ...InputValue } } } } fragment FullType on __Type { kind name description fields(includeDeprecated: true) { name description args { ...InputValue } type { ...TypeRef } isDeprecated deprecationReason } inputFields { ...InputValue } interfaces { ...TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes { ...TypeRef } } fragment InputValue on __InputValue { name description type { ...TypeRef } defaultValue } fragment TypeRef on __Type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } } } }
^C

Enviroment:
ProductName: Mac OS X
ProductVersion: 10.13.3
BuildVersion: 17D102
yarn version: 1.5.1
node version: v9.5.0

@benjie
Copy link
Member

benjie commented Mar 7, 2018

Follow the yarn resolution instructions in the error message to ensure there’s only one version of graphql installed. Probably 0.11.x

@mike-022
Copy link

Yarn resolution worked for me:

"dependencies": {
"babel-cli": "^6.26.0",
"config": "^1.26.2",
"cookie-parser": "^1.4.3",
"dotenv": "^4.0.0",
"express": "^4.13.3",
"graphql": "0.13.2",
"node-fetch": "^1.7.3",
"postgraphile": "^4.0.0-alpha2.20"
},
"resolutions": {
"postgraphile/graphql": "0.13.2"
},

@nmgds
Copy link

nmgds commented Aug 23, 2018

any solution for npm? have exactly the same as @MichaelG02

@benjie
Copy link
Member

benjie commented Aug 23, 2018

For yarn you’d do this: https://stackoverflow.com/questions/51990179/run-postgraphile-with-npm/51990635#51990635

Here’s some comments about it on the GraphQL repo, perhaps there might be something there that might point you somewhere useful for npm:

graphql/graphql-js#594 (comment)

I don’t use npm, but if you get a solution please report back 👍

@benjie
Copy link
Member

benjie commented Aug 23, 2018

“npm dedupe” might work. Use 0.12.x if you can.

@nmgds
Copy link

nmgds commented Aug 23, 2018

@benjie thank you for pointing the right direction. I did try npm dedupe before, but without success. Fortunately lowering down graphql to 0.12.3 helped!

@omar-dulaimi
Copy link

I get this error despite running postgraphile with npx. Any tips?

@benjie
Copy link
Member

benjie commented Mar 29, 2022

Do it in a clean folder whose ancestors have no node_modules folders

@omar-dulaimi
Copy link

@benjie running it from root fixed the issue. Thank you!

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

No branches or pull requests

8 participants