[MGNLGQL-179] Error 500 when disabling content type Created: 11/Jan/24  Updated: 06/Feb/24  Resolved: 06/Feb/24

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

Type: Bug Priority: Neutral
Reporter: Jonathan Ayala Assignee: Jaroslav Simak
Resolution: Fixed Votes: 0
Labels: quickwin
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
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:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Epic Link: Support
Team: DeveloperX
Work Started:

 Description   

Steps to reproduce

  1. Create decoration file as follows:
    <light-module>/decorations/graphql-core/graphqlTypes/asset.yaml
    enabled=false
    
  2. Restart the instance
  3. Launch graphQL app

Expected results

App opens correctly

Actual results

An error occurs:

{
  "status": 500,
  "errors": [
    "An internal server occurred, please check the log file"
  ]
}

Logs show the following error:

ERROR info.magnolia.graphql.core.http.GraphQLServlet    : Failed to execute the GraphQL query
graphql.AssertException: type Asset not found in schema

Workaround

Override GraphQLSchemaBuilder to filter disabled types

public class GraphQLSchemaBuilder {
             .filter(DefinitionProvider::isValid)
             .filter(provider -> provider.getProblems().stream().noneMatch(problem -> problem.getSeverityType() == DefinitionProvider.Problem.SeverityType.SEVERE))
             .map(DefinitionProvider::get)
+            // PATCHED CHANGE: Filter disabled definitions
+            .filter(GraphQLDefinition::isEnabled)
             .collect(Collectors.toList());
         for (final GraphQLDefinition graphQLDefinition : graphQLDefinitions) {
             graphQLDefinition.getTypes()

Development notes


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