apollographql / apollo-kotlin

:rocket:  A strongly-typed, caching GraphQL client for the JVM, Android, and Kotlin multiplatform.
https://www.apollographql.com/docs/kotlin
MIT License
3.74k stars 652 forks source link

Feature: `@stream` support #4098

Open jpvajda opened 2 years ago

jpvajda commented 2 years ago

One of the disadvantages of GraphQL’s request/response model is that the GraphQL response is not returned to clients until the entire request has finished processing. However, not all requested data may be of equal importance, and in some use cases it may be possible for applications to act on a subset of the requested data. An application can speed up its time-to-interactive if the GraphQL server can send the most important data as soon as it’s ready. The new @defer and @stream directives allow GraphQL servers to do exactly that by returning multiple payloads from a single GraphQL response.

Similar to @defer the @stream directive also allows the client to receive data before the entire result is ready. @stream can be used on list fields. Whereas @defer can be used on used on fragment spreads and inline fragments.

References

https://graphql.org/blog/2020-12-08-improving-latency-with-defer-and-stream-directives/

martinbonnin commented 2 months ago

See https://github.com/apollographql/apollo-feature-requests/issues/3