-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for application/graphql-response+json content type #1699
Conversation
@@ -45,8 +45,9 @@ class GraphQLRoutesConfiguration( | |||
|
|||
(isEndpointRequest and isNotWebSocketRequest).invoke { serverRequest -> | |||
val graphQLResponse = graphQLServer.execute(serverRequest) | |||
val accept = serverRequest.headers().accept().find { it == MediaType.APPLICATION_JSON } ?: MediaType.APPLICATION_GRAPHQL_RESPONSE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since application/json
is current behavior I'd keep it as default for the next release as well i.e.
val accept = serverRequest.headers().accept().find { it == MediaType.APPLICATION_JSON } ?: MediaType.APPLICATION_GRAPHQL_RESPONSE | |
val acceptMediaType = serverRequest.headers().accept().find { it.includes(MediaType.APPLICATION_GRAPHQL_RESPONSE) }?.let { MediaType.APPLICATION_GRAPHQL_RESPONSE } ?: MediaType.APPLICATION_JSON |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you your review!
I've changed as the above.
endpoint: String = "graphql", | ||
streamingResponse: Boolean = true, | ||
jacksonConfiguration: ObjectMapper.() -> Unit = {}, | ||
acceptContentType: ContentType = ContentType("application", "graphql-response+json"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably should wait for ktor 2.3.0 which includes ktorio/ktor@45b4ccd
how do we also provide a fallback to just use application/json
if there is no match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I removed support in ktor server from this PR.
I'll make another PR when ktor 2.3.0 is released. 👍
Thanks for the PR! |
…application/graphql-response+json (#1832) ### 📝 Description Most clients will request with `*/*` unless an any MediaType is specified. However, the `*/*` was not taken into account in current implementation. I change to keep `application/json` as default instead of `application/graphql-response+json`. ### 🔗 Related Issues #1831 #1573 #1699
📝 Description
Based on the accept header, spring server respond either with
application/json
(default) orapplication/graphql-response+json
media type.🔗 Related Issues
#1573