Closed gjinajgledis closed 4 months ago
Unfortunately, you're not giving us much to go on here. Can you elaborate?
Ideally, a minimal sample application should help us answer most of those.
Please note that "application/graphql"
is supported in Spring for GraphQL, but not officially by the GraphQL community. See #375 and #563
Sorry Brian for not giving enough information.
According to this closed issue support for application/graphql for request body was added by this commit . So, in version 1.3.1 spring graphql started to support for the first time this media type.
But when I perform this request using Spring mockmvc:
mvc.perform(MockMvcRequestBuilders.post(PATH_GRAPHQL) .content("{ hello }") .contentType("application/graphql") .accept(MediaType.APPLICATION_JSON))
I still get this error: org.springframework.web.HttpMediaTypeNotSupportedException
Is this something expected or could be potentially an issue?
This is covered by a test case in the same commit you're pointing at. Also, your initial comment mentioned "application/graphql;charset=UTF-8"
but your code snippet doesn't. Maybe you can share a sample application?
Hey Brian, Please have a look to this sample application . You will find inside AuthorIntegrationTest two test cases and one of them which is sending a application/graphql media type request fails.
Thanks for the sample.
MockMvc
is adding automatically the charset information to the outgoing content type. This means the server is effectively receiving application/graphql;charset=UTF-8
. The fallback introduced in #948 was incomplete since it checked for exact matches and did not compare media types.
We'll fix this in 1.2.x and 1.3.x but please note that you should get rid of "application/graphql"
as soon as possible in favor of "application/json"
(client requests) and "application/json"
/"application/graphql-response+json"
(server responses).
Recent changes to support application/graphql seems like do not cater for the case when the content-type value is application/graphql;charset=UTF-8