Skip to content

Conversation

TimRoadley
Copy link

@TimRoadley TimRoadley commented Aug 23, 2025

Problem

This PR fixes issue 3330, where generated GraphQL output is wrong for mutation with array of customType.

Before the fix, resource.ts causes TodoUpsertInput to be generated incorrectly without an array type.

export type TodoUpsertInput = {
  content?: string | null,
  tags?: TodoTagTypeInput | null,
  updatedTs?: number | null,
};

After the fix, TodoUpsertInput is generated properly with the Array type:

export type TodoUpsertInput = {
  content?: string | null,
  tags?: Array< TodoTagTypeInput | null > | null,
  updatedTs?: number | null,
};

Note that this fix was required to generate the schema properly in the first place. Without this fix, the AppSync schema is generated incorrectly to begin with, setting up codegen for failure when it generates the client side code.

Changes

The only fixes required are in packages/data-schema/src/SchemaProcessor.ts, the other changes in this PR were required for the push to work and can otherwise ideally be ignored / omitted.

Validation

Unit tests have been added for this new functionality.

Checklist

  • [x ] If this PR includes a functional change to the runtime or type-level behavior of the code, I have added or updated automated test coverage for this change. (see Testing Strategy README)
  • [ x] If this PR requires a docs update, I have linked to that docs PR above. (not required)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

// Basic type structure verification - the exact shape is verified in runtime tests
const _typeCheck: ActualArgs = {} as ActualArgs;

// These assignments should work with your fix
Copy link
Member

@ahmedhamouda78 ahmedhamouda78 Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing this comment was generated by an LLM. Can you please review/remove all such comments?

Copy link
Member

@ahmedhamouda78 ahmedhamouda78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also please add the missing props to the "Enum" type on line 1422?

Copy link
Member

@ahmedhamouda78 ahmedhamouda78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please remove any unnecessary white space changes irrelevant to the fix itself from the PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding tests! Can you also add test coverage to the ModelSchema.test.ts file as it is more focused on testing custom operations argument inputs? You can refer to PR #617 for these tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generated GraphQL output is wrong for mutation with array of customType
2 participants