Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws-cdk/aws-appsync): Union type definition fields suffixed with "id" #17771

Closed
fab-mindflow opened this issue Nov 30, 2021 · 4 comments · Fixed by #17787
Closed

(aws-cdk/aws-appsync): Union type definition fields suffixed with "id" #17771

fab-mindflow opened this issue Nov 30, 2021 · 4 comments · Fixed by #17787
Assignees
Labels
@aws-cdk/aws-appsync Related to AWS AppSync bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@fab-mindflow
Copy link

fab-mindflow commented Nov 30, 2021

What is the problem?

Union type definition is generated with a weird "id" suffix. Maybe there is a reason?

this.definition[options.field?.toString() + 'id'] = options.field;

Consequently, some of our union type are generated in GraphQL (as we have an advanced code first pre-processing using CDK AppSync) like this:

input UpdatePayloadInput {
  Type1id: Type1Input
  Type2id: Type2Input
}

Reproduction Steps

Build a Union type:

    const TypeUnion = new appsync.UnionType("TypeUnion", {
      definition: [
        Type1,
        Type2,
      ],
    })


   console.log(TypeUnion.definition)

This gives out:

{
  Type1id: GraphqlType {
    type: 'INTERMEDIATE',
    // ...
    }
  },
  Type2id: GraphqlType {
    type: 'INTERMEDIATE',
    // ...
    }
  }
}

What did you expect to happen?

Definition does not contain the "id" suffix.

What actually happened?

"id" is appended to the union type definition.

CDK CLI Version

1.134.0

Framework Version

No response

Node.js Version

16.13.0

OS

macOS 12.0.1 (Monterey)

Language

Typescript

Language Version

4.4.3

Other information

No response

@fab-mindflow fab-mindflow added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 30, 2021
@github-actions github-actions bot added the @aws-cdk/aws-appsync Related to AWS AppSync label Nov 30, 2021
@otaviomacedo
Copy link
Contributor

@BryanPan342 do you remember what was the reason for this suffix?

@ryparker ryparker added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Nov 30, 2021
@BryanPan342
Copy link
Contributor

Hm quite frankly i can't remember why i added the 'id' suffix. I think it might have tried to serve as a catchall if the field didnt exists.. but that doesnt make sense because i made a check beforehand. I dont see any problem changing it to remove the suffix.

Also i didnt really think about people using the definition function so this is actuall pretty interesting.

@fab-mindflow
Copy link
Author

fab-mindflow commented Dec 3, 2021

Also i didnt really think about people using the definition function so this is actuall pretty interesting.

To be honest, that's because we are doing uncommon usage of this module by generating a lot of GraphQL stuff (applying Relay best pratiques to the generated GraphQL such as input types, payload types, pagination, etc... For now we have just filtered the output from definition to make it work)

Hope the module to go out from experimental soon - it works pretty well for our code first usage btw.

@mergify mergify bot closed this as completed in #17787 Dec 6, 2021
mergify bot pushed a commit that referenced this issue Dec 6, 2021
Removing an unnecessary suffix from union definitions.

Fixes: #17771 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Dec 6, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
Removing an unnecessary suffix from union definitions.

Fixes: aws#17771 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-appsync Related to AWS AppSync bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants