aws-amplify / aws-amplify/amplify-codegen

Cannot use 'in' operator to search for 'name' in amplify codegen [UPDATE]

Open
#787 6 comments 1 reaction 0 assignees View on GitHub
feature-request
Dominant language
TypeScript
Stars
59
Forks
64
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-codegen/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-codegen/blob/main/CONTRIBUTING.md#bugs).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### How did you install the Amplify CLI?

npm

### If applicable, what version of Node.js are you using?

16.19.0

### Amplify CLI Version

12.10.1 / 10.8.1

### What operating system are you using?

Mac

### Amplify Codegen Command

codegen

### Describe the bug

Hello, everyone.

I checked [this](https://github.com/aws-amplify/amplify-cli/issues/13338) issue that was opened recently but even with the [suggested fix](https://github.com/aws-amplify/amplify-cli/issues/13338#issuecomment-1766644288) for me it did not work.

I tried to upgrade the CLI to the 12.10.1 but still got the same error.

`Cannot use 'in' operator to search for 'name' in amplify codegen`

I tried also to downgrade to the `10.8.1`, the error changed to:

```
Could not parse graphql operations in src/graphql/customQueries.ts
Failed on : amplify codegen
```

Then, since the second error was more explicit with the word `parse` I started to look what could be possibly the cause, and I noticed that my `customQueries.ts` had a multiline comment at the top of the file. I removed the comment and codegen worked.
So it seems that the parser was having a bad time parsing the file because I suspect that the `/* */` was expecting a graphql statement and instead it was just a comment.

I hope to help someone who will encountered the same issue. If i inspected correctly the code correctly the parsing is done by [graphql ](https://www.npmjs.com/package/graphql) so It is not an issue releated to codegen itself.

### Expected behavior

Maybe it should be said explicitly that the file should have no comments at all.

### Reproduction steps

1. create a file with custom queries inside the `/graphql` folder
2. write some `/*multiline*/` comment at the start of the file
3. write some graphql queries.
4. run amplify codegen to generate the types.
5. the error should appear.
6. remove the multiline comment at the top of the file
7. errors should disappear and codegen should run succefully

### GraphQL schema(s)

```graphql
# Put schemas below this line

```

### Log output

```
# Put your logs below this line

```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.