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

ra-data-graphql broken with enabled mangle in Webpack #1640

Closed
byymster opened this issue Mar 12, 2018 · 4 comments
Closed

ra-data-graphql broken with enabled mangle in Webpack #1640

byymster opened this issue Mar 12, 2018 · 4 comments

Comments

@byymster
Copy link
Contributor

What you were expecting:
When I build project for production(react-scripts build or build with Webpack with enabled mangling in Uglify plugin) project is working

What happened instead:
Page loads with console error:
`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.`

Steps to reproduce:

  • go to examples/graphcool-demo
  • make npm run build
  • start webserver eg. npx http-server build
  • see issue in console

Related code:
Developers of graphql-js respond here that issue is fixed in 0.13/0.13.1 version

Environment

  • Admin-on-rest version: 2.0.0-beta3
  • ra-data-graphql-simple: 2.0.0-beta3
  • ra-data-graphql: 2.0.0-beta3
  • React version: 16.2.0
  • Browser: any
@byymster byymster changed the title ra-data-graphql broken with enabled mange in Webpack ra-data-graphql broken with enabled mangle in Webpack Mar 12, 2018
@fzaninotto
Copy link
Member

ping @djhi I can't reproduce this one, can you take a look?

@jonasho
Copy link

jonasho commented Mar 24, 2018

Ran into the same issue.

It happens because ra-data-graphql has a direct dependency on graphql. If you have installed graphql with a different version also in your main project you will get 2 versions in your final build an this error occurs.
If you are using yarn you could set the following options in your package.json to resolve graphql always to the same Version.

"resolutions": {
"/graphql": "^0.13.1" /or whatever version you are using/,
"
/graphql-tag": "^2.8.0",
"**/apollo-client": "^2.2.6"
}

Also maybe the react-admin Team could make graphql a peer dependency instead.

@Ashenback
Copy link

I ran into the same issue though only having one version of graphql.

Using react-create-app and react-admin:

  • react-scripts: 2.0.0-next.9754a231
  • react-admin: 2.0.0-beta4
  • ra-data-graphql-simple: 2.0.0-beta4
    ra-data-graphql: 2.0.0-beta4
    graphql: 0.12.3
  • react: 16.2.0

Tried using the resolutions directive in package.json, and it didn't help, and my guess is that it is due to the fact that I only have one version of graphql.

Not sure if making graphql a peer dependency of ra-data-graphql would work better as it will still one version of graphql, but the main project will decide which version that would be.

@fzaninotto
Copy link
Member

Fixed by #1719

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

4 participants