question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

amplify codegen add gives error: 'The "path" argument must be of type string'

See original GitHub issue

Describe the bug Error when adding an existing API to codegen.

amplify codegen add --apiId XXXMyApiIdXXXX

adds “api” section to amplify-meta.json files but then terminates with error:

$ amplify codegen add --apiId XXXXXXX
✔ Getting API details
✖ Getting API details
The "path" argument must be of type string. Received type undefined

Trying to get it up and running using statements command i got a callstack:

/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/index.js:13
    throw up;
    ^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at assertPath (path.js:39:11)
    at Object.join (path.js:1155:7)
    at projects.forEach (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-codegen/src/commands/statements.js:19:31)
    at Array.forEach (<anonymous>)
    at Object.generateStatements (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-codegen/src/commands/statements.js:18:12)
    at Command.run (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-codegen/commands/codegen/statements.js:11:21)
    at Runtime.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:90:58)
    at step (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:32:23)
    at Object.next (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:13:53)
    at /usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:7:71 

To Reproduce Steps to reproduce the behavior:

  1. A project with no API managed by CFN
  2. type $ amplify codegen add --apiId XXXXXX to add an API that has been created with AppSync console before.

Expected behavior The command should successfully add the external API.

Desktop (please complete the following information):

  • OS: macOS
  • Amplify CLI 1.1.7

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kochetkovITcommented, Mar 17, 2019

Just had similar problem. Solved it by adding projectPath attribute in <project_root>/amplify/.config/local-env-info.json with a valid path, worked both absolute and relative paths for me.

0reactions
github-actions[bot]commented, May 27, 2021

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 for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API (GraphQL) - Client code generation - AWS Amplify Docs
Codegen helps you generate native code for iOS and Android, as well as the generation of types for Flow and TypeScript. It can...
Read more >
The "path" argument must be of type string or an instance of ...
Apparently, config.outputFolder is undefined at that point. You could confirm this by logging its value before running fs.mkDirSync . Share.
Read more >
TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
Read more >
GraphQL error handling to the max with Typescript, codegen ...
We'll see in this article how to: achieve a better error representation than the default offered by GraphQL; get type safety using Typescript ......
Read more >
GraphQL Code Libraries, Tools and Services
Add any type specific cache control directives in the format: ... GitHubaws-amplify/amplify-js ... Tiny GraphQL client library using template strings.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found