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

Tracking Issue - Some words are not handled well for Model names (Pluralization, ect) and reserved words #1198

Closed
1 task done
johannpinson opened this issue May 15, 2018 · 35 comments
Labels
flag: tracking issue Special issues used to combine multiple issues into one issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package status: confirmed Confirmed by a Strapi Team member or multiple community members

Comments

@johannpinson
Copy link
Contributor

johannpinson commented May 15, 2018

Edited by @derrickmehaffy on 2021/03/29

This issue has been converted to a global tracking issue regarding certain english or other language words that fail to work when building models. There are various examples, and for the moment the workarounds mean excluding these words from use and doing things like:

news => newsItem ect


Informations

  • Node.js version: 8.9.1
  • npm version: 5.6.0
  • Strapi version: 3.0.0-alpha.12.1.3
  • Database: Mongo v3.4.9
  • Operating system: MacOS 10.13.4

What is the current behavior?
When I create a new content type with a name which have the same plural version, the API generate will loop into a 500

Steps to reproduce the problem

  • Create a new content type named "Fish" (or "News")
  • Use a GraphQL IDE or look the terminal
    capture d ecran 2018-05-15 a 16 56 39

What is the expected behavior?
The problem is that some english words have a specific plural behavior (like child/children) or have the same orthograph
As example : https://github.com/atteo/evo-inflector/blob/master/src/main/java/org/atteo/evo/inflector/English.java#L131

Suggested solutions

Best solution:
Disallow to use "words" which can have an different plural/single mode (ex: fish, news, etc.)

Another solution is to add a flag "all" in front, a.k.a "allFish" (but it add a 2nd behavior so i don't think it's the best solution


  • I'm sure that this feature hasn't already been referenced.
@lauriejim lauriejim added issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around labels May 15, 2018
@lauriejim lauriejim changed the title GraphQL > No plural for some english words Plural for some english words are not handle May 15, 2018
@Aurelsicoko
Copy link
Member

Great question... It's complicated because we're going to follow the OpenCRUD specs and this case doesn't seem to be handled. I'm going to ask how we should deal with this case.

@johannpinson
Copy link
Contributor Author

I know, i already have the problem with Prisma (who manages the OpenCRUD docs) about this problem: prisma/prisma1#1772
In fact, the use a scala library to detect singular/plural words and blocks some of them.

@Aurelsicoko
Copy link
Member

@johannpinson Thank you for sharing the issue on Prisma. I think the OpenCRUD specs could evolve for fixing that kind of issues. I'm not sure that excluding words is the right way to solve it. How many words are concerned by it?

@johannpinson
Copy link
Contributor Author

@Aurelsicoko
Actually, Prisma blocks words which are invariable.

And in the OpenCRUD doc, it talks about using the java library evo-inflector (because Prisma is built with Scala/Sangria) and it lists 51 words invariable.

Moreover, it looks like Strapi use the pluralize lib, so we can detect if the word have a plural way.

@Aurelsicoko
Copy link
Member

I understand but blocking words is not an optimal solution because as a workaround we can add the prefix all for these words or change the specs to make sure the plural queries are harmonized whatever the word used. It should be specified in the specs.

@lauriejim lauriejim added the status: confirmed Confirmed by a Strapi Team member or multiple community members label Jun 14, 2018
@MartinMuzatko
Copy link
Contributor

Have the same problem.

I get the following stack trace:

[2018-08-15T14:48:37.214Z] debug POST /graphql (7 ms)
Error: Field Query.species can only be defined once.
    at assertValidSchema (~test/plugins/graphql/node_modules/graphql/type/validate.js:82:11)
    at Object.validate (~test/plugins/graphql/node_modules/graphql/validation/validate.js:58:35)
    at doRunQuery (~test/plugins/graphql/node_modules/apollo-server-core/dist/runQuery.js:111:42)
    at ~test/plugins/graphql/node_modules/apollo-server-core/dist/runQuery.js:21:56
    at process._tickCallback (internal/process/next_tick.js:68:7)
[2018-08-15T14:48:40.397Z] debug POST /graphql (10 ms)

@Aurelsicoko
Copy link
Member

@MartinMuzatko Try to find another word for this model until we find a viable solution.

@MartinMuzatko
Copy link
Contributor

Sure - already did. I just hate to abuse the english language @Aurelsicoko

@kret13
Copy link

kret13 commented Feb 22, 2019

Any update on this seems News keyword cant still be used as content type name?

@Aurelsicoko
Copy link
Member

Aurelsicoko commented Feb 22, 2019

@kret13 No update for now... You should find another name for the content type as a workaround ;)

@davidkartuzinski
Copy link
Contributor

@kret13 - may I suggest that "news" isn't really a great name in general for a content type. "News Article" or "News Post" or "News Release" are more description and more user friendly. Consider that you may syndicate your news. You may have different content types for a News Snippet versus a News Article versus a News release.

I do understand also just using "news" as this will have a specific meaning to you and your team.

@lauriejim lauriejim added severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve and removed severity: medium If it breaks the basic use of the product but can be worked around labels May 9, 2019
@emahuni
Copy link
Contributor

emahuni commented Jul 30, 2019

yah the sort of resulting solution to this is issue is wrecking havoc with the Graphql plugin and crashes Strapi. See issue #3695.

@emahuni
Copy link
Contributor

emahuni commented Jul 30, 2019

@kret13 - may I suggest that "news" isn't really a great name in general for a content type. "News Article" or "News Post" or "News Release" are more description and more user friendly. Consider that you may syndicate your news. You may have different content types for a News Snippet versus a News Article versus a News release.

I do understand also just using "news" as this will have a specific meaning to you and your team.

what about pants or scissors? I think the idea here is that it should just handle anything thrown at it fine. I think the actual best solution here is a hybrid 'all' prefix, maybe it could be done only for words that result to a tantum, whether singularia or pluralaria. eg: team => teams, fish => allFish, news => allNews

or just do the Golum way, sheep => sheepsies 🤣

@MartinMuzatko
Copy link
Contributor

It would be sufficient for me to be notified on content type creation, that this can't be pluralized properly ;)

@emahuni
Copy link
Contributor

emahuni commented Jul 30, 2019

It would be sufficient for me to be notified on content type creation, that this can't be pluralized properly ;)

exactly! Then once told, if you choose to continue you are notified that its plural form will be "allNAME", sometimes you don't want to change or can't change it to anything else remember that.

pants is a good example

@emahuni
Copy link
Contributor

emahuni commented Jul 30, 2019

@kret13 - may I suggest that "news" isn't really a great name in general for a content type. "News Article" or "News Post" or "News Release" are more description and more user friendly. Consider that you may syndicate your news. You may have different content types for a News Snippet versus a News Article versus a News release.

I do understand also just using "news" as this will have a specific meaning to you and your team.

oh another thing is you can't define "newsArticle" as a content type, you can only do "newsarticle" as you can't specify caps in the name field, nor can you do "news_article". I don't know why exactly this is the case, but this deters your efforts and is super weird considering we need to specify such content types as "newsArticle".

@DarkTraveler
Copy link

DarkTraveler commented Aug 18, 2019

content type "news" dropped strapi))

Error: Field "Query.news" can only be defined once.
at assertValidSDL (/mnt/c/work/axios/node_modules/graphql/validation/validate.js:80:11)
at Object.buildASTSchema (/mnt/c/work/axios/node_modules/graphql/utilities/buildASTSchema.js:69:34)

@prawee
Copy link

prawee commented Sep 4, 2019

same same solved by change to another name such as "post"

@lauriejim lauriejim added severity: medium If it breaks the basic use of the product but can be worked around and removed severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve labels Feb 11, 2020
@florentbolo
Copy link

Try with "series" had a 400
Try with a space before : " series", it worked and removed automatically the space in the collection name 🙃

@a-stein
Copy link

a-stein commented Oct 25, 2021

Whilst this issue is completely understandable, I think it would help to have a more useful feedback for the CMS user than "an error occurred". In fact, validation on the collection name as you type it would probably make sense!

"news" is going to be a very common collection people try to make (and actually, pointing out that it should be a singular like NewsItem quickly helps grasp the what/why it's wrong). I was 5 minutes into trying strapi for the first time and it didn't give me a first good impression to hit a completely nondescript error message

Just ran in the exactly same problem by trying to create a "News" collection. Did a bit research and ended up here.

I think a more meaningful error message would definitely help. There are probably lots of people that ran into the same issue and ditched Strapi afterwards.

@derrickmehaffy
Copy link
Member

Summery of related (closed/duplicate) issues:

@derrickmehaffy derrickmehaffy removed this from To be reviewed (Open) in Developer Experience - Old May 6, 2022
@derrickmehaffy derrickmehaffy added the flag: tracking issue Special issues used to combine multiple issues into one label May 9, 2022
@derrickmehaffy derrickmehaffy changed the title Tracking Issue - Some words are not handled well for Model names (Pluralization, ect) Tracking Issue - Some words are not handled well for Model names (Pluralization, ect) and reserved words Nov 15, 2022
@derrickmehaffy
Copy link
Member

This Issue is now being closed and locked as we are breaking it up into two different tracking issues:

Reserved Words: #16222
Pluralization Issues: #16223

@strapi strapi locked and limited conversation to collaborators Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
flag: tracking issue Special issues used to combine multiple issues into one issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package status: confirmed Confirmed by a Strapi Team member or multiple community members
Projects
Archived in project
Development

No branches or pull requests