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: Support new list name pluralization #1451

Merged
merged 4 commits into from
Oct 29, 2021
Merged

fix: Support new list name pluralization #1451

merged 4 commits into from
Oct 29, 2021

Conversation

lawmicha
Copy link
Contributor

@lawmicha lawmicha commented Oct 5, 2021

Issue #, if available:
aws-amplify/amplify-cli#8350

Description of changes:

  • Finish rest schema updates to use listPluralName and syncPluralName
  • Run existing integration test using feature flag turned off
  • Generate new models using the latest codegen process (Feature: Use improved pluralization amplify-codegen#255 (comment)) and cross check with the test schemas we have
  • Provision backend using improvepluralization true (this is on by default), and rerun integration tests

Check points:

  • Added new tests to cover change, if needed
  • All unit tests pass
  • All integration tests pass
  • Documentation update for the change if required
  • PR title conforms to conventional commit style

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

@codecov-commenter
Copy link

codecov-commenter commented Oct 7, 2021

Codecov Report

Merging #1451 (91a20db) into main (1e5d800) will increase coverage by 0.02%.
The diff coverage is 65.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1451      +/-   ##
==========================================
+ Coverage   58.48%   58.51%   +0.02%     
==========================================
  Files         678      678              
  Lines       20729    20741      +12     
==========================================
+ Hits        12124    12137      +13     
+ Misses       8605     8604       -1     
Flag Coverage Δ
API_plugin_unit_test 61.57% <ø> (ø)
AWSPluginsCore 73.10% <58.33%> (+0.10%) ⬆️
Amplify 46.06% <75.00%> (+0.05%) ⬆️
Analytics_plugin_unit_test 71.76% <ø> (ø)
Auth_plugin_unit_test 78.96% <ø> (ø)
DataStore_plugin_unit_test 74.83% <ø> (+0.03%) ⬆️
Predictions_plugin_unit_test 26.81% <ø> (ø)
Storage_plugin_unit_test 58.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ies/DataStore/Subscribe/MutationEvent+Schema.swift 0.00% <0.00%> (ø)
...WSPluginsCore/Sync/MutationSync/MutationSync.swift 32.60% <0.00%> (ø)
...Model/Internal/Schema/ModelSchema+Definition.swift 63.20% <100.00%> (+1.21%) ⬆️
.../DataStore/Model/Internal/Schema/ModelSchema.swift 66.00% <100.00%> (+1.41%) ⬆️
...luginsCore/Model/Support/ModelSchema+GraphQL.swift 100.00% <100.00%> (ø)
...oreCategoryPlugin/Sync/Support/Model+Compare.swift 71.87% <0.00%> (+2.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e5d800...91a20db. Read the comment docs.

@lawmicha
Copy link
Contributor Author

Related issue discovered #1488

@lawmicha lawmicha marked this pull request as ready for review October 25, 2021 20:06
Copy link
Contributor

@diegocstn diegocstn left a comment

Choose a reason for hiding this comment

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

@lawmicha Do we need test cases for all the permutations?

@lawmicha
Copy link
Contributor Author

@lawmicha Do we need test cases for all the permutations?

added some unit testing in the latest commit! 91a20db

@lawmicha
Copy link
Contributor Author

lawmicha commented Nov 3, 2021

@sebsto
Copy link

sebsto commented Nov 4, 2021

Thank you @lawmicha
What are the steps required to update existing projects ?

Here is what I did and it is not working

  • update pod to 1.15.4
  • update cli to 6.3.1
  • run amplify codegen models

It still fails at runtime.

I noticed the following (`NoteData' is my model name)

ModelSchema+GraphQL.swift

            if let listPluralName = listPluralName {
                graphQLName = queryType.rawValue + listPluralName
            } else {
                graphQLName = (queryType.rawValue + name).pluralize()
            }

Looks like pluralize() does not work for me. I tried with both "improvepluralization": false, and "improvepluralization": true, in cli.json

Workaround that works for me is to add listPluralName in the generated model class :

    model.listPluralName = "NoteData"

@lawmicha
Copy link
Contributor Author

lawmicha commented Nov 4, 2021

hey @sebsto, sorry I wasn't clear, the codegen changes still need to be released. What you have there is the correct workaround by modifying what the codegen would be generating

@sebsto
Copy link

sebsto commented Nov 5, 2021

I thought that CLI 6.3.0 and this PR is fixing the pluralisation aws-amplify/amplify-cli#8401

What is the CLI PR to track ?

@lawmicha
Copy link
Contributor Author

lawmicha commented Nov 5, 2021

that one sets the flag as false for new projects, this one aws-amplify/amplify-codegen#255 adds code that generates the new fields based on the flag

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.

4 participants