-
Notifications
You must be signed in to change notification settings - Fork 821
fix(amplify-codegen-appsync-model-plugin): DataStore Array Support #5327
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5327 +/- ##
=======================================
Coverage 59.86% 59.86%
=======================================
Files 391 391
Lines 17469 17473 +4
Branches 3470 3472 +2
=======================================
+ Hits 10458 10461 +3
- Misses 6388 6389 +1
Partials 623 623
Continue to review full report at Codecov.
|
Rename isArrayRequired to isArrayNullable
| }; | ||
|
|
||
| if (field.isListNullable !== undefined) { | ||
| fieldMeta.isArrayNullable = !field.isListNullable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the rename, this should be changed to
| fieldMeta.isArrayNullable = !field.isListNullable; | |
| fieldMeta.isArrayNullable = field.isListNullable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yuth, Ah I did not think about this. I added a commit to fix this.
isArrayNullable value should be flipped due to name change
|
@yuth, I discovered an issue due to the rename to isArrayNullable having the opposite meaning means in getTypeInfo it should only return if isListNullable is true instead of if it is false. I am submitting a PR that fixes this. |
|
@yuth just an FYI that this looks like the cause that broke our front-end when we upgraded from (e.g. the array is optional) stopped being generated as: readonly foo?: Bar[];but instead got generated as: readonly foo: Bar[];I haven't yet read this ticket in detail to know if that was an intentional change or not, but if it was, I would suggest it wasn't a patch-level change since it caused our RN app using those types to start generating TypeScript errors. I think overall the change is likely a good one as we were having to work around DataStore not being able to handle empty arrays and so instead we were deliberately setting the values to Update: Perhaps #5450 fixes this issue we ran into but hasn't yet been released, and so isn't included in |
|
@danrivett I looked into this, #5450 is in the latest version. The schema is generating correctly with isArrayNullable true and isRequired as true, but the types are not correct. I'll look into this and submit a PR for types. Sorry for the bug! |
Thanks for the update @seang96, no problem. Thank you for looking into this. For now we've reverted to |
…ws-amplify#5327) fix aws-amplify#5139 Co-authored-by: Sean Greenawalt <sgreenawalt@dasherlawless.com>
|
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Issue #, if available: #5139
Description of changes:
I added a check to getTypeInfo to check if the current node is NonNullType and its' child node is ListType to set isListNullable, new attribute in TypeInfo, to to true.
The metadata-visitor then sets isArrayRequired to true whe isListNullable is not allowed.
To add support in DataStore, this PR should do: aws-amplify/amplify-js#6784
This PR should support the table below:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.