Skip to content

Support for application/graphql content type #108

@vangapr

Description

@vangapr

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);

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions