graphiql-rails: GraphiQL broken in production. Duplicate "graphql" modules.
We are using graphiql-rails as a dependency on one our gems.
From version 1.5 the graphiql page is broken. I can confirm that 1.4.11 along with graphql 1.8.10 works.
The error is present only in production environment. Development works. Might be something that happens during the assets precompile process.
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
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 28
- Comments: 38 (7 by maintainers)
Commits related to this issue
- Downgrade graphiql-rails GraphiQL web UI is not working on staging/production. Downgrading should fix this. https://github.com/rmosolgo/graphiql-rails/issues/58 — committed to anandaroop/portfolio18 by anandaroop 5 years ago
- Downgrade GraphiQL so it works in production https://github.com/rmosolgo/graphiql-rails/issues/58 — committed to coffeecoffeecoffeecoffee/coffee by jamescmartinez 5 years ago
Is everyone with this issue running production on Google Cloud Platform? 👍 for yes 👎 for no I’m not sure if GCP is respecting
NODE_ENV: productionfrom theapp.yamlfile when precompiling assets. I was following advice from https://github.com/howtographql/react-apollo/issues/33#issuecomment-426096917In my case, the issue involved Uglifier mangling variables in the javascript file. The following settings appear to work:
Make sure to update Uglifier to a version that supports the
mangleoption.@leechunhoe you need to update your production environment and set your js_compressor like this:
Don’t forget to
require 'uglifier'Concerning the Topic: 1.6.x is still causing the initial mentioned Bug in Production for me.
The same issue has occurred on Heroku.
For anyone else that gets here, the combination of
config.assets.js_compressor = Uglifier.new(harmony: true, mangle: false)and
worked for me
We just came across this in GitLab as well (https://gitlab.com/gitlab-org/gitlab-ce/issues/67293).
As described in https://github.com/graphql/graphql-js/issues/1182#issuecomment-354009213:
Disabling name mangling in
UglifyJsPluginviamangle: falsesounds like a possible workaround, but this may bloat the size of the JavaScript output.graphql-js added a fix to disable this check when
NODE_ENVis set toproduction(https://github.com/graphql/graphql-js/pull/1174).Normally, Webpack will set
NODE_ENVproperly and generate assets accordingly. However, if you are using Sprockets,NODE_ENVis never set to anything, so this check always gets hit if name mangling is in use.Perhaps this gem is no longer needed now that Rails 5 defaults to Webpacker (https://github.com/rails/webpacker). For those of us not using Webpacker, I wonder if we can work around this by defining a
NODE_ENVinside or patching the graphql-js code during asset compilation.Just Worked with the old version 😭 :
hmm upgraded to 1.7 did not change the error for me.
Hey everyone, I hope that upstream fixes and new configurations for the minifier worked alright. If anyone runs into this again, please open a new issue!
This works for me as well Thanks
We stopped using this gem and just directly use graphiql-js library.
Since the gem doesn’t seem to maintained anymore, does anyone have successfully implemented graphiql using webpacker?
I’m experiencing this issue on Heroku and have been able to duplicate locally in production mode. Using
mangle: falsedid not resolve my issue.Is there a long term fix in the works?
@mortik In that case, have you tried Altair? No integration within the app, just connect directly to any graphql endpoint, has subscriptions, etc.
We removed graphiql-rails from our Apps and are now using a html only version of the GraphiQL Playground from Prisma https://github.com/prisma/graphql-playground
The next step would be to use the React Component to build a customized Playground with Subscription support like you would get when you use Apollo Server or Absinthe from Elixir but in this case for Rails with ActionCable
Ah no problem i only read the notification mail which did not include the link ^^
graphiql-rails 1.6.0,graphql 1.8.11works okay in development, but shows following error when build production.I’m also having this issue. The error is not occurring in development, only in production.