From aa45342a78364d153ad75a6dc33cfadb40276dcf Mon Sep 17 00:00:00 2001 From: Samuel Imolorhe Date: Mon, 30 Dec 2024 13:09:27 +0100 Subject: [PATCH] added additional graphql-sse plugin for single connection mode testing --- test-server/package.json | 3 ++- test-server/src/yoga.ts | 23 ++++++++++++----------- test-server/yarn.lock | 15 +++++++++++---- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/test-server/package.json b/test-server/package.json index 5dd4d814d9..1f47b96e70 100644 --- a/test-server/package.json +++ b/test-server/package.json @@ -15,6 +15,7 @@ "@apollo/server": "^4.5.0", "@graphql-tools/schema": "^9.0.17", "@graphql-yoga/plugin-defer-stream": "^3.3.1", + "@graphql-yoga/plugin-graphql-sse": "^3.10.8", "axios": "^0.18.1", "body-parser": "^1.20.2", "chokidar": "^3.5.0", @@ -23,7 +24,7 @@ "cors": "^2.8.5", "express": "^4.19.2", "graphql": "^16.6.0", - "graphql-sse": "^2.1.3", + "graphql-sse": "^2.5.3", "graphql-subscriptions": "^2.0.0", "graphql-upload": "15.0.2", "graphql-ws": "^5.16.0", diff --git a/test-server/src/yoga.ts b/test-server/src/yoga.ts index 2951573914..3e0f778e5c 100644 --- a/test-server/src/yoga.ts +++ b/test-server/src/yoga.ts @@ -1,10 +1,11 @@ -import { createSchema, createYoga } from "graphql-yoga"; -import express, { Request, RequestHandler } from "express"; -import { createServer } from "http"; -import { resolvers, typeDefs } from "./schema"; -import { useDeferStream } from "@graphql-yoga/plugin-defer-stream"; -import { useServer } from "graphql-ws/lib/use/ws"; -import { WebSocketServer } from "ws"; +import { createSchema, createYoga } from 'graphql-yoga'; +import express from 'express'; +import { createServer } from 'http'; +import { resolvers, typeDefs } from './schema'; +import { useDeferStream } from '@graphql-yoga/plugin-defer-stream'; +import { useGraphQLSSE } from '@graphql-yoga/plugin-graphql-sse'; +import { useServer } from 'graphql-ws/lib/use/ws'; +import { WebSocketServer } from 'ws'; export const yogaMain = async () => { const schema = createSchema({ @@ -15,9 +16,9 @@ export const yogaMain = async () => { const yoga = createYoga({ schema, batching: true, - logging: "debug", + logging: 'debug', multipart: true, - plugins: [useDeferStream()], + plugins: [useDeferStream(), useGraphQLSSE()], }); const app = express(); @@ -25,7 +26,7 @@ export const yogaMain = async () => { app.use(async (req, res, next) => { console.log(req.headers); console.log(req.cookies); - res.set("x-auth", "text/plain"); + res.set('x-auth', 'text/plain'); // await delay(5000); return next(); }); @@ -73,6 +74,6 @@ export const yogaMain = async () => { ); server.listen(5400, () => { - console.log("Server is running on http://localhost:5400"); + console.log('Server is running on http://localhost:5400'); }); }; diff --git a/test-server/yarn.lock b/test-server/yarn.lock index ffe4e6b490..336c555ec8 100644 --- a/test-server/yarn.lock +++ b/test-server/yarn.lock @@ -260,6 +260,13 @@ dependencies: "@graphql-tools/utils" "^10.0.0" +"@graphql-yoga/plugin-graphql-sse@^3.10.8": + version "3.10.8" + resolved "https://registry.yarnpkg.com/@graphql-yoga/plugin-graphql-sse/-/plugin-graphql-sse-3.10.8.tgz#10221cb4e26404e7e9c647b74416277b2ed33888" + integrity sha512-fXpXGjCoaZgMfMwAJCdEU6/x796Jr37h/FH1u92CiAI69lwoPwzYWEa17APOKrz7p2frXRMcJO8lCdwxNUT21g== + dependencies: + graphql-sse "^2.0.0" + "@graphql-yoga/subscription@^5.0.0": version "5.0.0" resolved "https://registry.yarnpkg.com/@graphql-yoga/subscription/-/subscription-5.0.0.tgz#c0aedd3f7c0c0564a2fe687e9f45c16f70bdffc5" @@ -1283,10 +1290,10 @@ gopd@^1.0.1, gopd@^1.2.0: resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1" integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg== -graphql-sse@^2.1.3: - version "2.1.3" - resolved "https://registry.yarnpkg.com/graphql-sse/-/graphql-sse-2.1.3.tgz#c58d02a035a9efb281cedcf93cb98f454d1e529c" - integrity sha512-NZ4bek4VBlsEDSCnibq9MddbZ2AU4rAusTwUg3sbux4J3WOcZ6zB6Ysrw6rzfJq771wEmwPEMtXPVbOYZnnFUw== +graphql-sse@^2.0.0, graphql-sse@^2.5.3: + version "2.5.3" + resolved "https://registry.yarnpkg.com/graphql-sse/-/graphql-sse-2.5.3.tgz#c3557803f2db306d8ac87fd3bc089b6d4bac8353" + integrity sha512-5IcFW3e7fPOG7oFkK1v3X1wWtCJArQKB/H1UJeNotjy7a/9EYA5K+EiHJF1BiDSVNx7y64bd0FlDETrNBSvIHQ== graphql-subscriptions@^2.0.0: version "2.0.0"