Skip to content

Cannot generate code using amplify codegen after 12.4.0 #764

@cmeyer90

Description

@cmeyer90

How did you install the Amplify CLI?

npm

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

21.2.0

Amplify CLI Version

12.8.2

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Describe the bug

I am able to use amplify codegen in a non-amplify directory with 12.4.0 but not with 12.8.2.

I developed a cloud backend with AWS CDK and deployed an appsync graphql api. I would like to use that api in my swift project on iOS.

When running amplify codegen on 12.4.0, the API.swift file generates fine from my schema.graphql

When running amplify codegen on 12.8.2, an error is generated:

Syntax Error: Unexpected <EOF> (4:1)
  2 | 
  3 | 
> 4 | 
    | ^

My schema.graphql looks like the following:

type Bundle {
  bundleId: ID!
  imageUrl: String
  metadata: String
  assets: S3Object
}

type S3Object {
  bucket: String!
  region: String!
  key: String!
  localUri: String!
  mimeType: String!
}

input CreateBundleInput {
  imageUrl: String!
  metadata: String!
  assets: S3ObjectInput
}

input S3ObjectInput {
  bucket: String!
  region: String!
  key: String!
  localUri: String!
  mimeType: String!
}

type Query {
  getBundleById(bundleId: ID!): Bundle
}

type Mutation {
  createBundle(input: CreateBundleInput!): Bundle
}

If this isn't proper usage, would anyone be able to kindly guide me?

Expected behavior

amplify codegen should generate an API.swift file

Reproduction steps

  1. Install the amplify cli using npm install -g @aws-amplify/cli
  2. In a new directory, add this schema.graphql file:
type Bundle {
  bundleId: ID!
  imageUrl: String
  metadata: String
  assets: S3Object
}

type S3Object {
  bucket: String!
  region: String!
  key: String!
  localUri: String!
  mimeType: String!
}

input CreateBundleInput {
  imageUrl: String!
  metadata: String!
  assets: S3ObjectInput
}

input S3ObjectInput {
  bucket: String!
  region: String!
  key: String!
  localUri: String!
  mimeType: String!
}

type Query {
  getBundleById(bundleId: ID!): Bundle
}

type Mutation {
  createBundle(input: CreateBundleInput!): Bundle
}
  1. Run amplify codegen add. Select 'ios', and use the defaults for the questions that follow.

Project Identifier

No response

Log output

Details
# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

Metadata

Metadata

Assignees

No one assigned

    Labels

    transferredIssue has been transferred from another Amplify repository

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions