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

GraphQL error - Cannot use e "__Schema" from another module or realm. #1445

Closed
vivekFAGH opened this issue Aug 14, 2018 · 26 comments
Closed
Assignees
Labels
investigating This issue is being investigated pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days.

Comments

@vivekFAGH
Copy link

Do you want to request a feature or report a bug?
Maybe a bug

What is the current behavior?
Using a ionic 3 app and amplify 1.0.5 on android and ios. I get the following graphql error:

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 t.a (vendor.js:1)
at h (vendor.js:1)
at l (vendor.js:1)
at F (vendor.js:1)
at q (vendor.js:1)
at new u (vendor.js:1)
at u (vendor.js:1)
at Object. (vendor.js:1)
at t (vendor.js:1)
at Object. (vendor.js:1)

I checked and do not see any other graphql version installed. A debug build works as expected, while a release build with ionic cli 3.2 does not work and results in a white screen with the error above.

npm ls graphql
\ionic\myapp
-- aws-amplify@1.0.5 -- @aws-amplify/api@1.0.5
`-- graphql@0.13.0

Anyone else see this?

@manueliglesias manueliglesias added bug Something isn't working investigating This issue is being investigated and removed bug Something isn't working labels Aug 15, 2018
@haverchuck
Copy link
Contributor

haverchuck commented Aug 15, 2018

Hi @vivekFAGH ,

Thanks for reporting this. Have you updated either your version of GraphQL or your version of Amplify recently?

That's not a suggestion - just trying to get more info.

@vivekFAGH
Copy link
Author

I do not have any other version of graphql, but yes, I have been trying to upgrade amplify from 0.4.8 to 1.0.x without success. A clean install of the app after clearing cache still results in this error. If it helps, the only way i do not see this error after installing version 1.0.5, or 1.0.6, is by excluding the minifyjs flag, So,

ionic cordova build android --prod --release
---- Does not work

Building without the --prod flag
ionic cordova build android --aot --uglifyjs --minifyjs--minifycss --optimizeJs --release
-- Does not work

but, this works as expected:
ionic cordova build android --aot --uglifyjs --minifycss --optimizeJs --release

@johneast
Copy link

I get the same issue with ionic 3, aws-amplify 1.0.6 and aws-amplify-angular 1.0.4-unstable.2 see #1003

The issue was reported as closed with 1.0.4-unstable.0, but I think that's only with ionic 4. The problem still persists in ionic 3

@vivekFAGH
Copy link
Author

I have since tested this with earlier versions of amplify ( upto 1.0.3) and ionic app scripts, its still a problem.

@johneast
Copy link

I have been able to get around the issue by using the modular imports of amplify, rather than importing the entire amplify service.

@vivekFAGH
Copy link
Author

I am using module imports as well, but still see the error. Any related changes you had to make?

@vivekFAGH
Copy link
Author

@johneast I saw your other post about how you resolved the error. I am using the API import in my code which has a dependency on graphql.

@moldstadt
Copy link

I am also seeing this error, and also using the API import, so need a different solution.

Using --aot --uglifyjs --minifycss --optimizeJs works, but the output is significantly bigger.

Is it perhaps possible to exclude only the aws-amplify module from minification?

@edgarelc
Copy link

edgarelc commented Sep 3, 2018

I'm also facing this issue. I tried aws-amplify 1.0.8 and aws-amplify-angular 2.0.0 and it still doesn't work. I did some digging in my node_modules folder and I found that AWS Amplify defines graphql version 0.11.7 in its package-lock.json file (node_modules/aws-amplify/package-lock.json) but the API module uses 0.13.0 in its package.json file (node_modules/@aws-amplify/api/package.json). That might be the problem. Still haven't found a solution...

Any other information/suggestion is appreciated :)

@blakeage
Copy link

blakeage commented Sep 4, 2018

I have the same issue. We're using Amplify 1.0.8 and Expo/React Native, and when starting Expo with --minify option, we get the same error in the simulator. It works fine if it's not minified. We're also including the API module, which depends on GraphQL.

@mbunge
Copy link

mbunge commented Sep 21, 2018

Same here for latest Ionic 3.9.2 and Angular 5.2.11.

Building with --minifyjs flag leads to mentioned error.

Current build environment for reference:

Ionic:

   ionic (Ionic CLI)  : 4.1.2
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.1.0, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-webview 2.1.4, (and 13 other plugins)

System:

   Android SDK Tools : 26.1.1
   ios-deploy        : 1.9.2
   NodeJS            : v10.7.0
   npm               : 6.4.1
   OS                : macOS High Sierra
   Xcode             : Xcode 9.3.1 Build version 9E501

@edgarelc
Copy link

edgarelc commented Oct 2, 2018

Any news on this issue? Still having problems with ionic 3 when building prod builds. I'm using aws-amplify version 1.1.4 and aws-amplify-angular version 2.0.7

@ciekawy
Copy link

ciekawy commented Oct 10, 2018

the problem is caused by graphql/graphql-js#1182 - currently suggested solution is to use NODE_ENV=production which does not make sense for mobile app as this is a static bundle served from a device filesystem. I recommend to put a comment in graphql-js ticket or open a new one.

As I experience same issue with my own Ionic project, for now I downgraded graphql to v 0.11.7 and the issue is gone.

@L0key
Copy link

L0key commented Nov 16, 2018

the problem is caused by graphql/graphql-js#1182 - currently suggested solution is to use NODE_ENV=production which does not make sense for mobile app as this is a static bundle served from a device filesystem. I recommend to put a comment in graphql-js ticket or open a new one.

As I experience same issue with my own Ionic project, for now I downgraded graphql to v 0.11.7 and the issue is gone.

Stuck here... Downgrade to 0.11.7 didn't help. Any ideas?

@haverchuck
Copy link
Contributor

@ciekawy - I actually experienced some success with the NODE_ENV=production solution (at least on an emulator).

@haverchuck
Copy link
Contributor

haverchuck commented Dec 28, 2018

This is realted to #2275 . In troubleshooting that issue, I was able to reproduce the error with two combinations of build arguments, and fix both of them by prepending NODE_ENV=production, i.e.

  • NODE_ENV=production ionic cordova run android --prod --device
  • NODE_ENV=production ionic cordova run android --aot --uglifyjs --minifyjs --minifycss --optimizeJs --device

You might also need to put the following into your package.json:

"resolutions": {
     "graphql": "0.13.0"
},

@haverchuck haverchuck added the pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. label Dec 28, 2018
@jmannau
Copy link

jmannau commented Apr 4, 2019

For anyone experiencing this problem and finding that setting NODE_ENV when running ionic build like NODE_ENV=production ionic build --prod doesn't work, you can fix this by using webpack to inject process.env.NODE_ENV into the build package. I wrote up how I did this here - https://gist.github.com/jmannau/8039787e29190f751aa971b4a91a8901

@mikan3rd
Copy link

mikan3rd commented Oct 9, 2019

I have same issue when NODE_ENV is NOT 'production'.
I'm not sure, but I can fix it by downgrading graphql to 0.11.7.

  "resolutions": {
    "graphql": "0.11.7"
  },

@loganpowell
Copy link

I just got this same error, but I'm not using Ionic. I am using Parcel along with these dependencies in my package.json:

  "dependencies": {
    "@workpop/graphql-proxy": "^2.4.0",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "graphql-playground-middleware-express": "^1.7.18",
  },

Would it be possible to reopen the issue? Setting NODE_ENV=production did not work for me 😭

@codemaster08240328
Copy link

I am facing this issue.
I used amplify in my react web app, not used graphql.
Please help me.

@neiker
Copy link

neiker commented Oct 20, 2020

Same problem on an Expo app and using NODE_ENV=production solves it

@ciekawy
Copy link

ciekawy commented Oct 21, 2020

just NODE_ENV=production has very little sense for ionic app loaded directly from mobile device :D

@benjamn
Copy link

benjamn commented Jan 26, 2021

Just submitted this graphql-js PR to solve this problem in non-production environments where minification is enabled (such as NODE_ENV=staging). Please have a look!

@liviaalmeida
Copy link

I've had this problem for AGES. Using NODE_ENV=production is not a good solution, since we have separate endpoints for each environment and we didn't want to mess up the metrics. Then I removed devtool: 'source-map' from configureWebpack (we use Vue) and the problem was gone. Maybe that helps someone.

@bgeshk
Copy link

bgeshk commented Mar 23, 2022

I ran into this problem as well. I created a new amplify app through CloudFormation with the same name property as an existing app. The new app (despite the duplicate name) showed up within Amplify and was able to provision/build/deploy it, but ran into the aforementioned error. Deleting the new app from Amplify and redeploying with a new name within CloudFormation fixed the issue for me

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
investigating This issue is being investigated pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days.
Projects
None yet
Development

No branches or pull requests