Skip to content

HttpGraphQlClient content-type #389

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
marinus-suniram opened this issue May 11, 2022 · 3 comments
Closed

HttpGraphQlClient content-type #389

marinus-suniram opened this issue May 11, 2022 · 3 comments
Labels
status: duplicate A duplicate of another issue

Comments

@marinus-suniram
Copy link

The content-type header in HttpGraphQlTransport is hard-code to application/graphql+json. No all graphql servers supports application/graphql+json. Can we make the content-type configurable?

public Mono<GraphQlResponse> execute(GraphQlRequest request) {
	return this.webClient.post()
			.contentType(MediaType.APPLICATION_GRAPHQL)
			.accept(MediaType.APPLICATION_GRAPHQL, MediaType.APPLICATION_JSON)
			.bodyValue(request.toMap())
			.retrieve()
			.bodyToMono(MAP_TYPE)
			.map(ResponseMapGraphQlResponse::new);
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 11, 2022
@bclozel
Copy link
Member

bclozel commented May 11, 2022

The HttpGraphQlTransport has been changed recently. In our published SNAPSHOTs:

private static MediaType initContentType(WebClient webClient) {
HttpHeaders headers = new HttpHeaders();
webClient.mutate().defaultHeaders(headers::putAll);
MediaType contentType = headers.getContentType();
return (contentType != null ? contentType : MediaType.APPLICATION_JSON);
}
@Override
public Mono<GraphQlResponse> execute(GraphQlRequest request) {
return this.webClient.post()
.contentType(this.contentType)
.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_GRAPHQL)

As of #359, you can explicitly set a content type with the client, so this might be a duplicate of this issue.
As of #375, we're now back to using "application/json" as the default.

Is there something else we're missing? Can you try our latest SNAPSHOTs?

@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label May 11, 2022
@marinus-suniram
Copy link
Author

Thanks, I can confirm that the issue is fixed on SNAPSHOT.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 11, 2022
@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels May 11, 2022
@bclozel
Copy link
Member

bclozel commented May 11, 2022

Thanks for trying the SNAPSHOTs!

@bclozel bclozel closed this as completed May 11, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants