Skip to content

Commit

Permalink
fix initialSubscriptionRequestHandlerId not being set
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Dec 15, 2024
1 parent 9a761c6 commit 628fa46
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 44 deletions.
1 change: 1 addition & 0 deletions examples/express-v4/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ app.use(
headerValue: 'my-secret-token',
},
},
initialSubscriptionRequestHandlerId: 'graphql-sse',
})
);

Expand Down
4 changes: 3 additions & 1 deletion examples/express-v4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -14,5 +15,6 @@
},
"scripts": {
"start": "ts-node index.ts"
}
},
"packageManager": "[email protected]"
}
84 changes: 84 additions & 0 deletions examples/express-v4/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,92 @@
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"
integrity sha512-p8Yy/8sw1caA8CdRIQBG5tiLHmxtQKObCijiAa9Ez+d4+PRffM4054xbju0msf+cvhJpnFEeNjxmVT/0ipktrg==
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"
Expand Down Expand Up @@ -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==

[email protected], unpipe@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
Expand Down
3 changes: 2 additions & 1 deletion examples/fastify-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"scripts": {
"start": "ts-node index.ts"
},
"private": true
"private": true,
"packageManager": "[email protected]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('WindowService', () => {
responses: [],
selectedOperation: null,
subscriptionConnectionParams: '{}',
subscriptionProviderId: 'websocket',
subscriptionRequestHandlerId: 'websocket',
subscriptionUrl: 'ws://localhost:3000',
subscriptionUseDefaultRequestHandler: false,
url: 'http://localhost:3000',
Expand Down Expand Up @@ -158,7 +158,7 @@ describe('WindowService', () => {
responses: [],
selectedOperation: null,
subscriptionConnectionParams: '{}',
subscriptionProviderId: 'websocket',
subscriptionRequestHandlerId: 'websocket',
subscriptionUrl: 'ws://localhost:3000',
subscriptionUseDefaultRequestHandler: false,
url: 'http://localhost:3000',
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('WindowService', () => {
responses: [],
selectedOperation: null,
subscriptionConnectionParams: '{}',
subscriptionProviderId: 'websocket',
subscriptionRequestHandlerId: 'websocket',
subscriptionUrl: 'ws://localhost:3001',
subscriptionUseDefaultRequestHandler: false,
url: 'http://localhost:3001',
Expand Down Expand Up @@ -264,7 +264,7 @@ describe('WindowService', () => {
responses: [],
selectedOperation: null,
subscriptionConnectionParams: '{}',
subscriptionProviderId: 'websocket',
subscriptionRequestHandlerId: 'websocket',
subscriptionUrl: 'ws://localhost:3000',
subscriptionUseDefaultRequestHandler: false,
url: 'http://localhost:3000',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions packages/altair-core/src/types/state/query.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 628fa46

Please sign in to comment.