Skip to content

Commit

Permalink
added additional graphql-sse plugin for single connection mode testing
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Dec 30, 2024
1 parent 0b0d801 commit aa45342
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
3 changes: 2 additions & 1 deletion test-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
23 changes: 12 additions & 11 deletions test-server/src/yoga.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -15,17 +16,17 @@ export const yogaMain = async () => {
const yoga = createYoga({
schema,
batching: true,
logging: "debug",
logging: 'debug',
multipart: true,
plugins: [useDeferStream()],
plugins: [useDeferStream(), useGraphQLSSE()],
});

const app = express();

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();
});
Expand Down Expand Up @@ -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');
});
};
15 changes: 11 additions & 4 deletions test-server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit aa45342

Please sign in to comment.