aws-amplify / aws-amplify/amplify-codegen
Nested arrays of custom types being parsed incorrectly
- 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?
v20.12.1
### Amplify CLI Version
12.14.2
### What operating system are you using?
Mac
### Amplify Codegen Command
codegen
### Describe the bug
Generated types of nested arrays of a custom type are not correct.
Say I have this in my `schema.graphql`
```graphql
type Foo {
nestedArray: [[Bar!]!]!
}
type Bar {
bool: Boolean
}
```
and I run amplify codegen, I get the following in API.ts
```ts
export type Foo = {
nestedArray: Array<{
__typename: "Bar";
bool?: boolean | null;
}>;
}
export type Bar = {
__typename: "Bar";
bool?: boolean | null;
};
```
### Expected behavior
```ts
export type Foo = {
nestedArray: Array< Array<{
__typename: "Bar";
bool?: boolean | null;
}> >;
}
export type Bar = {
__typename: "Bar";
bool?: boolean | null;
};
```
### Reproduction steps
1. Add this to schema.graphql
```graphql
type Foo {
nestedArray: [[Bar!]!]!
}
type Bar {
bool: Boolean
}
```
2. Run `amplify codegen`
3. See generated types in API.ts
### GraphQL schema(s)
```graphql
type Foo {
nestedArray: [[Bar!]!]!
}
type Bar {
bool: Boolean
}
```
### Log output
```
# Put your logs below this line
```
### Additional information
Nested arrays of primitive types are being generated fine. Running codegen on
```graphql
type Foo {
nestedArray: [[String!]!]!
}
```
I get
```ts
export type Foo = {
nestedArray: Array>;
}
```
Contributor guide
Assessment
This issue has not been assessed yet.