spring-boot-graphql-query-example icon indicating copy to clipboard operation
spring-boot-graphql-query-example copied to clipboard

InvalidSyntax error on executing this project

Open KushagraBindal opened this issue 4 years ago • 2 comments

While trying to execute the project using below query

{ book(id: "123") { title authors publisher } }

I am getting below error.

{ "data": null, "errors": [ { "message": "Invalid Syntax", "locations": [ { "line": 1, "column": 1, "sourceName": null } ], "errorType": "InvalidSyntax", "path": null, "extensions": null } ], "dataPresent": false, "extensions": null }

On server side I am getting below error

2021-05-12 18:11:10.346 WARN 16964 --- [o-auto-1-exec-5] graphql.GraphQL : Query failed to parse : '{"operationName":null,"variables":{},"query":"{\n book(id: "123") {\n title\n authors\n publisher\n }\n}\n"}'

Please help in understanding the root cause of this problem and how to fix the same.

KushagraBindal avatar May 12 '21 12:05 KushagraBindal

@MovingToWeb can you please help here... Just to highlight that I am using java 1.8 in my case and this shouldn't be the problem as my application compiled and code is in running state.

I have observed one more thing, when I am running through POSTMAN(Chrome/Window) it is working with contentType application/json but when trying with Postman as Graphql it is throwing above error. I am getting in playground as well.

KushagraBindal avatar May 12 '21 12:05 KushagraBindal

Make sure to select the following in the body of the Request in Postman.

Type: Raw, and select "text" from the dropdown

midhunhk avatar Aug 14 '21 04:08 midhunhk