Skip to content

HttpGraphQlClientTransport should respect an existing, explicitly set Content-Type #359

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

Closed
busches opened this issue Apr 22, 2022 · 2 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@busches
Copy link

busches commented Apr 22, 2022

With 1.0.0-RC1, the Client now sends the Content-Type header as application/graphql+json

We're trying to override the headers here, but it has no affect:

HttpGraphQlClient.builder(webClient)
        .url(url)
        .headers { header -> header.contentType = MediaType.APPLICATION_JSON }
        .build()

graphQlClient.documentName(documentName)
            .variables(variables)
            .retrieve("myQuery")
            .toEntityList(myQuery::class.java)

It's still coming over as application/graphql+json.

We need to do this, as the the Apollo graphql gateway we're using does not accept the graphql header.
Error: POST body missing, invalid Content-Type, or JSON object has no keys. (it's not the other two).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 22, 2022
@giger85
Copy link
Contributor

giger85 commented Apr 25, 2022

Overriding the content-type value (actually application/json) of request header is needed for me, too.

@rstoyanchev
Copy link
Contributor

Currently HttpGraphQlTransport sets the content type unconditionally. We can update that to check if it's already been set.

@rstoyanchev rstoyanchev added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 25, 2022
@rstoyanchev rstoyanchev added this to the 1.0.0 milestone Apr 25, 2022
@rstoyanchev rstoyanchev changed the title Client - Update documentation on how to override Content Type Header HttpGraphQlClientTransport should allow explicitly set Content-Type Apr 28, 2022
@rstoyanchev rstoyanchev self-assigned this Apr 28, 2022
@rstoyanchev rstoyanchev changed the title HttpGraphQlClientTransport should allow explicitly set Content-Type HttpGraphQlClientTransport should respect an existing, explicitly set Content-Type May 16, 2022
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