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

feat(core): Implement GraphQL SSE Response Support #3050

Merged
merged 8 commits into from
Mar 15, 2023
Merged

Conversation

kitten
Copy link
Member

@kitten kitten commented Mar 15, 2023

Summary

This implements support for text/event-stream responses, as per GraphQL SSE.

We've used GraphQL Yoga's "push" mechanism as a general template for what this must look like: https://github.com/dotansimha/graphql-yoga/blob/d2060c1/packages/graphql-yoga/src/plugins/resultProcessor/push.ts
And this generally adheres to the GraphQL SSE protocol: https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md

The current implementation found it unnecessary to respect event: type fields, instead it will just loosely look at data: fields and attempt to parse them.

We generally regard this as an alternative to multipart/mixed responses, and the protocol is loosely supported alongside it, while basically being an alternative to text/event-stream.
Currently, it's unclear to us when which one would be preferred, and we believe that's up to implementors and APIs to decide.

We also know that subscription operations could now be implemented with either response formats, however, we haven't decided yet how the default fetchExchange could switch over to handle subscription operations. This could be an option on the Client, but, we think that overall we already have a lot of fetch-related options on the Client, some of which may have to go. Discussion needed ✌️

5.9kB -> 5.98 kB min+gzip

Set of changes

  • Add selector for response handlers
  • Implement parseEventStream handler alongside parseMultipartMixed

@kitten kitten merged commit afc68a1 into main Mar 15, 2023
@kitten kitten deleted the feat/sse-support branch March 15, 2023 18:28
This was referenced Mar 15, 2023
@github-actions github-actions bot mentioned this pull request Mar 27, 2023
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.

2 participants