aws-amplify / amplify-codegen

Amplify Codegen is a JavaScript toolkit library for frontend and mobile developers building Amplify applications.
Apache License 2.0
59 stars 57 forks source link

fix: java builder steps to respect handleListNullabilityTransparently #830

Closed dpilch closed 2 months ago

dpilch commented 2 months ago

Description of changes

The java builder steps did not respect handleListNullabilityTransparently. This was an issue because the code generation for the builder step interfaces did respect handleListNullabilityTransparently. This would sometimes result in a case where a builder step was created but the interface for the builder step was not created.

For the following model when handleListNullabilityTransparently is true, the builder step would be crated but the interface would not be created resulting in compilation error.

type Foo @model {
  items: [String!]
}

Interface creation: https://github.com/aws-amplify/amplify-codegen/blob/a909ff333af7513c6babfa8cf5f6cfce57e854e5/packages/appsync-modelgen-plugin/src/visitors/appsync-java-visitor.ts#L412-L419

Builder step creation: https://github.com/aws-amplify/amplify-codegen/blob/a909ff333af7513c6babfa8cf5f6cfce57e854e5/packages/appsync-modelgen-plugin/src/visitors/appsync-java-visitor.ts#L949-L955

This is only an issue when handleListNullabilityTransparently is true, there is a field with required element optional list ([String!]), and there is no required field before the list field.

This would not have the issue

type Foo @model {
  someRequiredField: String!
  items: [String!]
}

Codegen Paramaters Changed or Added

N/A

Issue #, if available

N/A

Description of how you validated changes

Checklist

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