amplify-js: @aws-amplify/api: export 'GraphQLError' was not found in 'graphql'
Describe the bug When I try to build my typescript react app, I get the following error:
ERROR in ./node_modules/@aws-amplify/api/lib-esm/API.js 543:40-52
"export 'GraphQLError' was not found in 'graphql'
@ ./node_modules/@aws-amplify/api/lib-esm/index.js
@ ./node_modules/aws-amplify/lib/index.js
@ ./src/pages/ForgotPassword/index.tsx
@ ./src/routes.ts
@ ./src/components/Routes.tsx
@ ./src/App.tsx
@ ./src/client/index.tsx
@ multi regenerator-runtime/runtime ./src/client/index.tsx
ERROR in ./node_modules/@aws-amplify/api/lib-esm/API.js 560:41-53
"export 'GraphQLError' was not found in 'graphql'
@ ./node_modules/@aws-amplify/api/lib-esm/index.js
@ ./node_modules/aws-amplify/lib/index.js
@ ./src/pages/ForgotPassword/index.tsx
@ ./src/routes.ts
@ ./src/components/Routes.tsx
@ ./src/App.tsx
@ ./src/client/index.tsx
@ multi regenerator-runtime/runtime ./src/client/index.tsx
ERROR in ./node_modules/@aws-amplify/api/lib-esm/API.js 607:65-77
"export 'GraphQLError' was not found in 'graphql'
@ ./node_modules/@aws-amplify/api/lib-esm/index.js
@ ./node_modules/aws-amplify/lib/index.js
@ ./src/pages/ForgotPassword/index.tsx
@ ./src/routes.ts
@ ./src/components/Routes.tsx
@ ./src/App.tsx
@ ./src/client/index.tsx
@ multi regenerator-runtime/runtime ./src/client/index.tsx
It looks like aws-amplify can’t find graphql components.
To Reproduce Steps to reproduce the behavior:
npm run installnpm run dev(ts-node -T -O '{\"module\": \"commonjs\"}' --transpileOnly internal/scripts/build -- --optimize)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 28 (3 by maintainers)
Update: I solved this by updating my webpack config. I moved
.mjsto come before.jsin my resolve extensions, and I also did not have.mjsfiles excluded in my file-loader configand my file loader:
Hope this helps!
Also, if anyone has an explanation as to why the order of resolve extensions matters, I’d love to know.
Angular could provide a workaround but it seems that it is not their problem. Graphql-js should adapt their configuration for Webpack 5.
Ok I re-re-re read thru a lot of posts. Looks like 12.0.0-beta.0 with the
fullySpecified: falsevs listing out extensions got rid of the graphql errors.crypto w/ cognito was still an issue. Its unclear if amplify needs crypto in the polyfill so I’ll dive into that further. Prior I had
browser { crypto: false}in the package.json so I went ahead and addedfallback: { crypto: false }to the custom-webpack.config.js. custom-webpack.config.js:angular.jsonreally should be aymlorjsfile if we are going to get into heavy mods. No comments in JSON is disqualifying. 😃Just left with -
Update: this was fixed by adding that package to my pre-existing list from Angular 11 (angular.json):
The custom webpack doesn’t work when compilng for production because it’s version 4, so this is what’s working for me now.
@angular-builders/custom-webpack@12.0.0-beta.0- this includes webpack 5custom-webpack.config.jsin your root folder with the following in it:angular.json, replace the following:The problem is here : https://github.com/graphql/graphql-js/issues/2721