1
votes

After modifying my appsync schema on aws console, I am trying to run the 'amplify codegen' cli command in order to update my local project files. However, I obtain the following error:

amplify codegen
- Downloading the introspection schema
√ Downloaded the schema
- Generating GraphQL operations
- Generating
undefined
√ Code generated successfully and saved in file
2018-10-29T10:48:28.717Z - error: uncaughtException: GraphQL schema file should contain a valid GraphQL introspection query result date=Mon Oct 29 2018 18:48:28 GMT+0800 (Malay Peninsula Standard Time), pid=4768, uid=null, gid=null, cwd=C:\code_repo\dir\a\react-dashboard, execPath=C:\Program Files\nodejs\node.exe, version=v8.10.0, argv=[C:\Program Files\nodejs\node.exe, C:\Program Files\nodejs\node_modules\@aws-amplify\cli\bin\amplify, codegen], rss=126963712, heapTotal=103223296, heapUsed=79488616, external=390282, loadavg=[0, 0, 0], uptime=1068500.4532678, trace=[column=11, file=C:\Users\kaustavg\amplify-launch\amplify-cli\packages\amplify-graphql-docs-generator\src\generator\generate.ts, function=Object.generate [as default], line=19, method=generate [as default], native=false, column=57, file=C:\Users\kaustavg\amplify-launch\amplify-cli\packages\amplify-graphql-docs-generator\src\index.ts, function=generate, line=43, method=null, native=false, column=11, file=C:\Users\Alex\AppData\Roaming\nvm\v8.10.0\node_modules\@aws-amplify\cli\node_modules\amplify-codegen\src\commands\statements.js, function=projects.forEach, line=35, method=forEach, native=false, column=null, file=null, function=Array.forEach, line=null, method=forEach, native=false, column=12, file=C:\Users\Alex\AppData\Roaming\nvm\v8.10.0\node_modules\@aws-amplify\cli\node_modules\amplify-codegen\src\commands\statements.js, function=generateStatements, line=17, method=null, native=false, column=9, file=C:\Users\Alex\AppData\Roaming\nvm\v8.10.0\node_modules\@aws-amplify\cli\node_modules\amplify-codegen\src\commands\generateStatementsAndType.js, function=Object.generateStatementsAndTypes [as generate], line=27, method=generateStatementsAndTypes [as generate], native=false, column=null, file=null, function=null, line=null, method=null, native=false, column=7, file=internal/process/next_tick.js, function=process._tickDomainCallback, line=228, method=_tickDomainCallback, native=false], stack=[Error: GraphQL schema file should contain a valid GraphQL introspection query result,     at Object.generate [as default] (C:\Users\kaustavg\amplify-launch\amplify-cli\packages\amplify-graphql-docs-generator\src\generator\generate.ts:19:11),     at generate (C:\Users\kaustavg\amplify-launch\amplify-cli\packages\amplify-graphql-docs-generator\src\index.ts:43:57),     at projects.forEach (C:\Users\Alex\AppData\Roaming\nvm\v8.10.0\node_modules\@aws-amplify\cli\node_modules\amplify-codegen\src\commands\statements.js:35:11),     at Array.forEach (<anonymous>),     at generateStatements (C:\Users\Alex\AppData\Roaming\nvm\v8.10.0\node_modules\@aws-amplify\cli\node_modules\amplify-codegen\src\commands\statements.js:17:12),     at Object.generateStatementsAndTypes [as generate] (C:\Users\Alex\AppData\Roaming\nvm\v8.10.0\node_modules\@aws-amplify\cli\node_modules\amplify-codegen\src\commands\generateStatementsAndType.js:27:9),     at <anonymous>,     at process._tickDomainCallback (internal/process/next_tick.js:228:7)]

What is causing this to happen?

1

1 Answers

1
votes

I had similar problem when I was trying to move my project from one computer to another.

At first I thought it to be a memory error because it was error out during the generation process.

The thing that resolved the error for me was by installing the GraphQL package.

It turns out when installing the amplify package with npm, it would display the requirement for graphql, but it doesn't if you use yarn instead.