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(modelgen-swift): respect index sk fields in associate fields #542
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #542 +/- ##
==========================================
+ Coverage 85.69% 85.71% +0.02%
==========================================
Files 148 148
Lines 7380 7364 -16
Branches 1962 1958 -4
==========================================
- Hits 6324 6312 -12
+ Misses 959 955 -4
Partials 97 97
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Minor comments
// Configuration used for processing directives | ||
export type CodeGenDirectiveProcessConfig = { | ||
// This flag is going to be used for using custom primary key feature | ||
isCustomPKEnabled: boolean, |
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.
does this mean that there is a @primaryKey
present in the schema or just that if it's present, we will codegen differently?
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.
This is determined by the feature flag value rather than the presence of the directive. If the value is true and the schema is a CPK (the @primaryKey
is attached to non-id field/id PK with SK defined), it will codegen differently
packages/appsync-modelgen-plugin/src/visitors/appsync-visitor.ts
Outdated
Show resolved
Hide resolved
return [otherSideConnectedField]; | ||
const sortKeyFieldNames: string[] = otherSideConnectedDir?.arguments.sortKeyFields ?? []; | ||
return shouldRespectSortKeyFieldsOfIndexInAssociatedWithFields | ||
? [otherSideConnectedField, ...sortKeyFieldNames.map(sk => connectedModel.fields.find(f => f.name === sk)!)] |
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.
Is the !
necessary in the find
?
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.
Yes the sortKeyField should exist in connected when its field name is provided. Otherwise it is not a valid schema.
Description of changes
associatedWith
fields now respect the index sortKeyFields in explicit uni hasMany relation. This change only affects swift modelgen.processDirectives
. Add new type definition and default value for directive process configuration.Issue #, if available
Fix #539
Description of how you validated changes
yarn test
amplify-dev codegen models
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.