apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.89k stars 728 forks source link

Feature: `@stream` support #2269

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/

john-twigg-ck commented 2 years ago

Is there a separate Issue for @defer support? Is it in progress?

jpvajda commented 2 years ago

@john-twigg-ck 👋 I just made a separate issue for @defer support in our iOS client. Apollo is currently working on supporting @defer with Apollo Router and our Web and Kotlin Clients and that is something we plan to release soon.

For the iOS client we have some networking layer improvements to make prior to supporting @defer and @stream as part of our 2.0 release. So this client will lag a bit behind in the support for @defer.

I hope that helps clarify.