artemkloko / amplify-graphql-fragments-generator

Generate GraphQL fragments and statements (query, mutations and subscriptions) for the provided introspection schema
11 stars 2 forks source link

Cannot find module 'amplify-codegen/src/codegen-config' #1

Open jcbdev opened 3 years ago

jcbdev commented 3 years ago

First of all - Nice work! I've been looking for this exact type of thing for ages!

Unfortunately for me I get the following error when running the generate command:

Cannot find module 'amplify-codegen/src/codegen-config'
Require stack:
- /usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/commands/generate.js
- /usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/index.js
- /usr/local/lib/node_modules/@aws-amplify/cli/lib/execution-manager.js
- /usr/local/lib/node_modules/@aws-amplify/cli/lib/index.js
- /usr/local/lib/node_modules/@aws-amplify/cli/bin/amplify
/usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/commands/generate.js:1
Error: Cannot find module 'amplify-codegen/src/codegen-config'
Require stack:
- /usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/commands/generate.js
- /usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/index.js
- /usr/local/lib/node_modules/@aws-amplify/cli/lib/execution-manager.js
- /usr/local/lib/node_modules/@aws-amplify/cli/lib/index.js
- /usr/local/lib/node_modules/@aws-amplify/cli/bin/amplify
    at Object.<anonymous> (/usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/commands/generate.js:27:42)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)

This probably means you need to 'amplify-codegen' as a dependency in the package.json

Unfortunately even after installing globally npm install -g amplify-codegen I get the following call stack issue:

Generated fragments and statements successfully and saved at /Users/jimbo/Projects/roar/packages/core/graphql
(node:3627) UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded
    at getType (/usr/local/lib/node_modules/amplify-graphql-fragments-generator/node_modules/amplify-graphql-docs-generator/lib/generator/utils/getType.js:4:17)
    at Object.getType [as default] (/usr/local/lib/node_modules/amplify-graphql-fragments-generator/node_modules/amplify-graphql-docs-generator/lib/generator/utils/getType.js:6:16)
    at Object.getFields (/usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/generator/getFields.js:16:40)
    at /usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/generator/getFragment.js:16:37
    at Array.map (<anonymous>)
    at Object.getFragment (/usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/generator/getFragment.js:16:10)
    at Object.getFields (/usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/generator/getFields.js:43:40)
    at /usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/generator/getFragment.js:16:37
    at Array.map (<anonymous>)
    at Object.getFragment (/usr/local/lib/node_modules/amplify-graphql-fragments-generator/lib/generator/getFragment.js:16:10)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3627) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3627) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Maybe my schema has a self-referencing model or two models which reference each other and its getting caught in a recursive loop?

artemkloko commented 3 years ago

Thank you! @jcbdev could you please try the 1-cannot-find-codegen-and-maxDepth-bug-build branch? You can do so by running the following

yarn global add amplify-graphql-fragments-generator@https://github.com/artemkloko/amplify-graphql-fragments-generator.git\#1-cannot-find-codegen-and-maxDepth-bug-build
amplify codegen-with-fragments generate
jcbdev commented 3 years ago

@artemkloko Awesome thanks! I will try it out in the next few weeks but I am super busy at the moment!

dmdmd commented 3 years ago

@artemkloko I got the same error. Running your commands didn't work. Is there a way to double-check if I the correct version of the plugin was installed?