[MGNLGQL-72] Exception when query variables are null, like with GraphiQL Created: 11/Feb/21  Updated: 22/Mar/21  Resolved: 22/Mar/21

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

Type: Bug Priority: Major
Reporter: Christopher Zimmermann Assignee: Robert Šiška
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: HTML File simple-graphiql.html    
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
Testcase included:
Yes
Epic Link: GraphQL Phase 1
Sprint: HL & LD 24
Story Points: 3

 Description   

Steps to reproduce

  1.  With "beta-2" - Use GraphiQL(attached as file) to submit a simple query with no varialbes, like:

 

{
    books {
        title
    }
}

 

Expected results

The response.

Actual results

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

Magnola log shows:

graphql.AssertException: variables map can't be null
	at graphql.Assert.assertNotNull(Assert.java:15) ~[graphql-java-14.1.jar:?]
	at graphql.ExecutionInput$Builder.variables(ExecutionInput.java:243) ~[graphql-java-14.1.jar:?]
	at info.magnolia.graphql.core.http.GraphQLServlet.handleQuery(GraphQLServlet.java:95) ~[magnolia-graphql-core-1.0-beta2.jar:?]
	at info.magnolia.graphql.core.http.GraphQLServlet.doGet(GraphQLServlet.java:78) [magnolia-graphql-core-1.0-beta2.jar:?]

Workaround

In the "Query Variables" pane of GraphiQL, supply an empty object

{}

Notes

GraphiQL is a very popular GUI for graphQL endpoints. It should work by default.

I guess other GUI or usages will also stumble on this.

If it does not cause problems, I suggest that we treat non-existing or null query varaibles as an empty map so that the query succeeds.

Notes

Run the attached simple-graphiql.html file on any web server. (Needs to run on a web server due to Magnolia CORS)

Tweak the URL in the file to hit your instances graphql endpoint.

 


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