TechPrimers / spring-boot-graphql-query-example

Spring Boot with GraphQL Query Example
98 stars 106 forks source link

InvalidSyntax error on executing this project #10

Open KushagraBindal opened 3 years ago

KushagraBindal commented 3 years ago

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 commented 3 years ago

@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.

midhunhk commented 3 years ago

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

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