[MGNLGQL-68] Good query names for plural contenttype names like 'authors' Created: 06/Jan/21  Updated: 19/Apr/21

Status: Open
Project: Magnolia GraphQL
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Christopher Zimmermann Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
relation
is related to MGNLCT-169 DOC: Document that contenttype names ... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: GraphQL Phase 2

 Description   

Steps to reproduce

  1.  Create a contenttype called 'authors'
  2.  Try to use a GraphQL query for an  'author' by path.

 

{
  author(path: "/My-Good-Authors/Charles-Darwin") {
    name
  }
}

 

Expected results

It works.

Actual results

Get an error: 
Validation error of type FieldUndefined: Field 'author' in type 'Query' is undefined @ 'author'"

Workaround

Change contenttype names to be singular. 

Development notes

Magnolia GraphQL creates two queries by default, one for single items and one for multiple items.

Currently it assumes that the contenttype name is singular and so it uses that name for the single query and it uses a library to 'pluralize' the contenttype name for the multiple items.

So with contenttype name "authors" the two queries are:

singluar: "authors"

plural: "authorses"

Recommendation

In Magnolia, contenttype names are not enforced to be singluar or plural, but singular is the soft convention GraphQL should behave best based on that convention, as it does now.

However we should not force any projects who have used a plural name for their content type to change it. So it should be possible to somehow configure the system whether the contenttype name is singular or plural - or maybe best - simply allow developers to specify the name of the two queries if they want to. (for example to handle a contentTyp name like "news")

 

Idea:

Could the system detect whether the contenttype name is singluar or plural - and take appropriate action based on that?

 

 



 Comments   
Comment by Christopher Zimmermann [ 19/Apr/21 ]

Agreed. Done. docs ticket is attached.

Generated at Mon Feb 12 05:52:16 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.