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

Batch Multiple Queries #817

Open
bszeliga opened this issue Sep 18, 2023 · 8 comments
Open

Batch Multiple Queries #817

bszeliga opened this issue Sep 18, 2023 · 8 comments
Labels
in: core Issues related to config and core support type: enhancement A general enhancement
Milestone

Comments

@bszeliga
Copy link

It appears that being able to send multiple batched queries is not supported.

I would like to be able to make a single network call to be able to execute multiple queries.

@bclozel
Copy link
Member

bclozel commented Sep 18, 2023

I don't understand, can you elaborate? What are you trying to achieve?

Can you share a sample GraphQL query that shows what's currently not supported? Which parts of Spring for GraphQL are you using?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 18, 2023
@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Sep 18, 2023
@bszeliga
Copy link
Author

So I'm able to execute a query for a random color

curl -v http://localhost:8080/graphql -H "Content-Type: application/json" --data '{"query":"query getRandomColor{ getRandomColor } "}'
*   Trying 127.0.0.1:8080...                                      
* Connected to localhost (127.0.0.1) port 8080 (#0)               
> POST /graphql HTTP/1.1                                          
> Host: localhost:8080                                            
> User-Agent: curl/8.1.2                                                                                                            
> Accept: */*                                                     
> Content-Type: application/json                                  
> Content-Length: 51                                              
>                                                                                                                                   
< HTTP/1.1 200 OK                                                                                                                   
< Content-Type: application/json                                                                                                    
< Content-Length: 33                                                                                                                
<                                                                                                                                                                                                                                                                        
* Connection #0 to host localhost left intact                     
{"data":{"getRandomColor":"RED"}}%                                

And I can execute a query for a random Int

curl -v http://localhost:8080/graphql -H "Content-Type: application/json" --data '{"query":"query getRandomInt{ getRandomInt } "}'
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /graphql HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.1.2
> Accept: */*
> Content-Type: application/json
> Content-Length: 47
> 
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 37
< 
* Connection #0 to host localhost left intact
{"data":{"getRandomInt":-1460752148}}%   

But I can't combine these two queries into a single remote call

curl -v http://localhost:8080/graphql -H "Content-Type: application/json" --data '[{"query":"query getRandomColor{ getRandomColor } "}, {"query":"query getRandomInt{ getRandomInt } "}]'
*   Trying 127.0.0.1:8080...                                      
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /graphql HTTP/1.1                                          
> Host: localhost:8080                                            
> User-Agent: curl/8.1.2                                          
> Accept: */*                                                     
> Content-Type: application/json                                  
> Content-Length: 102                                             
>                                                                 
< HTTP/1.1 400 Bad Request                                        
< Content-Type: application/json                                  
< Content-Length: 123                                             
<                                                                 
* Connection #0 to host localhost left intact
{"timestamp":"2023-09-18T19:36:52.284+00:00","path":"/graphql","status":400,"error":"Bad Request","requestId":"af3ace97-9"}% 

This is possible however with the legacy com.graphql-java-kickstart:graphql-spring-boot-starter:15.0.0

@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 Sep 18, 2023
@bclozel
Copy link
Member

bclozel commented Sep 20, 2023

I think you're referring to batch requests, which is a non-standard feature supported by Apollo and others.

It doesn't look like the official issue for the GraphQL spec is getting traction. I will leave this issue opened for now to see if there is community demand for this, but at this time we are not likely to introduce features that are at odds with the spec.

@bclozel bclozel added type: enhancement A general enhancement in: core Issues related to config and core support and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Sep 20, 2023
@bclozel bclozel added this to the Triage Queue milestone Sep 20, 2023
@trthsa
Copy link

trthsa commented Jan 12, 2024

Up vote for this feature!

@VnzBzk
Copy link

VnzBzk commented Jan 15, 2024

Up vote!

1 similar comment
@SarahDiet
Copy link

Up vote!

@bclozel
Copy link
Member

bclozel commented Jan 16, 2024

Please use the upvote feature on the original description. Adding comments like this just adds noise to the issue tracker and doesn't count when ranking issues by popularity.

@jimartinmoreno
Copy link

jimartinmoreno commented Feb 16, 2024

Hi all. First off thank you for your great job! Any update here? We are facing a migration from kickstart to Spring from Graphql, everything is going smooth, but then we realize that we have an issue with executing multiple batched queries in one request. This feature was previously supported by the kickstart implementation:
curl -Sss 'http://localhost:8080/graphql' -u xxx:xxx -H 'accept: application/json' -H 'content-type: application/json' \ --data-raw '{"batch":[{"query":"query FIND_PERSON {findPerson(searchCriteria: {email: \"a@b.com\"}) {id}}","variables":null},{"query":"query FIND_PERSON {findPerson(searchCriteria: {email: \"test@springboot.com\"}) {id}}","variables":null}]}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues related to config and core support type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

7 participants