[MGNLGQL-113] Sort definitions fail if contenttype has no title field Created: 17/Mar/22  Updated: 22/Jun/23  Resolved: 22/Jun/23

Status: Closed
Project: Magnolia GraphQL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0.0, 1.1.3

Type: Bug Priority: Neutral
Reporter: Christopher Zimmermann Assignee: Valeria Robles-Garzon
Resolution: Fixed Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: 3h Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Attachments: File navigation.yaml    
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLGQL-142 Implement fix Technical task Completed Valeria Robles-Garzon  
MGNLGQL-143 Review Technical task Closed Oanh Thai Hoang  
MGNLGQL-144 Pre-Integration QA Technical task Closed Oanh Thai Hoang  
MGNLGQL-145 QA Technical task Completed Javier Benito  
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Epic Link: GraphQL Phase 2
Sprint: DevX 40
Story Points: 3
Team: DeveloperX
Work Started:
Approved:
Yes

 Description   

When the contenttype has no 'enumerable' property, like a string, then the autogenerted graphQL 'sort' type for that congenttype gives an error, and the type cannot be used in GraphQL

Please see attached definition file for example of definition that does not work.

To reproduce:

Start a DXCore with GraphQL module installed. (for example dxcore-demo webaapp)

Put the attached navigations.yaml file in a light module 'contentTypes' directory.

Open GraphQL app, this exception is written to log.

2022-03-17 12:06:48,191 ERROR info.magnolia.graphql.core.http.GraphQLServlet    : Failed to execute the GraphQL query
graphql.schema.validation.InvalidSchemaException: invalid schema:
Enum type "NavigationSort" must define one or more enum values.
	at graphql.schema.GraphQLSchema$Builder.buildImpl(GraphQLSchema.java:647) ~[graphql-java-16.2.jar:?] 

It probably causes errors in other attempted usages of the graphQL type. For exaample "introspection" fails.

Adding a simple "test" String property fixes the problem.

Expectation

I would expect that the graphql endpoint is still usaable even if there is no non-enumerable property.

I would expect that 'name' property would always be availble for sorting.

I would expect a more clear exception message - like "Navigation contentType must have at least one property that is enumerable, such as a String.


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