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

fix(relation-transformer): relation field nullability in object and input type #817

Merged
merged 4 commits into from
Dec 2, 2022

Conversation

AaronZyLee
Copy link
Contributor

@AaronZyLee AaronZyLee commented Sep 20, 2022

Description of changes

Refactor the impact of non-nullable field with relation directive on the generated connection fields in object definition and input types.

  • Connection fields(foreign keys) will always be nullable in the UpdateInput type, which is consistent to other non-nullable fields.

Issue #, if available

Fix aws-amplify/amplify-codegen#461

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies

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

@AaronZyLee AaronZyLee requested a review from a team as a code owner September 20, 2022 23:50
@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2022

Codecov Report

Merging #817 (24da7fd) into main (be0850a) will increase coverage by 0.00%.
The diff coverage is 90.00%.

❗ Current head 24da7fd differs from pull request most recent head c48a885. Consider uploading reports for the commit c48a885 to get more accurate results

@@           Coverage Diff           @@
##             main     #817   +/-   ##
=======================================
  Coverage   63.30%   63.31%           
=======================================
  Files         282      282           
  Lines       18377    18383    +6     
  Branches     4461     4466    +5     
=======================================
+ Hits        11634    11639    +5     
- Misses       6132     6133    +1     
  Partials      611      611           
Impacted Files Coverage Δ
...plify-graphql-relational-transformer/src/schema.ts 93.25% <90.00%> (-0.25%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -262,6 +268,9 @@ export const ensureHasManyConnectionField = (
const relatedTypeObject = ctx.output.getType(relatedType.name.value) as ObjectTypeDefinitionNode;
const connectionAttributeName = getConnectionAttributeName(ctx.featureFlags, object.name.value, field.name.value, connectionFieldName);

// The nullabilty of connection fields for hasMany depends on the hasMany field
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I keep this as the original implementation. This is out of the scope of fixing the issue.

@phani-srikar phani-srikar merged commit 7345e6d into main Dec 2, 2022
@phani-srikar phani-srikar deleted the fix-relation-nonnull branch December 2, 2022 18:17
@phani-srikar phani-srikar mentioned this pull request Dec 2, 2022
5 tasks
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.

Foreign key fields (@hasOne) required in generated Update Input type
4 participants