Skip to content

Commit be437c7

Browse files
committed
legacySse flag
1 parent cb002dc commit be437c7

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

packages/graphql-yoga/src/plugins/useResultProcessor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const regular: ResultProcessorConfig = {
3737
const defaultList = [textEventStream, multipart, regular]
3838
const subscriptionList = [multipart, textEventStream, regular]
3939

40-
export function useResultProcessors(opts: { graphqlSse: boolean }): Plugin {
40+
export function useResultProcessors(opts: { legacySse: boolean }): Plugin {
4141
const isSubscriptionRequestMap = new WeakMap<Request, boolean>()
4242
return {
4343
onSubscribe({ args: { contextValue } }) {
@@ -66,10 +66,10 @@ export function useResultProcessors(opts: { graphqlSse: boolean }): Plugin {
6666
acceptableMediaTypes.push(processorMediaType)
6767
if (isMatchingMediaType(processorMediaType, requestMediaType)) {
6868
setResultProcessor(
69-
opts.graphqlSse &&
69+
opts.legacySse &&
7070
resultProcessorConfig.processResult === processPushResult
71-
? processGraphQLSSEResult
72-
: resultProcessorConfig.processResult,
71+
? resultProcessorConfig.processResult
72+
: processGraphQLSSEResult,
7373
processorMediaType,
7474
)
7575
}

packages/graphql-yoga/src/server.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,15 @@ export type YogaServerOptions<TServerContext, TUserContext> = {
171171
*/
172172
batching?: BatchingOptions
173173
/**
174-
* Use the [GraphQL over SSE spec](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md) for streaming results.
174+
* Use the legacy Yoga SSE and not the [GraphQL over SSE spec](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md) for streaming results.
175175
*
176-
* Currently GraphQL Yoga supports exclusively the ["distinct connections mode"](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md#distinct-connections-mode).
176+
* @note Currently GraphQL Yoga supports exclusively the ["distinct connections mode"](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md#distinct-connections-mode). For using the ["distinct connection mode"](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md#single-connections-mode) please [use the `@graphql-yoga/plugin-graphql-sse` plugin](https://the-guild.dev/graphql/yoga-server/docs/features/subscriptions#graphql-over-server-sent-events-protocol-via-graphql-sse).
177177
*
178-
* @note Starting from next major release of Yoga, this option will be dropped and GraphQL over SSE spec will be used exclusively.
178+
* @default true
179+
*
180+
* @deprecated Consider using GraphQL over SSE spec instead by setting this flag to `false`. Starting with the next major release, this flag will default to `false`.
179181
*/
180-
graphqlSse?: boolean
182+
legacySse?: boolean
181183
}
182184

183185
export type BatchingOptions =
@@ -353,7 +355,7 @@ export class YogaServer<
353355
}),
354356
// Middlewares after the GraphQL execution
355357
useResultProcessors({
356-
graphqlSse: !!options?.graphqlSse,
358+
legacySse: !!options?.legacySse,
357359
}),
358360
useErrorHandling((error, request) => {
359361
const errors = handleError(error, this.maskedErrorsOpts, this.logger)

0 commit comments

Comments
 (0)