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

Provide a synchronous GraphQL client without spring-webflux #771

Closed
juergenzimmermann opened this issue Aug 13, 2023 · 7 comments
Closed
Assignees
Labels
in: web Issues related to web handling type: enhancement A general enhancement
Milestone

Comments

@juergenzimmermann
Copy link

It would be nice to have a synchroneous GraphQL client like org.springframework.web.client.RestClient (provided by spring-web-VERSION.jar).
The current org.springframework.graphql.client.HttpGraphQlClient is based on org.springframework.web.reactive.function.client.WebClient and, therefore, requires spring-webflux-VERSION.jar.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 13, 2023
@bclozel
Copy link
Member

bclozel commented Aug 16, 2023

We could consider a GraphQlClient that does not depend on WebClient, but we would still depend on reactor-core because of the Mono and Flux signature types. This would not make the client synchronous as outlined in the issue title. Would this still work for you?

@bclozel bclozel added type: enhancement A general enhancement in: web Issues related to web handling status: waiting-for-feedback We need additional information before we can continue labels Aug 16, 2023
@juergenzimmermann
Copy link
Author

@bclozel sounds good. This way at least org.springframework:spring-webflux resp. org.springframework.boot:spring-boot-starter-webflux will become obsolete for GraphQL apps.

@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 Aug 16, 2023
@bclozel bclozel added this to the 1.3 Backlog milestone Aug 31, 2023
@bclozel bclozel removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Aug 31, 2023
@rstoyanchev
Copy link
Contributor

@juergenzimmermann we'll consider a synchronous GraphQlClient along the lines of having RestClient and WebClient side by side, but that only adds another choice. It does not make spring-webflux obsolete for GraphQL applications. GraphQL with it's scatter-gather style handling benefits from concurrent execution, and the same can also be quite useful on the client side too if processing multiple requests.

@juergenzimmermann
Copy link
Author

@rstoyanchev Thank you for the clarification. I highly appreciate having a synchronous GraphQlClient, also for testing purposes.

@rstoyanchev
Copy link
Contributor

For testing we have GraphQlTester which has a synchronous API unless you are testing subscriptions but in that case you need Reactive Streams anyway with GraphQL Java.

@rstoyanchev rstoyanchev modified the milestones: 1.3 Backlog, 1.3.0-M1 Dec 8, 2023
@rstoyanchev rstoyanchev self-assigned this Jan 22, 2024
rstoyanchev added a commit that referenced this issue Jan 31, 2024
rstoyanchev added a commit that referenced this issue Jan 31, 2024
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Jan 31, 2024

This is now available in 1.3.0-SNAPSHOT from https://repo.spring.io/snapshot.

Please, review the updated Client section, including the HTTP Sync extension backed by RestClient, and the Requests section with code snippets.

As a general comment, you can now choose between blocking (e.g. RestClient) and non-blocking (e.g. WebClient) execution chains for the underlying transport and interceptors. At the top-level, the GraphQlClient remains a shared, common workflow that offers both synchronous and non-blocking style of performing requests that you can use with any transport.

If you are able to give this a try and provide feedback, that would be much appreciated!

@juergenzimmermann
Copy link
Author

@rstoyanchev Thank you very much, also for the updated docs!. The snapshot works perfectly.

@bclozel bclozel changed the title Provide a synchroneous GraphQL client without spring-webflux Provide a synchronous GraphQL client without spring-webflux Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues related to web handling type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants