'Offload query parts in Apollo client
I vaguely remember Apollo supporting a directive / mechanism, which enables offloading parts of the query into a subsequent query. I know this can be achieved combining multiple queries, or by simply loading the details separately, but I think this would be an easy way to provide fast previews without a lot of complexity. I was thinking of something like this:
query {
foo {
bar
baz @async
}
}
And the first response would be in the format of
{
"foo": {
"bar": "something",
"baz": null // Or a predefined value
}
}
Once it's loaded, the results are passed down to the component to render, while a subsequent request is made with "baz" included:
{
"foo" {
"bar": "something",
"baz": "else" // baz loaded
}
}
Is there such a thing, or it was dreaming about it?
Edit:
Apparently there's a deferred
directive in the making: https://www.apollographql.com/blog/community/backend/introducing-defer-in-apollo-server/ but I couldn't find any up-to-date information about it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|