Skip to content

Commit aa238af

Browse files
committed
chore: cleanup, tests, bump dependencies
1 parent e8d2297 commit aa238af

5 files changed

Lines changed: 60 additions & 28 deletions

File tree

packages/graphiql-toolkit/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121
"scripts": {},
2222
"dependencies": {
2323
"@n1ru4l/push-pull-async-iterable-iterator": "^2.0.1",
24-
"graphql-ws": "^4.1.0",
25-
"meros": "^1.1.2",
26-
"subscriptions-transport-ws": "^0.9.18"
24+
"graphql-ws": "^4.3.2",
25+
"meros": "^1.1.4"
2726
},
2827
"devDependencies": {
2928
"isomorphic-fetch": "^3.0.0",
30-
"graphql": "experimental-stream-defer"
29+
"graphql": "experimental-stream-defer",
30+
"subscriptions-transport-ws": "^0.9.18"
31+
},
32+
"optionalDependencies": {
33+
"subscriptions-transport-ws": "^0.9.18"
3134
},
3235
"keywords": [
3336
"graphql",

packages/graphiql-toolkit/src/create-fetcher/__tests__/lib.spec.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { parse } from 'graphql';
2-
import { isSubscriptionWithName, createWebsocketsFetcherFromUrl } from '../lib';
2+
import {
3+
isSubscriptionWithName,
4+
createWebsocketsFetcherFromUrl,
5+
getWsFetcher,
6+
} from '../lib';
37

48
import 'isomorphic-fetch';
59

@@ -59,3 +63,42 @@ describe('createWebsocketsFetcherFromUrl', () => {
5963
expect(createClient.mock.calls[0][0]).toEqual({ url: 'wss://example.com' });
6064
});
6165
});
66+
67+
describe('getWsFetcher', () => {
68+
afterEach(() => {
69+
jest.resetAllMocks();
70+
});
71+
it('provides an observable wsClient when custom wsClient option is provided', () => {
72+
createClient.mockReturnValue(true);
73+
getWsFetcher({
74+
url: '',
75+
// @ts-ignore
76+
wsClient: true,
77+
});
78+
// @ts-ignore
79+
expect(createClient.mock.calls).toHaveLength(0);
80+
});
81+
it('creates a subscriptions-transports-ws observable when custom legacyClient option is provided', () => {
82+
createClient.mockReturnValue(true);
83+
getWsFetcher({
84+
url: '',
85+
// @ts-ignore
86+
legacyClient: true,
87+
});
88+
// @ts-ignore
89+
expect(createClient.mock.calls).toHaveLength(0);
90+
expect(SubscriptionClient.mock.calls).toHaveLength(0);
91+
});
92+
93+
it('if subscriptionsUrl is provided, create a client on the fly', () => {
94+
createClient.mockReturnValue(true);
95+
getWsFetcher({
96+
url: '',
97+
subscriptionUrl: 'wss://example',
98+
});
99+
expect(createClient.mock.calls[0]).toEqual([
100+
{ connectionParams: undefined, url: 'wss://example' },
101+
]);
102+
expect(SubscriptionClient.mock.calls).toHaveLength(0);
103+
});
104+
});

packages/graphiql-toolkit/src/create-fetcher/createFetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function createGraphiQLFetcher(options: CreateFetcherOptions): Fetcher {
5757
`Your GraphiQL createFetcher is not properly configured for websocket subscriptions yet. ${
5858
options.subscriptionUrl
5959
? `Provided URL ${options.subscriptionUrl} failed`
60-
: `Try providing options.subscriptionUrl or options.wsClient first.`
60+
: `Please provide subscriptionUrl, wsClient or legacyClient option first.`
6161
}`,
6262
);
6363
}

packages/graphiql/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@
7474
"express-graphql": "experimental-stream-defer",
7575
"fork-ts-checker-webpack-plugin": "4.1.3",
7676
"graphql": "experimental-stream-defer",
77-
"graphql-transport-ws": "^1.9.0",
78-
"graphql-ws": "^4.1.0",
7977
"html-webpack-plugin": "^4.0.4",
8078
"identity-obj-proxy": "^3.0.0",
8179
"jest": "^24.8.0",

yarn.lock

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11137,17 +11137,10 @@ graphql-config@^3.0.2:
1113711137
string-env-interpolation "1.0.1"
1113811138
tslib "^2.0.0"
1113911139

11140-
graphql-transport-ws@^1.9.0:
11141-
version "1.9.0"
11142-
resolved "https://registry.yarnpkg.com/graphql-transport-ws/-/graphql-transport-ws-1.9.0.tgz#81891de870619d4e39242954a9e0f832dd980179"
11143-
integrity sha512-yrw7nIR4V+lWWRCVCa5ogagHWjlPLDO/Ld1177V4S4fqcMO4qVJyTgMKbTcAUXBhlEATqN7Scb5Oy8Ly+zKFwg==
11144-
dependencies:
11145-
ws "^7.3.1"
11146-
11147-
graphql-ws@^4.1.0:
11148-
version "4.1.0"
11149-
resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-4.1.0.tgz#cebe281474b5501d7be66210fb5711633b27fd78"
11150-
integrity sha512-DxJP1y2YzCqVLy7DrQN0iuR2l48vMOBWukX2d/J9aN2o5x9un5psIIq/2UFRh91UGARmfvPH86y1p4qbC1dITg==
11140+
graphql-ws@^4.3.2:
11141+
version "4.3.2"
11142+
resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-4.3.2.tgz#c58b03acc3bd5d4a92a6e9f729d29ba5e90d46a3"
11143+
integrity sha512-jsW6eOlko7fJek1iaSGQFj97AWuhexL9A3PuxYtyke/VlMdbSFzmDR4PlPPCTBBskRg6tNRb5RTbBVSd2T60JQ==
1115111144

1115211145
graphql@experimental-stream-defer:
1115311146
version "15.4.0-experimental-stream-defer.1"
@@ -14471,10 +14464,10 @@ merge@^1.2.0:
1447114464
resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.1.tgz#38bebf80c3220a8a487b6fcfb3941bb11720c145"
1447214465
integrity sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==
1447314466

14474-
meros@^1.1.2:
14475-
version "1.1.2"
14476-
resolved "https://registry.yarnpkg.com/meros/-/meros-1.1.2.tgz#12d5f520458ba8ae1536092824c1744fa09cf79d"
14477-
integrity sha512-BvOjEcEtGBOSts+lCCuqDe4LhSvzwQsQNxDB86ZY8RiAVQsPcmzxqm1/OjBBWv7vCufEEq8jstf4QJBBAHlDXg==
14467+
meros@^1.1.4:
14468+
version "1.1.4"
14469+
resolved "https://registry.yarnpkg.com/meros/-/meros-1.1.4.tgz#c17994d3133db8b23807f62bec7f0cb276cfd948"
14470+
integrity sha512-E9ZXfK9iQfG9s73ars9qvvvbSIkJZF5yOo9j4tcwM5tN8mUKfj/EKN5PzOr3ZH0y5wL7dLAHw3RVEfpQV9Q7VQ==
1447814471

1447914472
methods@~1.1.2:
1448014473
version "1.1.2"
@@ -21333,11 +21326,6 @@ ws@^7.2.1, ws@^7.2.3:
2133321326
resolved "https://registry.yarnpkg.com/ws/-/ws-7.3.1.tgz#d0547bf67f7ce4f12a72dfe31262c68d7dc551c8"
2133421327
integrity sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==
2133521328

21336-
ws@^7.3.1:
21337-
version "7.4.2"
21338-
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.2.tgz#782100048e54eb36fe9843363ab1c68672b261dd"
21339-
integrity sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA==
21340-
2134121329
wsrun@^5.2.4:
2134221330
version "5.2.4"
2134321331
resolved "https://registry.yarnpkg.com/wsrun/-/wsrun-5.2.4.tgz#6eb6c3ccd3327721a8df073a5e3578fb0dea494e"

0 commit comments

Comments
 (0)