aws-appsync-codegen icon indicating copy to clipboard operation
aws-appsync-codegen copied to clipboard

Removed generation of double Optionals for properties of Input type

Open MarioBajr opened this issue 6 years ago • 4 comments

For objects of type Input, the Swift code generation is creating unnecessary layers of Optionality for all Optional properties.

Given this GraphQL input type

input ReviewInput {
    stars: Int!
    commentary: String
    favoriteColor: ColorInput
}

The code generated has two layers of Optionality. eg: Optional<String?>

public struct ReviewInput: GraphQLMapConvertible {
    public init(stars: Int, 
                commentary: Optional<String?> = nil, 
                favoriteColor: Optional<ColorInput?> = nil) {
        ...
    }
}

This PR replaces to a single Optionality level, aligning with all other generated types.

public struct ReviewInput: GraphQLMapConvertible {
    public init(stars: Int, 
                commentary: String? = nil, 
                favoriteColor: ColorInput? = nil) {
        ...
    }
}

MarioBajr avatar Jul 04 '18 12:07 MarioBajr

Thanks @MarioBajr ,

I will discuss with the team about the change and update you with the decision.

minbi avatar Jul 05 '18 21:07 minbi

Hello @MarioBajr

We will be retiring this repo soon as the new [AWS Amplify CLI](url https://github.com/aws-amplify/amplify-cli) has the codegen features, improvements, and more, including automatic graphql generation as well as a GraphQL transformer: https://github.com/aws-amplify/amplify-cli/blob/master/native_guide.md

Could you look to see if the new AWS Amplify CLI flow resolves your issue and if not open something in that repo?

frankmuellr avatar Oct 03 '18 21:10 frankmuellr

Hi @muellerfr, thanks for the updates, while evaluating amplify-cli, I found that this project (aws-appsync-codegen) is imported as a dependency, being the responsible for the Swift code generation. https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-codegen/package.json#L17 https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-codegen/src/commands/types.js#L39

Is the new codegen feature that you guys are planning to use available anywhere else? Cheers

MarioBajr avatar Oct 04 '18 12:10 MarioBajr

Hi @MarioBajr, we will merge this change into the https://github.com/aws-amplify/amplify-cli repo, where this code now lives.

frankmuellr avatar Nov 14 '18 01:11 frankmuellr