Building query at run time
Does spring for graphql provide a way to call another graphql-server by passing the current selection set as a query?
For ex:
Let's say, there is an external Graphql-Server A , which serves all the book objects.
type Book {
id
title
auotherName,
price
}
Graphql-server B depends on the server A to get books. (Please do note that this server B might also call other services like C, D etc).
So, when the B service receives a request with the following selection, I do not see an option in HttpGraphQlClient to pass the selection set from B to A.
query {
book(id: 1){
title,
price
}
}
I am not sure I fully understand the scenario. From the given example I would think you want the whole original query, but you hinted at other services as well. It would help if you could provide a sample that better illustrates the aim. I'm also not sure why only the selection set? What about the the operation, arguments, etc?
Just to explain scenario, Let's imagine a graphql server B which has 3 graphql upstreams servers. Say A1, A2, A3. (This is a simplified view just to explain the problem)
- A1 handles Books only
- A2 handles Authors only
- A3 handles price only.
and B is a facade / aggregator of 3 graphql services.
B might receive 1 single operation as shown below for which it might end up fetching data from different upstreams (A1 and A2 for the below query).
query BookAuthorPrice{
book(...book specific search parameters){
id
title
}
author(..author search parameters){
id
name
}
}
This sounds like federation or stitching. This is not currently in the scope of Spring for GraphQL but this can be done when combined with other libraries. Have you seen #384? Is that what you are looking for?
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.