Skip to content

Nested arrays of custom types being parsed incorrectly #951

Description

@mohammedsahl

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • 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

type Foo {
  nestedArray: [[Bar!]!]!
}

type Bar {
  bool: Boolean
}

and I run amplify codegen, I get the following in API.ts

export type Foo = {
  nestedArray: Array<{
    __typename: "Bar";
    bool?: boolean | null;
  }>;
}

export type Bar = {
  __typename: "Bar";
  bool?: boolean | null;
};

Expected behavior

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
type Foo {
  nestedArray: [[Bar!]!]!
}

type Bar {
  bool: Boolean
}
  1. Run amplify codegen
  2. See generated types in API.ts

GraphQL schema(s)

Details
type Foo {
  nestedArray: [[Bar!]!]!
}

type Bar {
  bool: Boolean
}

Log output

Details
# Put your logs below this line


Additional information

Nested arrays of primitive types are being generated fine. Running codegen on

type Foo {
  nestedArray: [[String!]!]!
}

I get

export type Foo = {
  nestedArray: Array<Array<string>>;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions