Is it possible to chain requests in Android like in React Apollo below?
So not batching, but using the result of a query to construct the next one, all in one request.
You can use apollo-coroutines-support or apollo-rx2-support for that kind of things.
That's what I use now, but I did this with REST before. The point of GraphQL is to batch calls together, so it has less impact on the network. I can make parallel calls, but I'm unable to do dependent calls at once, like in the react link above. It's mind bending nobody finds this revolting. I was forced to use GraphQL at work for this very reason, so far for no real benefits.
I don't find it revolting rather not yet implemented. As apollo is a community project feel free to add any improvements that you want. Currently the focus is on replacing the apollo npm codegen as that has the highest impact.
@herrbert74 are you saying that GraphQL (no matter the language) can have the logic server side to batch calls ?
From: https://stackoverflow.com/questions/39644286/composing-graphql-queries
{
person(id: String) {
locationId
}
}
{
location(id: String) {
country
}
}
Given those the two queries above, do you want to have all the info in one single HTTP request ?
@digitalbuddha Sorry, if I wasn't clear. I do know what is it like working on open source. By all means, thank you for this. I meant it's revolting strange that nobody is missing this apart from me. I raised my voice to get a response.
@martinbonnin Yes, but I don't know how this exactly works and if it needs any kind of support from the server side.
That's why I'm curious if it's possible, planned, hard to implement, etc?
@herrbert74 I dont think it's actually possible. As the response in the stackoverflow link says, a properly designed schema would expose the full location node under person and you can then access person.location.country from just a personId.
From what I understand, javascript is not different and compose is just a way of chaining requests like you would do with RxJava Observable.flatMap. The fact that they mention the possibility of "skipping" the second request also comforts that impression.
Closing due to inactivity.
Most helpful comment
I don't find it revolting rather not yet implemented. As apollo is a community project feel free to add any improvements that you want. Currently the focus is on replacing the apollo npm codegen as that has the highest impact.