Skip to content
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

Support for application/graphql content type #108

Closed
vangapr opened this issue Aug 10, 2021 · 2 comments
Closed

Support for application/graphql content type #108

vangapr opened this issue Aug 10, 2021 · 2 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@vangapr
Copy link

vangapr commented Aug 10, 2021

Current spring boot graphql does not seem to support application/graphql content type with query text as body as specified here ( https://graphql.org/learn/serving-over-http ).

quote from the above specification:

In addition to the above, we recommend supporting two additional cases:

  • If the "query" query string parameter is present (as in the GET example above), it should be parsed and handled in the same way as the HTTP GET case.
  • If the "application/graphql" Content-Type header is present, treat the HTTP POST body contents as the GraphQL query string.

From GraphQlWebFluxAutoConfiguration.java:

RouterFunctions.Builder builder = RouterFunctions.route()
				.GET(graphQLPath, request ->
						ServerResponse.status(HttpStatus.METHOD_NOT_ALLOWED)
								.headers(headers -> headers.setAllow(Collections.singleton(HttpMethod.POST)))
								.build())
				.POST(graphQLPath,
						accept(MediaType.APPLICATION_JSON).and(contentType(MediaType.APPLICATION_JSON)),
						handler::handleRequest);
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 10, 2021
@bclozel
Copy link
Member

bclozel commented Aug 10, 2021

The graphQL over HTTP is still being worked on and I think we're keeping things the way they are for now until progress is made (see #11 (comment)).

As for the content-type we're more likely to choose application/graphql+json as suggested in the spec.

@rstoyanchev rstoyanchev added status: blocked An issue that's blocked on an external project change and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 1, 2021
@rstoyanchev rstoyanchev added this to the 1.0 Backlog milestone Sep 1, 2021
@rstoyanchev rstoyanchev modified the milestones: 1.0 Backlog, 1.0.0-RC1 Mar 24, 2022
@rstoyanchev rstoyanchev added type: enhancement A general enhancement and removed status: blocked An issue that's blocked on an external project change labels Mar 24, 2022
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Mar 24, 2022

After discussing this further, the spec draft now requires this and keeps application/json as a fallback for compatibility. We should make sure the server supports both and uses the one that's requested, while the client will use application/graph+json by default. The client changes are needed in Spring GraphQL while the server would also require a change in the Boot starter.

@bclozel bclozel self-assigned this Mar 24, 2022
@bclozel bclozel closed this as completed in e455ebb Apr 4, 2022
bclozel added a commit to spring-projects/spring-boot that referenced this issue Apr 4, 2022
As seen in spring-projects/spring-graphql#108, the GraphQL HTTP spec now
requires the "application/graphql+json" media type and accepts
"application/json" for backwards compatibility.

This commit updates the `RouterFunction` definition for the GraphQL HTTP
endpoints so that both types are accepted.

Closes gh-30407
bclozel added a commit that referenced this issue May 4, 2022
As of #108, the `"application/graphql+json"` media type is supported and
has been made the default.

It seems that it is not ready for adoption now; so while we'll keep
supporting it, this commit reverts back to `"application/json"` as the
default media type for servers and clients.

Closes gh-375
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants