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

WebClientGraphQLClient RequestBodyUriCustomizer #1290

Merged
merged 1 commit into from Oct 24, 2022

Conversation

berngp
Copy link
Contributor

@berngp berngp commented Oct 22, 2022

Pull Request type

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Changes in this PR

The WebClientGraphQLClient now offers a mechanism to customize the URI and Header parameters per request. This is done by allowing the user to define a RequestBodyUriCustomizer, a functional interface, that will receive a WebClient.RequestBodyUriSpec and return a RequestBodySpecwichiBody.

The customization of the WebClient.RequestBodyUriSpec happens before the WebClientGraphQLClient will apply the headerConsumer and serialize the GraphQL Request as the body.

Example

val result = client.reactiveExecuteQuery(
    query = "{ hello(name: \"foo\")  }",
    requestBodyUriCustomizer = {
        it.uri { uriBuilder -> uriBuilder.queryParam("q1", "one").build() }
    }
)

The WebClientGraphQLClient now offers a mechanism to customize the URI and Header parameters per request.
This is done by allowing the user to define a `RequestBodyUriCustomizer`, a functional interface, that
will receive a `WebClient.RequestBodyUriSpec` and return a  `RequestBodySpecwichiBody`.

The customization of the `WebClient.RequestBodyUriSpec` happens before the WebClientGraphQLClient will apply the
`headerConsumer` and serialize the GraphQL Request as the body.

Example
```
val result = client.reactiveExecuteQuery(
    query = "{ hello(name: \"foo\")  }",
    requestBodyUriCustomizer = {
        it.uri { uriBuilder -> uriBuilder.queryParam("q1", "one").build() }
    }
)
```
@berngp berngp merged commit 708e15c into master Oct 24, 2022
@berngp berngp deleted the feature/WebClientGraphQLClient_uri branch October 24, 2022 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants