Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

GraphiQL broken in production. Duplicate "graphql" modules. #11

Closed
a-barbieri opened this issue Nov 22, 2018 · 3 comments
Closed

GraphiQL broken in production. Duplicate "graphql" modules. #11

a-barbieri opened this issue Nov 22, 2018 · 3 comments

Comments

@a-barbieri
Copy link
Contributor

As @lufutu suggested is not possible to use GraphiQL in production. See this comment.

Bug

Accessing GraphiQL page I see only the loading... message and get this error:

Uncaught Error: Cannot use t "__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.

Which then create a second obvious error:

Uncaught ReferenceError: GraphiQL is not defined

How to reproduce it

  1. create a new Rails 5.2 application
  2. install Binda 0.1.10 and Binda API master
  3. deploy to production (on Heroku or anywhere with Capistrano)
  4. go to http://your.domain.com/admin_panel/graphiql
  5. check your browser console logs

Hint

The issue is probably due to GraphiQL Rails or GraphQL as they are the only responsible for injecting graphql as a dependency.

Versions

Rails 5.2
Binda 0.1.10
Binda API master (c0c6884)

@a-barbieri
Copy link
Contributor Author

I can confirm that the issue isn't present when using graphql-rails 1.4.11.

@a-barbieri
Copy link
Contributor Author

I opened a issue on graphiql-rails repo. Meanwhile I modify the gemspec to use 1.4.11 not the 1.5.

@a-barbieri
Copy link
Contributor Author

It's possible to temporarily fix this issue using version v0.1.4.alpha.1

gem "binda-api", github: "BindaCMS/binda-api", tag: "v0.1.4.alpha.1"

Just remember to change config/environments/production.rb from config.assets.js_compressor = :uglifier to config.assets.js_compressor = Uglifier.new(harmony: true)

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

No branches or pull requests

1 participant