From 576d0174a4fb0a20f21bfe35e4da9e543665063d Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Sat, 24 Aug 2024 02:49:32 +0200 Subject: [PATCH] update graphql-ws --- examples/graphiql-webpack/package.json | 2 +- examples/monaco-graphql-nextjs/package.json | 2 +- packages/graphiql-toolkit/package.json | 2 +- packages/graphiql/test/e2e-server.js | 2 +- packages/graphiql/test/schema.js | 26 +++++++++---------- .../vscode-graphql-execution/package.json | 2 +- yarn.lock | 12 ++++----- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/examples/graphiql-webpack/package.json b/examples/graphiql-webpack/package.json index 7da913dffb..90c9947260 100644 --- a/examples/graphiql-webpack/package.json +++ b/examples/graphiql-webpack/package.json @@ -15,7 +15,7 @@ "@graphiql/react": "^0.26.1", "graphiql": "^3.7.0", "graphql": "^16.8.1", - "graphql-ws": "^5.5.5", + "graphql-ws": "^5.16.0", "react": "^18.2.0", "regenerator-runtime": "^0.13.9" }, diff --git a/examples/monaco-graphql-nextjs/package.json b/examples/monaco-graphql-nextjs/package.json index 2173f5ffb5..cf33adf36d 100644 --- a/examples/monaco-graphql-nextjs/package.json +++ b/examples/monaco-graphql-nextjs/package.json @@ -11,7 +11,7 @@ "dependencies": { "@graphiql/toolkit": "^0.11.0", "graphql": "^16.8.1", - "graphql-ws": "^5.5.5", + "graphql-ws": "^5.16.0", "jsonc-parser": "^3.2.0", "marked": "^4.2.12", "monaco-editor": "^0.39.0", diff --git a/packages/graphiql-toolkit/package.json b/packages/graphiql-toolkit/package.json index 945f16d6b2..072adab935 100644 --- a/packages/graphiql-toolkit/package.json +++ b/packages/graphiql-toolkit/package.json @@ -31,7 +31,7 @@ }, "devDependencies": { "graphql": "^17.0.0-alpha.7", - "graphql-ws": "^5.5.5", + "graphql-ws": "^5.16.0", "graphql-sse": "^2.5.3", "isomorphic-fetch": "^3.0.0", "subscriptions-transport-ws": "0.11.0", diff --git a/packages/graphiql/test/e2e-server.js b/packages/graphiql/test/e2e-server.js index 4c0fc5c8e9..f57a4668f1 100644 --- a/packages/graphiql/test/e2e-server.js +++ b/packages/graphiql/test/e2e-server.js @@ -67,7 +67,7 @@ app.use('/graphql/stream', (req, res, next) => { }); // Create the GraphQL over SSE handler -const sseHandler = createHandler({ schema: sseSchema }); +const sseHandler = createHandler({ schema, execute: customExecute }); // Serve all methods on `/graphql/stream` app.use('/graphql/stream', sseHandler); diff --git a/packages/graphiql/test/schema.js b/packages/graphiql/test/schema.js index f4dd5c5377..a114084185 100644 --- a/packages/graphiql/test/schema.js +++ b/packages/graphiql/test/schema.js @@ -5,6 +5,9 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ + +const graphql = require('graphql'); + const { GraphQLSchema, GraphQLObjectType, @@ -22,7 +25,12 @@ const { GraphQLStreamDirective, specifiedDirectives, version, -} = require('graphql'); +} = graphql; + +const directives = + parseInt(version, 10) > 16 + ? [...specifiedDirectives, GraphQLDeferDirective, GraphQLStreamDirective] + : specifiedDirectives; // Test Schema const TestEnum = new GraphQLEnumType({ @@ -374,7 +382,7 @@ const TestSubscriptionType = new GraphQLObjectType({ }, async *subscribe(root, args) { for (const hi of ['Hi', 'Bonjour', 'Hola', 'Ciao', 'Zdravo']) { - if (args.delay) { + if (args?.delay) { await sleep(args.delay); } yield { message: hi }; @@ -384,20 +392,12 @@ const TestSubscriptionType = new GraphQLObjectType({ }, }); -const schemaConfig = { +const myTestSchema = new GraphQLSchema({ query: TestType, mutation: TestMutationType, subscription: TestSubscriptionType, description: 'This is a test schema for GraphiQL', -}; - -exports.schema = new GraphQLSchema({ - ...schemaConfig, - directives: - parseInt(version, 10) > 16 - ? [...specifiedDirectives, GraphQLDeferDirective, GraphQLStreamDirective] - : specifiedDirectives, + directives, }); -// Same schema but without defer/stream directives -exports.sseSchema = new GraphQLSchema(schemaConfig); +exports.schema = myTestSchema; diff --git a/packages/vscode-graphql-execution/package.json b/packages/vscode-graphql-execution/package.json index 00fd9823a2..d5fde39ba3 100644 --- a/packages/vscode-graphql-execution/package.json +++ b/packages/vscode-graphql-execution/package.json @@ -112,7 +112,7 @@ "graphql": "^16.8.1 || ^17.0.0-alpha.2", "graphql-config": "5.0.3", "graphql-tag": "2.12.6", - "graphql-ws": "5.10.0", + "graphql-ws": "5.16.0", "svelte": "^4.1.1", "svelte2tsx": "^0.6.16", "ws": "8.17.1", diff --git a/yarn.lock b/yarn.lock index 1e5659ea15..657a39b80f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10517,16 +10517,16 @@ graphql-tag@2.12.6: dependencies: tslib "^2.1.0" -graphql-ws@5.10.0: - version "5.10.0" - resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.10.0.tgz#3fb47a4e809e0d2e7c197f1bca754fa9f31b940e" - integrity sha512-ewbPzHQdRZgNCPDH9Yr6xccSeZfk3fmpO/AGGGg4KkM5gc6oAOJQ10Oui1EqprhVOyRbOll9bw2qAkOiOwfTag== - -graphql-ws@5.14.0, graphql-ws@^5.5.5: +graphql-ws@5.14.0: version "5.14.0" resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.14.0.tgz#766f249f3974fc2c48fae0d1fb20c2c4c79cd591" integrity sha512-itrUTQZP/TgswR4GSSYuwWUzrE/w5GhbwM2GX3ic2U7aw33jgEsayfIlvaj7/GcIvZgNMzsPTrE5hqPuFUiE5g== +graphql-ws@5.16.0, graphql-ws@^5.16.0: + version "5.16.0" + resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.16.0.tgz#849efe02f384b4332109329be01d74c345842729" + integrity sha512-Ju2RCU2dQMgSKtArPbEtsK5gNLnsQyTNIo/T7cZNp96niC1x0KdJNZV0TIoilceBPQwfb5itrGl8pkFeOUMl4A== + graphql@17.0.0-alpha.7, graphql@^16.8.1, "graphql@^16.8.1 || ^17.0.0-alpha.2", graphql@^17.0.0-alpha.7: version "17.0.0-alpha.7" resolved "https://registry.yarnpkg.com/graphql/-/graphql-17.0.0-alpha.7.tgz#707e7457d7ed5316a8d7940f78809a2eb5854383"