Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is pushed the need for #3330
Yoga already has built-in support for Subscriptions over SSE (which I forgot until today).
These work fine when deployed to AWS which uses HTTP/2.
Locally, over HTTP/1, however there is the a 6 connection limit.
Apollo Sandbox/Explorer/Studio also does not support SSE, they have a similar "apollo http multipart" protocol.
Websockets are supported, so this is for them, and just to have flexibility in subscription protocol.
UI client could use either going forward.
How it works
This ties
fastify
,yoga
, andgraphql-ws
together.Execution layers in order:
This allows our fastify hooks to be executed.
And provides a consistent Fastify
Request
type,instead of a raw
IncomingMessage
.graphql-ws
's fastify handler (adapts # 2 to graphql-ws)graphql-ws
(handles specific gql protocol over websockets)graphql-yoga
is unwrapped toenvelop
.Yoga just wraps
envelop
and handles more of the http layer.We really just reference
envelop
hooks with our "Yoga Plugins".So this allows our "yoga" plugins to be executed.
@graphql-yoga/nestjs
goes a completely different direction with its subscription logic, which is why I abandoned it. It adapts from theApolloDriver
, doing a bunch of unnecessary low level work. It couldn't assume fastify, because express is also supported.This approach here fully embraces fastify & yoga, and both of their lifecycle hooks.
@coderabbitai ignore
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Chores
@fastify/websocket
andgraphql-ws
.