-
Notifications
You must be signed in to change notification settings - Fork 63
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
Feature: Use improved pluralization #255
Conversation
...psync-modelgen-plugin/src/__tests__/visitors/__snapshots__/appsync-java-visitor.test.ts.snap
Outdated
Show resolved
Hide resolved
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 #255 +/- ##
==========================================
+ Coverage 85.69% 85.71% +0.01%
==========================================
Files 148 148
Lines 7380 7397 +17
Branches 1962 1973 +11
==========================================
+ Hits 6324 6340 +16
- Misses 959 960 +1
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.
The codegen logic LGTM. Still I have some concerns on each library change, which need further confirmation with library side.
-
JS(meta): the new attributes are appended instead of replacing the old one so it should not break customers
-
iOS and Android: the original plural field is replaced by two new fields, need library side release first
-
Flutter: we do not receive ticket from flutter and it usually depends on iOS and Android team, not sure if this should be included in this PR. The old plural field is also replaced and it might have impact
Also need a decision on the default feature flag value
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.
LGTM
JS team is OK with this change
@manueliglesias We advise to hold off on rolling this out. Once the open CLI concerns are resolved and remedied, we will review and proceed. |
Just a reminder, that codegen PR can be safely merged when the library changes are in for iOS and Android. Please track
There are flutter implications as well. Codeegn changes should be:
|
Are there any instructions you could provide to allow the library teams to run this change and generate the model files to make sure it works with the library before merging in the library changes? ie. install development version of the CLI which contains this codegen change so we can run |
For amplify-flutter, can go with option 2. Without any changes to be made into amplify-flutter, only the |
You can follow the instruction here to pull this PR and run |
@@ -610,13 +611,18 @@ export class AppSyncModelDartVisitor< | |||
} | |||
|
|||
protected generateSchemaField(model: CodeGenModel, declarationBlock: DartDeclarationBlock): void { | |||
const pluralFields = this.config.improvePluralization ? `modelSchemaDefinition.listPluralName = "${ |
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.
As mentioned in the comment, Flutter need option 1 for the change (reverting flutter changes)
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.
Please inform once this required change is complete, I will follow up and test. Thanks!
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.
Correction: amplify-flutter should take the option 1, the dart-visitor should not make any changes.
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.
@AaronZyLee removed
thanks! i got this working with the following:
|
Reminder this PR needs to be updated to remove the dart files changes related to Flutter (@HuiSF's comment #255 (comment)) |
const pluralAttributes = this.config.improvePluralization ? | ||
{ | ||
listPluralName: plurality(model.name, this.config.improvePluralization), | ||
syncPluralName: this.pluralizeModelName(model) |
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.
should json syncPluralName be different than java visitor?
https://github.com/aws-amplify/amplify-codegen/pull/255/files#diff-8fdb1b5aed85eca745295520073edb2af47d27fdf8cff3173487f147b11e5fdaR761
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.
good catch I think the java visitor needs fixed
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.
LGTM
hello, any chance to get this in the next CLI release ? |
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.
lgtm 🐰
any updates on this? |
@marcvberg following up to see when can we expect this to be closed? |
Hi @marcvberg could you reopen this PR against the Nevermind, I was able to update myself. Feel free to ignore. |
@marcvberg let's create an asana task to get this released in the next sprint. |
@alharris-at Added to my tasks |
Hello, Any status when this will be merged. It blocks customer projects on this issue aws-amplify/amplify-swift#1443 (opened since Sept. 2021). This PR is open since Oct 2021. Can you help to prioritize this ? |
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.
The failing tests are probably due to the dependency change. You can rebase the main branch (or merge main) with the latest dependency versions and re-build the project.
6100231
to
5bd5b09
Compare
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.
Could you add a unit test for the schema.js
generated by JS modelgen since the output is changed? Otherwise LGTM
packages/appsync-modelgen-plugin/src/__tests__/visitors/appsync-swift-visitor.test.ts
Outdated
Show resolved
Hide resolved
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.
LGTM. This will be held until the studio CMS using the new model introspection schema as there are new fields introduced in schema.js
Any chance to get this merged before re:Invent ? I am developing a workshop with Amplify. Current workshop instructions asks customer to manually modify the generated code. It would be great is this can be fixed by then. Thanks |
This pull request introduces 13 alerts when merging 5539ee5 into 00ba754 - view on LGTM.com new alerts:
|
@sebsto what platform are you writing your workshop for? We're testing this right now to verify if we're in a good place to merge, but it looks like Android/Flutter still won't have support for improvedPluralization after this PR from my current testing. |
@alharris-at workshop is for iOS / Swift (and while I am at it, there is a warning about field ID being deprecated. but I should report that on another issue) |
the warning about field ID being deprecated is a swift codegen warning. This is related to the new For reference, the CPK feature docs is located over here aws-amplify/docs#4452 |
The last comment on this PR was on October. Is someone actively working on this? I have an open issue reported: aws-amplify/amplify-swift#2460 |
db4ff43
to
65e5bfa
Compare
Thank you @marcvberg for the push. What are the next steps to get this merged ? |
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.
Q on the interface, otherwise looks sane to me given we understand the e2e testing a bit more.
@ModelConfig(pluralName = \\"Posts\\", type = Model.Type.USER, version = 1) | ||
@ModelConfig(listPluralName = \\"Posts\\", syncPluralName = \\"Posts\\", type = Model.Type.USER, version = 1) |
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 this a breaking change to no longer also specify the 'pluralName'?
@@ -1845,7 +1845,7 @@ import static com.amplifyframework.core.model.query.predicate.QueryField.field; | |||
|
|||
/** This is an auto generated class representing the Post type in your schema. */ | |||
@SuppressWarnings(\\"all\\") | |||
@ModelConfig(pluralName = \\"Posts\\") |
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.
Why do some of these not have the type/version as well?
@marcvberg hello Marc, any steps to move forward and review @alharris-at comments above ? Thank you |
Looks like this issue has been fixed by aws-amplify/amplify-swift#3135 |
Description of changes
Use feature flag to determine whether to set pluralName or listPluralName/syncPluralName
Issue #, if available
aws-amplify/amplify-cli#8350
fix #252
Description of how you validated changes
Unit testing
Manually tested with JS, Android, and iOS applications. Manual tests involved creating Todos through the console as well as through the app, and observing that the data was still available while offline
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.