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(graphql-transformer-common): pluralization for plural types #7030

Conversation

sharmaadityaHQ
Copy link
Contributor

Description of changes

Added a check for pluralization of list resolvers for plural types

Issue #, if available

Fixes #4224

Description of how you validated changes

Tested using sample project GraphQL schema

Checklist

  • PR description included
  • yarn test passes

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

@sharmaadityaHQ sharmaadityaHQ requested a review from a team as a code owner April 7, 2021 16:32
@sharmaadityaHQ
Copy link
Contributor Author

@SwaySway can you have a look please? Also the graphql-transformer-common package does not have any unit test yet. Is it a good idea to add one for this case?

@codecov
Copy link

codecov bot commented Apr 7, 2021

Codecov Report

Merging #7030 (0ff33b0) into master (ad037d1) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7030   +/-   ##
=======================================
  Coverage   56.31%   56.31%           
=======================================
  Files         445      445           
  Lines       21806    21806           
  Branches     4363     4363           
=======================================
  Hits        12280    12280           
  Misses       8711     8711           
  Partials      815      815           

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 ad037d1...0ff33b0. Read the comment docs.

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

It looks like #4224 (comment) requested a feature flag with this work.


export function plurality(val: string): string {
if (!val.trim()) {
return '';
}
if (pluralize.isPlural(val.trim())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this module can actually do the conversion to plural for you. Is there any reason not to use that functionality instead?

Side note: it might be worth putting val.trim() in a variable since it's called a few times now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I am pushing the changes soon.

Copy link
Contributor

@edwardfoyle edwardfoyle left a comment

Choose a reason for hiding this comment

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

I think this needs to be behind a feature flag because if someone currently has a model named Tomatoes and they are depending on the list operation being called listTomatoess this will break their frontend.

We should also pin the version of pluralize because an update could potentially change the pluralization of a word which could break someones model transformation

@renebrandel
Copy link
Contributor

Closing in favor of #7258

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.

ModelTransformer pluralization is incorrect for plural types
4 participants