Open seenimurugan opened 3 years ago
At step two you seem to be sending the GraphQL query as the request body in a POST request. Is that correct? In that case you must set the Content-Type header to application/graphql
as described here: https://graphql.org/learn/serving-over-http/#http-methods-headers-and-body. Are you doing that?
@oliemansm Thank you for your time and extremely valuable suggestion. Many thanks.
It works as expected after updating the content type toapplication/graphql
and the Postman's body set to raw type instead Graphql window
Behaviour:
application/graphql
as content-type works fineapplication/graphql
as content-type fails with syntax error(attached)application/json
as content-type fails with query can't be null (as mentioned above)The problem now is that I am not able to use the postman's GraphQL type body with content-type set to application/graphql
because the application now throws invalid syntax error. So i have to use raw body type with header set to application/graphql
to get it working.
So the question is why the behaviour changes as soon as Jackson Object mapper set with UPPER_CAMEL_CASE naming strategy?
How am i able to use the postman's graphql window to send the request? which is very convenient because it has separate query and variables window.
Below error occurs when query sent via Postman's Graphql window & content-type set to application/graphql
{
"errors": [
{
"message": "Invalid Syntax : offending token '\"query\"' at line 1 column 2",
"locations": [
{
"line": 1,
"column": 2
}
],
"extensions": {
"classification": "InvalidSyntax"
}
}
]
}
You say it has something to do with that uppercase object mapper, but seeing that it works with raw body and content type header I'm not convinced yet that the object mapper is the cause. So far it sounds like a problem in postman usage.
What happens if you enable graphiql with that starter and use that in the browser at /graphiql? Then you also have the variables panel, so same convenience. Could be worth a try to see if you still have these errors when using graphiql too.
If you do get the same errors, then paste the raw request body and headers here that are sent. If it works when using graphiql then I'd say it's a problem with Postman and not this lib.
@seenimurugan Have you been able to try out my last suggestions to try and figure out the root cause?
When project wide Jackson ObjectMapper is configured with PropertyNamingStrategy.UPPER_CAMEL_CASE naming strategy then sending query fails with query can't be null error
To Reproduce Steps to reproduce the behavior: Add the below Object mapper configuration
builder.propertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
Spring boot version:
@Bean ObjectMapperConfigurer objectMapperConfigurer() { return (mapper, context) -> { mapper.setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE); }; }