From 628fa464e1e63958bf900e7638e61a4c6e5dd807 Mon Sep 17 00:00:00 2001 From: Samuel Imolorhe Date: Sun, 15 Dec 2024 02:56:55 +0100 Subject: [PATCH] fix initialSubscriptionRequestHandlerId not being set --- examples/express-v4/index.ts | 1 + examples/express-v4/package.json | 4 +- examples/express-v4/yarn.lock | 84 +++++++++++++++++++ examples/fastify-v5/package.json | 3 +- .../services/query/query.service.spec.ts | 27 ------ .../altair/services/query/query.service.ts | 6 +- .../altair/services/window.service.spec.ts | 8 +- .../altair/store/query/query.reducer.ts | 2 +- .../src/types/state/query.interfaces.ts | 5 -- 9 files changed, 96 insertions(+), 44 deletions(-) diff --git a/examples/express-v4/index.ts b/examples/express-v4/index.ts index 0fd66e487b..bd748c7e9b 100644 --- a/examples/express-v4/index.ts +++ b/examples/express-v4/index.ts @@ -18,6 +18,7 @@ app.use( headerValue: 'my-secret-token', }, }, + initialSubscriptionRequestHandlerId: 'graphql-sse', }) ); diff --git a/examples/express-v4/package.json b/examples/express-v4/package.json index 60104b1540..ab9b6858e7 100644 --- a/examples/express-v4/package.json +++ b/examples/express-v4/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "main": "index.js", "devDependencies": { + "@types/express": "^5.0.0", "@types/node": "^22.7.4", "ts-node": "^10.9.2", "typescript": "5.2.2" @@ -14,5 +15,6 @@ }, "scripts": { "start": "ts-node index.ts" - } + }, + "packageManager": "yarn@1.22.17" } diff --git a/examples/express-v4/yarn.lock b/examples/express-v4/yarn.lock index f6eb5c3ad6..33f5a55e58 100644 --- a/examples/express-v4/yarn.lock +++ b/examples/express-v4/yarn.lock @@ -47,6 +47,58 @@ resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== +"@types/body-parser@*": + version "1.19.5" + resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.5.tgz#04ce9a3b677dc8bd681a17da1ab9835dc9d3ede4" + integrity sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg== + dependencies: + "@types/connect" "*" + "@types/node" "*" + +"@types/connect@*": + version "3.4.38" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858" + integrity sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug== + dependencies: + "@types/node" "*" + +"@types/express-serve-static-core@^5.0.0": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-5.0.2.tgz#812d2871e5eea17fb0bd5214dda7a7b748c0e12a" + integrity sha512-vluaspfvWEtE4vcSDlKRNer52DvOGrB2xv6diXy6UKyKW0lqZiWHGNApSyxOv+8DE5Z27IzVvE7hNkxg7EXIcg== + dependencies: + "@types/node" "*" + "@types/qs" "*" + "@types/range-parser" "*" + "@types/send" "*" + +"@types/express@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@types/express/-/express-5.0.0.tgz#13a7d1f75295e90d19ed6e74cab3678488eaa96c" + integrity sha512-DvZriSMehGHL1ZNLzi6MidnsDhUZM/x2pRdDIKdwbUNqqwHxMlRdkxtn6/EPKyqKpHqTl/4nRZsRNLpZxZRpPQ== + dependencies: + "@types/body-parser" "*" + "@types/express-serve-static-core" "^5.0.0" + "@types/qs" "*" + "@types/serve-static" "*" + +"@types/http-errors@*": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.4.tgz#7eb47726c391b7345a6ec35ad7f4de469cf5ba4f" + integrity sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA== + +"@types/mime@^1": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690" + integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w== + +"@types/node@*": + version "22.10.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.10.2.tgz#a485426e6d1fdafc7b0d4c7b24e2c78182ddabb9" + integrity sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ== + dependencies: + undici-types "~6.20.0" + "@types/node@^22.7.4": version "22.9.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-22.9.1.tgz#bdf91c36e0e7ecfb7257b2d75bf1b206b308ca71" @@ -54,6 +106,33 @@ dependencies: undici-types "~6.19.8" +"@types/qs@*": + version "6.9.17" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.17.tgz#fc560f60946d0aeff2f914eb41679659d3310e1a" + integrity sha512-rX4/bPcfmvxHDv0XjfJELTTr+iB+tn032nPILqHm5wbthUUUuVtNGGqzhya9XUxjTP8Fpr0qYgSZZKxGY++svQ== + +"@types/range-parser@*": + version "1.2.7" + resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb" + integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ== + +"@types/send@*": + version "0.17.4" + resolved "https://registry.yarnpkg.com/@types/send/-/send-0.17.4.tgz#6619cd24e7270793702e4e6a4b958a9010cfc57a" + integrity sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA== + dependencies: + "@types/mime" "^1" + "@types/node" "*" + +"@types/serve-static@*": + version "1.15.7" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.15.7.tgz#22174bbd74fb97fe303109738e9b5c2f3064f714" + integrity sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw== + dependencies: + "@types/http-errors" "*" + "@types/node" "*" + "@types/send" "*" + accepts@~1.3.8: version "1.3.8" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" @@ -565,6 +644,11 @@ undici-types@~6.19.8: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== +undici-types@~6.20.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.20.0.tgz#8171bf22c1f588d1554d55bf204bc624af388433" + integrity sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg== + unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" diff --git a/examples/fastify-v5/package.json b/examples/fastify-v5/package.json index 4dbdd4f093..a10a9aad69 100644 --- a/examples/fastify-v5/package.json +++ b/examples/fastify-v5/package.json @@ -14,5 +14,6 @@ "scripts": { "start": "ts-node index.ts" }, - "private": true + "private": true, + "packageManager": "yarn@1.22.17" } diff --git a/packages/altair-app/src/app/modules/altair/services/query/query.service.spec.ts b/packages/altair-app/src/app/modules/altair/services/query/query.service.spec.ts index ed0b293f17..fec604932b 100644 --- a/packages/altair-app/src/app/modules/altair/services/query/query.service.spec.ts +++ b/packages/altair-app/src/app/modules/altair/services/query/query.service.spec.ts @@ -292,32 +292,5 @@ describe('QueryService', () => { ); expect(requestHandler).toBeInstanceOf(ActionCableRequestHandler); }); - - it('should fallback to return handler specified in subscriptionProviderId for subscription if subscriptionRequestHandlerId is not set', async () => { - const requestHandler = await service.getRequestHandler( - { - query: { - url: 'http://localhost:3000/graphql', - query: 'subscription { hello }', - variables: '{ "name": "world" }', - subscriptionConnectionParams: '{ "name": "world" }', - subscriptionProviderId: GRAPHQL_SSE_HANDLER_ID, - requestHandlerId: HTTP_HANDLER_ID, // This should be ignored since it's a subscription - }, - variables: { - variables: '{ "name": "world" }', - }, - headers: [ - { - key: 'Content-Type', - value: 'application/json', - enabled: true, - }, - ], - } as unknown as PerWindowState, - true - ); - expect(requestHandler).toBeInstanceOf(SSERequestHandler); - }); }); }); diff --git a/packages/altair-app/src/app/modules/altair/services/query/query.service.ts b/packages/altair-app/src/app/modules/altair/services/query/query.service.ts index c43b0dc95b..119fabeffe 100644 --- a/packages/altair-app/src/app/modules/altair/services/query/query.service.ts +++ b/packages/altair-app/src/app/modules/altair/services/query/query.service.ts @@ -318,11 +318,7 @@ export class QueryService { if (isSubscription) { if (!window.query.subscriptionUseDefaultRequestHandler) { - return ( - window.query.subscriptionRequestHandlerId ?? - window.query.subscriptionProviderId ?? - WEBSOCKET_HANDLER_ID - ); + return window.query.subscriptionRequestHandlerId ?? WEBSOCKET_HANDLER_ID; } } diff --git a/packages/altair-app/src/app/modules/altair/services/window.service.spec.ts b/packages/altair-app/src/app/modules/altair/services/window.service.spec.ts index eab32f365f..6ee77b0f55 100644 --- a/packages/altair-app/src/app/modules/altair/services/window.service.spec.ts +++ b/packages/altair-app/src/app/modules/altair/services/window.service.spec.ts @@ -107,7 +107,7 @@ describe('WindowService', () => { responses: [], selectedOperation: null, subscriptionConnectionParams: '{}', - subscriptionProviderId: 'websocket', + subscriptionRequestHandlerId: 'websocket', subscriptionUrl: 'ws://localhost:3000', subscriptionUseDefaultRequestHandler: false, url: 'http://localhost:3000', @@ -158,7 +158,7 @@ describe('WindowService', () => { responses: [], selectedOperation: null, subscriptionConnectionParams: '{}', - subscriptionProviderId: 'websocket', + subscriptionRequestHandlerId: 'websocket', subscriptionUrl: 'ws://localhost:3000', subscriptionUseDefaultRequestHandler: false, url: 'http://localhost:3000', @@ -218,7 +218,7 @@ describe('WindowService', () => { responses: [], selectedOperation: null, subscriptionConnectionParams: '{}', - subscriptionProviderId: 'websocket', + subscriptionRequestHandlerId: 'websocket', subscriptionUrl: 'ws://localhost:3001', subscriptionUseDefaultRequestHandler: false, url: 'http://localhost:3001', @@ -264,7 +264,7 @@ describe('WindowService', () => { responses: [], selectedOperation: null, subscriptionConnectionParams: '{}', - subscriptionProviderId: 'websocket', + subscriptionRequestHandlerId: 'websocket', subscriptionUrl: 'ws://localhost:3000', subscriptionUseDefaultRequestHandler: false, url: 'http://localhost:3000', diff --git a/packages/altair-app/src/app/modules/altair/store/query/query.reducer.ts b/packages/altair-app/src/app/modules/altair/store/query/query.reducer.ts index a3e45e8402..49546d5be2 100644 --- a/packages/altair-app/src/app/modules/altair/store/query/query.reducer.ts +++ b/packages/altair-app/src/app/modules/altair/store/query/query.reducer.ts @@ -48,7 +48,7 @@ export const getInitialState = (): QueryState => { subscriptionConnectionParams: initialData.initialSubscriptionsPayload ? JSON.stringify(initialData.initialSubscriptionsPayload) : '{}', - subscriptionProviderId: + subscriptionRequestHandlerId: initialData.initialSubscriptionRequestHandlerId ?? WEBSOCKET_HANDLER_ID, isSubscribed: false, autoscrollResponseList: false, diff --git a/packages/altair-core/src/types/state/query.interfaces.ts b/packages/altair-core/src/types/state/query.interfaces.ts index 179f05d1b8..2ffc6d0a4d 100644 --- a/packages/altair-core/src/types/state/query.interfaces.ts +++ b/packages/altair-core/src/types/state/query.interfaces.ts @@ -57,11 +57,6 @@ export interface QueryState { editorAlertMessage: string; editorAlertSuccess: boolean; subscriptionConnectionParams: string; - - /** - * @deprecated Use {@link subscriptionRequestHandlerId} instead. Will be removed in future versions. - */ - subscriptionProviderId?: string; subscriptionRequestHandlerId?: RequestHandlerIds; isSubscribed: boolean; autoscrollResponseList: boolean;