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

Update to Spring Boot 3.2 and added a RestClient based GraphQLClient #1726

Merged
merged 3 commits into from
Nov 29, 2023

Conversation

paulbakker
Copy link
Collaborator

Pull Request type

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

Changes in this PR

Update to Spring Boot 3.2 and added a RestClientGraphQLClient, using Spring's new RestClient.
This is a blocking client with a similar API to WebClient, but without anything Reactive.

Example use:

@Autowired
RestClient.Builder restClientBuilder;

String helloRequest() {
   RestClient restClient = restClientBuilder.baseUrl("http://localhost:8080/graphql").build();
   RestClientGraphQLClient client = new RestClientGraphQLClient(restClient);
   return client.executeQuery("{hello}").extractValue<String>("hello");
}

@@ -43,7 +43,7 @@ class ReactiveWebClientTest {
.headers { consumer -> headers.forEach { consumer.addAll(it.key, it.value) } }
.bodyValue(body)
.exchange()
.flatMap { cr -> cr.bodyToMono(String::class.java).map { json -> HttpResponse(cr.rawStatusCode(), json) } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rawStatusCode doesn't exist anymore in Spring.

@paulbakker paulbakker merged commit cc73042 into master Nov 29, 2023
3 checks passed
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.

2 participants