Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(experimental) - Add full support for multipart/mixed defer and stream directive responses #1854

Merged
merged 30 commits into from
Aug 17, 2021

Conversation

kitten
Copy link
Member

@kitten kitten commented Aug 11, 2021

Add experimental support for @defer and @stream responses for GraphQL. This implements the "GraphQL Defer and Stream Directives" and "Incremental Delivery over HTTP" specifications. If a GraphQL API supports multipart/mixed responses for deferred and streamed delivery of GraphQL results, @urql/core (and all its derived fetch implementations) will attempt to stream results. This is only supported on browsers supporting streamed fetch responses, which excludes IE11.

The implementation of streamed multipart responses is derived from meros by @maraisr, and is subject to change if the RFCs end up changing.

For more information, read: https://graphql.org/blog/2020-12-08-improving-latency-with-defer-and-stream-directives

On fresh builds with a quick gzip check across all minified files ($ cat packages/core/dist/*.min.mjs | gzip-size) we see an increase from 5.32kB minzipped to 6.02kB minzipped, meaning a delta of approximately 700B.
On Graphcache ($ cat exchanges/graphcache/dist/*.min.mjs | gzip-size) we see a change from 9.38kB to 9.55kB, a delta of 170B.
Therefore we can estimate that the total impact of this feature is limited to <1kB minzipped.

@changeset-bot
Copy link

changeset-bot bot commented Aug 11, 2021

🦋 Changeset detected

Latest commit: 91b6650

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@urql/exchange-graphcache Minor
@urql/core Minor
@urql/exchange-execute Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kitten kitten changed the title WIP: Add initial (isomorphic) incremental multipart support WIP: (core) - Add initial (isomorphic) incremental multipart support Aug 11, 2021
@kitten kitten force-pushed the feat/incremental-multipart-responses branch from 2b1ed8c to 61028a9 Compare August 11, 2021 23:12
@kitten kitten force-pushed the feat/incremental-multipart-responses branch 2 times, most recently from 6b46f98 to ff61e9a Compare August 12, 2021 12:37
@kitten kitten changed the title WIP: (core) - Add initial (isomorphic) incremental multipart support (experimental) - Add full support for multipart/mixed defer and stream directive responses Aug 12, 2021
@kitten kitten marked this pull request as ready for review August 12, 2021 15:53
@kitten kitten force-pushed the feat/incremental-multipart-responses branch from d699304 to ebec0e6 Compare August 12, 2021 17:59
@kitten kitten force-pushed the feat/incremental-multipart-responses branch from ebec0e6 to 9e91428 Compare August 12, 2021 19:03
@kitten
Copy link
Member Author

kitten commented Aug 12, 2021

We've released initial prerelease versions:

Package Version
@urql/core@defer 2.3.0-defer.0
@urql/exchange-graphcache@defer 4.3.0-defer.0
@urql/exchange-execute@defer 1.1.0-defer.0

This will automatically enable this PR's patch. It may be necessary to create a resolution in Yarn, e.g. "resolutions": { "@urql/core": "2.3.0-defer.0" }, for the core package to remain deduplicated and on the new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants