aws-appsync-subscription-link 3.1.3 → 4.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/link/realtime-subscription-handshake-link-test.ts +559 -489
- package/jest.config.js +5 -1
- package/lib/index.d.mts +23 -0
- package/lib/index.d.ts +20 -3
- package/lib/index.js +4884 -44
- package/lib/index.mjs +4869 -0
- package/package.json +21 -6
- package/tsup.config.ts +19 -0
- package/lib/non-terminating-http-link.d.ts +0 -9
- package/lib/non-terminating-http-link.js +0 -32
- package/lib/non-terminating-link.d.ts +0 -15
- package/lib/non-terminating-link.js +0 -101
- package/lib/realtime-subscription-handshake-link.d.ts +0 -37
- package/lib/realtime-subscription-handshake-link.js +0 -795
- package/lib/subscription-handshake-link.d.ts +0 -25
- package/lib/subscription-handshake-link.js +0 -272
- package/lib/types/index.d.ts +0 -87
- package/lib/types/index.js +0 -75
- package/lib/utils/index.d.ts +0 -5
- package/lib/utils/index.js +0 -8
- package/lib/utils/logger.d.ts +0 -5
- package/lib/utils/logger.js +0 -20
- package/lib/utils/retry.d.ts +0 -19
- package/lib/utils/retry.js +0 -130
- package/lib/vendor/paho-mqtt.js +0 -2392
|
@@ -1,525 +1,595 @@
|
|
|
1
1
|
import { AUTH_TYPE } from "aws-appsync-auth-link";
|
|
2
|
-
import { execute } from "@apollo/client/core";
|
|
3
|
-
import gql from
|
|
4
|
-
import { AppSyncRealTimeSubscriptionHandshakeLink } from
|
|
2
|
+
import { execute, ApolloClient } from "@apollo/client/core";
|
|
3
|
+
import gql from "graphql-tag";
|
|
4
|
+
import { AppSyncRealTimeSubscriptionHandshakeLink } from "../../src/realtime-subscription-handshake-link";
|
|
5
5
|
import { MESSAGE_TYPES } from "../../src/types";
|
|
6
6
|
import { v4 as uuid } from "uuid";
|
|
7
|
-
jest.mock(
|
|
7
|
+
jest.mock("uuid", () => ({ v4: jest.fn() }));
|
|
8
8
|
|
|
9
|
-
const query = gql`
|
|
9
|
+
const query = gql`
|
|
10
|
+
subscription {
|
|
11
|
+
someSubscription {
|
|
12
|
+
aField
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
// Mock ApolloClient for execute context
|
|
18
|
+
const mockClient = {} as ApolloClient;
|
|
10
19
|
|
|
11
20
|
class myWebSocket implements WebSocket {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
21
|
+
binaryType: BinaryType = "arraybuffer";
|
|
22
|
+
bufferedAmount: number;
|
|
23
|
+
extensions: string;
|
|
24
|
+
onclose: (this: WebSocket, ev: CloseEvent) => any;
|
|
25
|
+
onerror: (this: WebSocket, ev: Event) => any;
|
|
26
|
+
onmessage: (this: WebSocket, ev: MessageEvent) => any;
|
|
27
|
+
onopen: (this: WebSocket, ev: Event) => any;
|
|
28
|
+
protocol: string;
|
|
29
|
+
readyState: number;
|
|
30
|
+
url: string;
|
|
31
|
+
close(code?: number, reason?: string): void {
|
|
32
|
+
throw new Error("Method not implemented.");
|
|
33
|
+
}
|
|
34
|
+
send(data: string | ArrayBuffer | Blob | ArrayBufferView): void {
|
|
35
|
+
throw new Error("Method not implemented.");
|
|
36
|
+
}
|
|
37
|
+
CLOSED: number;
|
|
38
|
+
CLOSING: number;
|
|
39
|
+
CONNECTING: number;
|
|
40
|
+
OPEN: number;
|
|
41
|
+
addEventListener<K extends "close" | "error" | "message" | "open">(
|
|
42
|
+
type: K,
|
|
43
|
+
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => void,
|
|
44
|
+
options?: boolean | AddEventListenerOptions
|
|
45
|
+
): void;
|
|
46
|
+
addEventListener(
|
|
47
|
+
type: string,
|
|
48
|
+
listener: EventListenerOrEventListenerObject,
|
|
49
|
+
options?: boolean | AddEventListenerOptions
|
|
50
|
+
): void;
|
|
51
|
+
addEventListener(type: any, listener: any, options?: any) {
|
|
52
|
+
throw new Error("Method not implemented.");
|
|
53
|
+
}
|
|
54
|
+
removeEventListener<K extends "close" | "error" | "message" | "open">(
|
|
55
|
+
type: K,
|
|
56
|
+
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => void,
|
|
57
|
+
options?: boolean | EventListenerOptions
|
|
58
|
+
): void;
|
|
59
|
+
removeEventListener(
|
|
60
|
+
type: string,
|
|
61
|
+
listener: EventListenerOrEventListenerObject,
|
|
62
|
+
options?: boolean | EventListenerOptions
|
|
63
|
+
): void;
|
|
64
|
+
removeEventListener(type: any, listener: any, options?: any) {
|
|
65
|
+
throw new Error("Method not implemented.");
|
|
66
|
+
}
|
|
67
|
+
dispatchEvent(event: Event): boolean {
|
|
68
|
+
throw new Error("Method not implemented.");
|
|
69
|
+
}
|
|
45
70
|
}
|
|
46
71
|
|
|
47
72
|
describe("RealTime subscription link", () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
url: 'https://firsttesturl12345678901234.appsync-api.us-west-2.amazonaws.com/graphql'
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
73
|
+
test("Can instantiate link", () => {
|
|
74
|
+
expect.assertions(1);
|
|
75
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
76
|
+
auth: {
|
|
77
|
+
type: AUTH_TYPE.API_KEY,
|
|
78
|
+
apiKey: "xxxxx",
|
|
79
|
+
},
|
|
80
|
+
region: "us-west-2",
|
|
81
|
+
url: "https://firsttesturl12345678901234.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
61
82
|
});
|
|
62
83
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("Can instantiate link with custom domain", () => {
|
|
88
|
+
expect.assertions(1);
|
|
89
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
90
|
+
auth: {
|
|
91
|
+
type: AUTH_TYPE.API_KEY,
|
|
92
|
+
apiKey: "xxxxx",
|
|
93
|
+
},
|
|
94
|
+
region: "us-west-2",
|
|
95
|
+
url: "https://test1.testcustomdomain.com/graphql",
|
|
75
96
|
});
|
|
76
97
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
done();
|
|
105
|
-
},
|
|
106
|
-
complete: () => {
|
|
107
|
-
console.log('done with this');
|
|
108
|
-
done();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
});
|
|
98
|
+
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("Initialize WebSocket correctly for API KEY", (done) => {
|
|
102
|
+
expect.assertions(2);
|
|
103
|
+
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
104
|
+
jest.fn(() => {
|
|
105
|
+
return "2019-11-13T18:47:04.733Z";
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
109
|
+
(url, protocol) => {
|
|
110
|
+
expect(url).toBe(
|
|
111
|
+
"wss://apikeytesturl1234567890123.appsync-realtime-api.us-west-2.amazonaws.com/graphql?header=eyJob3N0IjoiYXBpa2V5dGVzdHVybDEyMzQ1Njc4OTAxMjMuYXBwc3luYy1hcGkudXMtd2VzdC0yLmFtYXpvbmF3cy5jb20iLCJ4LWFtei1kYXRlIjoiMjAxOTExMTNUMTg0NzA0WiIsIngtYXBpLWtleSI6Inh4eHh4In0=&payload=e30="
|
|
112
|
+
);
|
|
113
|
+
expect(protocol).toBe("graphql-ws");
|
|
114
|
+
done();
|
|
115
|
+
return new myWebSocket();
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
119
|
+
auth: {
|
|
120
|
+
type: AUTH_TYPE.API_KEY,
|
|
121
|
+
apiKey: "xxxxx",
|
|
122
|
+
},
|
|
123
|
+
region: "us-west-2",
|
|
124
|
+
url: "https://apikeytesturl1234567890123.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
112
125
|
});
|
|
113
126
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
type: AUTH_TYPE.API_KEY,
|
|
128
|
-
apiKey: 'xxxxx'
|
|
129
|
-
},
|
|
130
|
-
region: 'us-west-2',
|
|
131
|
-
url: 'https://apikeytest.testcustomdomain.com/graphql'
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
execute(link, { query }).subscribe({
|
|
135
|
-
error: (err) => {
|
|
136
|
-
console.log(JSON.stringify(err));
|
|
137
|
-
fail;
|
|
138
|
-
},
|
|
139
|
-
next: (data) => {
|
|
140
|
-
console.log({ data });
|
|
141
|
-
done();
|
|
142
|
-
},
|
|
143
|
-
complete: () => {
|
|
144
|
-
console.log('done with this');
|
|
145
|
-
done();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
});
|
|
127
|
+
execute(link, { query }, { client: mockClient }).subscribe({
|
|
128
|
+
error: (err) => {
|
|
129
|
+
console.log(JSON.stringify(err));
|
|
130
|
+
fail;
|
|
131
|
+
},
|
|
132
|
+
next: (data) => {
|
|
133
|
+
console.log({ data });
|
|
134
|
+
done();
|
|
135
|
+
},
|
|
136
|
+
complete: () => {
|
|
137
|
+
console.log("done with this");
|
|
138
|
+
done();
|
|
139
|
+
},
|
|
149
140
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
next: (data) => {
|
|
177
|
-
console.log({ data });
|
|
178
|
-
done();
|
|
179
|
-
},
|
|
180
|
-
complete: () => {
|
|
181
|
-
console.log('done with this');
|
|
182
|
-
done();
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("Initialize WebSocket correctly for API KEY with custom domain", (done) => {
|
|
144
|
+
expect.assertions(2);
|
|
145
|
+
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
146
|
+
jest.fn(() => {
|
|
147
|
+
return "2019-11-13T18:47:04.733Z";
|
|
148
|
+
})
|
|
149
|
+
);
|
|
150
|
+
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
151
|
+
(url, protocol) => {
|
|
152
|
+
expect(url).toBe(
|
|
153
|
+
"wss://apikeytest.testcustomdomain.com/graphql/realtime?header=eyJob3N0IjoiYXBpa2V5dGVzdC50ZXN0Y3VzdG9tZG9tYWluLmNvbSIsIngtYW16LWRhdGUiOiIyMDE5MTExM1QxODQ3MDRaIiwieC1hcGkta2V5IjoieHh4eHgifQ==&payload=e30="
|
|
154
|
+
);
|
|
155
|
+
expect(protocol).toBe("graphql-ws");
|
|
156
|
+
done();
|
|
157
|
+
return new myWebSocket();
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
161
|
+
auth: {
|
|
162
|
+
type: AUTH_TYPE.API_KEY,
|
|
163
|
+
apiKey: "xxxxx",
|
|
164
|
+
},
|
|
165
|
+
region: "us-west-2",
|
|
166
|
+
url: "https://apikeytest.testcustomdomain.com/graphql",
|
|
186
167
|
});
|
|
187
168
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
169
|
+
execute(link, { query }, { client: mockClient }).subscribe({
|
|
170
|
+
error: (err) => {
|
|
171
|
+
console.log(JSON.stringify(err));
|
|
172
|
+
fail;
|
|
173
|
+
},
|
|
174
|
+
next: (data) => {
|
|
175
|
+
console.log({ data });
|
|
176
|
+
done();
|
|
177
|
+
},
|
|
178
|
+
complete: () => {
|
|
179
|
+
console.log("done with this");
|
|
180
|
+
done();
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test("Initialize WebSocket correctly for COGNITO USER POOLS", (done) => {
|
|
186
|
+
expect.assertions(2);
|
|
187
|
+
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
188
|
+
jest.fn(() => {
|
|
189
|
+
return "2019-11-13T18:47:04.733Z";
|
|
190
|
+
})
|
|
191
|
+
);
|
|
192
|
+
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
193
|
+
(url, protocol) => {
|
|
194
|
+
expect(url).toBe(
|
|
195
|
+
"wss://cognitouserpooltesturl1234.appsync-realtime-api.us-west-2.amazonaws.com/graphql?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoiY29nbml0b3VzZXJwb29sdGVzdHVybDEyMzQuYXBwc3luYy1hcGkudXMtd2VzdC0yLmFtYXpvbmF3cy5jb20ifQ==&payload=e30="
|
|
196
|
+
);
|
|
197
|
+
expect(protocol).toBe("graphql-ws");
|
|
198
|
+
done();
|
|
199
|
+
return new myWebSocket();
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
203
|
+
auth: {
|
|
204
|
+
type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
|
|
205
|
+
jwtToken: "token",
|
|
206
|
+
},
|
|
207
|
+
region: "us-west-2",
|
|
208
|
+
url: "https://cognitouserpooltesturl1234.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
223
209
|
});
|
|
224
210
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
211
|
+
execute(link, { query }, { client: mockClient }).subscribe({
|
|
212
|
+
error: (err) => {
|
|
213
|
+
console.log(JSON.stringify(err));
|
|
214
|
+
fail;
|
|
215
|
+
},
|
|
216
|
+
next: (data) => {
|
|
217
|
+
console.log({ data });
|
|
218
|
+
done();
|
|
219
|
+
},
|
|
220
|
+
complete: () => {
|
|
221
|
+
console.log("done with this");
|
|
222
|
+
done();
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
test("Initialize WebSocket correctly for COGNITO USER POOLS with custom domain", (done) => {
|
|
228
|
+
expect.assertions(2);
|
|
229
|
+
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
230
|
+
jest.fn(() => {
|
|
231
|
+
return "2019-11-13T18:47:04.733Z";
|
|
232
|
+
})
|
|
233
|
+
);
|
|
234
|
+
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
235
|
+
(url, protocol) => {
|
|
236
|
+
expect(url).toBe(
|
|
237
|
+
"wss://cognitouserpools.testcustomdomain.com/graphql/realtime?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoiY29nbml0b3VzZXJwb29scy50ZXN0Y3VzdG9tZG9tYWluLmNvbSJ9&payload=e30="
|
|
238
|
+
);
|
|
239
|
+
expect(protocol).toBe("graphql-ws");
|
|
240
|
+
done();
|
|
241
|
+
return new myWebSocket();
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
245
|
+
auth: {
|
|
246
|
+
type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
|
|
247
|
+
jwtToken: "token",
|
|
248
|
+
},
|
|
249
|
+
region: "us-west-2",
|
|
250
|
+
url: "https://cognitouserpools.testcustomdomain.com/graphql",
|
|
251
|
+
});
|
|
258
252
|
|
|
259
|
-
|
|
253
|
+
execute(link, { query }, { client: mockClient }).subscribe({
|
|
254
|
+
error: (err) => {
|
|
255
|
+
console.log(JSON.stringify(err));
|
|
256
|
+
fail;
|
|
257
|
+
},
|
|
258
|
+
next: (data) => {
|
|
259
|
+
console.log({ data });
|
|
260
|
+
done();
|
|
261
|
+
},
|
|
262
|
+
complete: () => {
|
|
263
|
+
console.log("done with this");
|
|
264
|
+
done();
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test("Initialize WebSocket correctly for OPENID_CONNECT", (done) => {
|
|
270
|
+
expect.assertions(2);
|
|
271
|
+
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
272
|
+
jest.fn(() => {
|
|
273
|
+
return "2019-11-13T18:47:04.733Z";
|
|
274
|
+
})
|
|
275
|
+
);
|
|
276
|
+
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
277
|
+
(url, protocol) => {
|
|
278
|
+
expect(url).toBe(
|
|
279
|
+
"wss://openidconnecttesturl123456.appsync-realtime-api.us-west-2.amazonaws.com/graphql?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0Ijoib3BlbmlkY29ubmVjdHRlc3R1cmwxMjM0NTYuYXBwc3luYy1hcGkudXMtd2VzdC0yLmFtYXpvbmF3cy5jb20ifQ==&payload=e30="
|
|
280
|
+
);
|
|
281
|
+
expect(protocol).toBe("graphql-ws");
|
|
282
|
+
done();
|
|
283
|
+
return new myWebSocket();
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
287
|
+
auth: {
|
|
288
|
+
type: AUTH_TYPE.OPENID_CONNECT,
|
|
289
|
+
jwtToken: "token",
|
|
290
|
+
},
|
|
291
|
+
region: "us-west-2",
|
|
292
|
+
url: "https://openidconnecttesturl123456.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
260
293
|
});
|
|
261
294
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
+
execute(link, { query }, { client: mockClient }).subscribe({
|
|
296
|
+
error: (err) => {
|
|
297
|
+
console.log(JSON.stringify(err));
|
|
298
|
+
fail;
|
|
299
|
+
},
|
|
300
|
+
next: (data) => {
|
|
301
|
+
console.log({ data });
|
|
302
|
+
done();
|
|
303
|
+
},
|
|
304
|
+
complete: () => {
|
|
305
|
+
console.log("done with this");
|
|
306
|
+
done();
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test("Initialize WebSocket correctly for OPENID_CONNECT with custom domain", (done) => {
|
|
312
|
+
expect.assertions(2);
|
|
313
|
+
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
314
|
+
jest.fn(() => {
|
|
315
|
+
return "2019-11-13T18:47:04.733Z";
|
|
316
|
+
})
|
|
317
|
+
);
|
|
318
|
+
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
319
|
+
(url, protocol) => {
|
|
320
|
+
expect(url).toBe(
|
|
321
|
+
"wss://openidconnecttesturl.testcustomdomain.com/graphql/realtime?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0Ijoib3BlbmlkY29ubmVjdHRlc3R1cmwudGVzdGN1c3RvbWRvbWFpbi5jb20ifQ==&payload=e30="
|
|
322
|
+
);
|
|
323
|
+
expect(protocol).toBe("graphql-ws");
|
|
324
|
+
done();
|
|
325
|
+
return new myWebSocket();
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
329
|
+
auth: {
|
|
330
|
+
type: AUTH_TYPE.OPENID_CONNECT,
|
|
331
|
+
jwtToken: "token",
|
|
332
|
+
},
|
|
333
|
+
region: "us-west-2",
|
|
334
|
+
url: "https://openidconnecttesturl.testcustomdomain.com/graphql",
|
|
335
|
+
});
|
|
295
336
|
|
|
296
|
-
|
|
337
|
+
execute(link, { query }, { client: mockClient }).subscribe({
|
|
338
|
+
error: (err) => {
|
|
339
|
+
console.log(JSON.stringify(err));
|
|
340
|
+
fail;
|
|
341
|
+
},
|
|
342
|
+
next: (data) => {
|
|
343
|
+
console.log({ data });
|
|
344
|
+
done();
|
|
345
|
+
},
|
|
346
|
+
complete: () => {
|
|
347
|
+
console.log("done with this");
|
|
348
|
+
done();
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
test("Initialize WebSocket correctly for AWS_LAMBDA", (done) => {
|
|
354
|
+
expect.assertions(2);
|
|
355
|
+
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
356
|
+
jest.fn(() => {
|
|
357
|
+
return "2019-11-13T18:47:04.733Z";
|
|
358
|
+
})
|
|
359
|
+
);
|
|
360
|
+
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
361
|
+
(url, protocol) => {
|
|
362
|
+
expect(url).toBe(
|
|
363
|
+
"wss://awslambdatesturl1234567890.appsync-realtime-api.us-west-2.amazonaws.com/graphql?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoiYXdzbGFtYmRhdGVzdHVybDEyMzQ1Njc4OTAuYXBwc3luYy1hcGkudXMtd2VzdC0yLmFtYXpvbmF3cy5jb20ifQ==&payload=e30="
|
|
364
|
+
);
|
|
365
|
+
expect(protocol).toBe("graphql-ws");
|
|
366
|
+
done();
|
|
367
|
+
return new myWebSocket();
|
|
368
|
+
}
|
|
369
|
+
);
|
|
370
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
371
|
+
auth: {
|
|
372
|
+
type: AUTH_TYPE.AWS_LAMBDA,
|
|
373
|
+
token: "token",
|
|
374
|
+
},
|
|
375
|
+
region: "us-west-2",
|
|
376
|
+
url: "https://awslambdatesturl1234567890.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
297
377
|
});
|
|
298
378
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
379
|
+
execute(link, { query }, { client: mockClient }).subscribe({
|
|
380
|
+
error: (err) => {
|
|
381
|
+
fail;
|
|
382
|
+
},
|
|
383
|
+
next: (data) => {
|
|
384
|
+
done();
|
|
385
|
+
},
|
|
386
|
+
complete: () => {
|
|
387
|
+
done();
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
test("Initialize WebSocket correctly for AWS_LAMBDA with custom domain", (done) => {
|
|
393
|
+
expect.assertions(2);
|
|
394
|
+
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
395
|
+
jest.fn(() => {
|
|
396
|
+
return "2019-11-13T18:47:04.733Z";
|
|
397
|
+
})
|
|
398
|
+
);
|
|
399
|
+
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
400
|
+
(url, protocol) => {
|
|
401
|
+
expect(url).toBe(
|
|
402
|
+
"wss://awslambdatesturl.testcustomdomain.com/graphql/realtime?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoiYXdzbGFtYmRhdGVzdHVybC50ZXN0Y3VzdG9tZG9tYWluLmNvbSJ9&payload=e30="
|
|
403
|
+
);
|
|
404
|
+
expect(protocol).toBe("graphql-ws");
|
|
405
|
+
done();
|
|
406
|
+
return new myWebSocket();
|
|
407
|
+
}
|
|
408
|
+
);
|
|
409
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
410
|
+
auth: {
|
|
411
|
+
type: AUTH_TYPE.AWS_LAMBDA,
|
|
412
|
+
token: "token",
|
|
413
|
+
},
|
|
414
|
+
region: "us-west-2",
|
|
415
|
+
url: "https://awslambdatesturl.testcustomdomain.com/graphql",
|
|
416
|
+
});
|
|
329
417
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
418
|
+
execute(link, { query }, { client: mockClient }).subscribe({
|
|
419
|
+
error: (err) => {
|
|
420
|
+
fail;
|
|
421
|
+
},
|
|
422
|
+
next: (data) => {
|
|
423
|
+
done();
|
|
424
|
+
},
|
|
425
|
+
complete: () => {
|
|
426
|
+
done();
|
|
427
|
+
},
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
test("Can use a custom keepAliveTimeoutMs", (done) => {
|
|
432
|
+
const id = "abcd-efgh-ijkl-mnop";
|
|
433
|
+
uuid.mockImplementationOnce(() => id);
|
|
434
|
+
|
|
435
|
+
expect.assertions(5);
|
|
436
|
+
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
437
|
+
jest.fn(() => {
|
|
438
|
+
return "2019-11-13T18:47:04.733Z";
|
|
439
|
+
})
|
|
440
|
+
);
|
|
441
|
+
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
442
|
+
(url, protocol) => {
|
|
443
|
+
expect(url).toBe(
|
|
444
|
+
"wss://apikeytest.testcustomdomain.com/graphql/realtime?header=eyJob3N0IjoiYXBpa2V5dGVzdC50ZXN0Y3VzdG9tZG9tYWluLmNvbSIsIngtYW16LWRhdGUiOiIyMDE5MTExM1QxODQ3MDRaIiwieC1hcGkta2V5IjoieHh4eHgifQ==&payload=e30="
|
|
445
|
+
);
|
|
446
|
+
expect(protocol).toBe("graphql-ws");
|
|
447
|
+
const socket = new myWebSocket();
|
|
448
|
+
|
|
449
|
+
setTimeout(() => {
|
|
450
|
+
socket.close = () => {};
|
|
451
|
+
socket.onopen.call(socket, undefined as unknown as Event);
|
|
452
|
+
socket.send = (msg: string) => {
|
|
453
|
+
const { type } = JSON.parse(msg);
|
|
454
|
+
|
|
455
|
+
switch (type) {
|
|
456
|
+
case MESSAGE_TYPES.GQL_CONNECTION_INIT:
|
|
457
|
+
socket.onmessage.call(socket, {
|
|
458
|
+
data: JSON.stringify({
|
|
459
|
+
type: MESSAGE_TYPES.GQL_CONNECTION_ACK,
|
|
460
|
+
payload: {
|
|
461
|
+
connectionTimeoutMs: 99999,
|
|
462
|
+
},
|
|
463
|
+
}),
|
|
464
|
+
} as MessageEvent);
|
|
465
|
+
setTimeout(() => {
|
|
466
|
+
socket.onmessage.call(socket, {
|
|
467
|
+
data: JSON.stringify({
|
|
468
|
+
id,
|
|
469
|
+
type: MESSAGE_TYPES.GQL_DATA,
|
|
470
|
+
payload: {
|
|
471
|
+
data: { something: 123 },
|
|
472
|
+
},
|
|
473
|
+
}),
|
|
474
|
+
} as MessageEvent);
|
|
475
|
+
}, 100);
|
|
476
|
+
break;
|
|
362
477
|
}
|
|
363
|
-
|
|
364
|
-
});
|
|
478
|
+
};
|
|
479
|
+
}, 100);
|
|
480
|
+
|
|
481
|
+
return socket;
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
485
|
+
auth: {
|
|
486
|
+
type: AUTH_TYPE.API_KEY,
|
|
487
|
+
apiKey: "xxxxx",
|
|
488
|
+
},
|
|
489
|
+
region: "us-west-2",
|
|
490
|
+
url: "https://apikeytest.testcustomdomain.com/graphql",
|
|
491
|
+
keepAliveTimeoutMs: 123456,
|
|
365
492
|
});
|
|
366
493
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
uuid.mockImplementationOnce(() => id);
|
|
370
|
-
|
|
371
|
-
expect.assertions(5);
|
|
372
|
-
jest.spyOn(Date.prototype, 'toISOString').mockImplementation(jest.fn(() => {
|
|
373
|
-
return "2019-11-13T18:47:04.733Z";
|
|
374
|
-
}));
|
|
375
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn((url, protocol) => {
|
|
376
|
-
expect(url).toBe('wss://apikeytest.testcustomdomain.com/graphql/realtime?header=eyJob3N0IjoiYXBpa2V5dGVzdC50ZXN0Y3VzdG9tZG9tYWluLmNvbSIsIngtYW16LWRhdGUiOiIyMDE5MTExM1QxODQ3MDRaIiwieC1hcGkta2V5IjoieHh4eHgifQ==&payload=e30=');
|
|
377
|
-
expect(protocol).toBe('graphql-ws');
|
|
378
|
-
const socket = new myWebSocket();
|
|
379
|
-
|
|
380
|
-
setTimeout(() => {
|
|
381
|
-
socket.close = () => {};
|
|
382
|
-
socket.onopen.call(socket, (undefined as unknown as Event));
|
|
383
|
-
socket.send = (msg: string) => {
|
|
384
|
-
const { type } = JSON.parse(msg);
|
|
385
|
-
|
|
386
|
-
switch (type) {
|
|
387
|
-
case MESSAGE_TYPES.GQL_CONNECTION_INIT:
|
|
388
|
-
socket.onmessage.call(socket, {
|
|
389
|
-
data: JSON.stringify({
|
|
390
|
-
type: MESSAGE_TYPES.GQL_CONNECTION_ACK,
|
|
391
|
-
payload: {
|
|
392
|
-
connectionTimeoutMs: 99999,
|
|
393
|
-
},
|
|
394
|
-
})
|
|
395
|
-
} as MessageEvent);
|
|
396
|
-
setTimeout(() => {
|
|
397
|
-
socket.onmessage.call(socket, {
|
|
398
|
-
data: JSON.stringify({
|
|
399
|
-
id,
|
|
400
|
-
type: MESSAGE_TYPES.GQL_DATA,
|
|
401
|
-
payload: {
|
|
402
|
-
data: { something: 123 },
|
|
403
|
-
},
|
|
404
|
-
})
|
|
405
|
-
} as MessageEvent);
|
|
406
|
-
|
|
407
|
-
}, 100);
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
}, 100);
|
|
412
|
-
|
|
413
|
-
return socket;
|
|
414
|
-
});
|
|
415
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
416
|
-
auth: {
|
|
417
|
-
type: AUTH_TYPE.API_KEY,
|
|
418
|
-
apiKey: 'xxxxx'
|
|
419
|
-
},
|
|
420
|
-
region: 'us-west-2',
|
|
421
|
-
url: 'https://apikeytest.testcustomdomain.com/graphql',
|
|
422
|
-
keepAliveTimeoutMs: 123456,
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
426
|
-
expect((link as any).keepAliveTimeout).toBe(123456);
|
|
494
|
+
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
495
|
+
expect((link as any).keepAliveTimeout).toBe(123456);
|
|
427
496
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
});
|
|
497
|
+
const sub = execute(link, { query }, { client: mockClient }).subscribe({
|
|
498
|
+
error: (err) => {
|
|
499
|
+
console.log(JSON.stringify(err));
|
|
500
|
+
fail();
|
|
501
|
+
},
|
|
502
|
+
next: (data) => {
|
|
503
|
+
expect((link as any).keepAliveTimeout).toBe(123456);
|
|
504
|
+
done();
|
|
505
|
+
sub.unsubscribe();
|
|
506
|
+
},
|
|
507
|
+
complete: () => {
|
|
508
|
+
console.log("done with this");
|
|
509
|
+
fail();
|
|
510
|
+
},
|
|
444
511
|
});
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
});
|
|
494
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
495
|
-
auth: {
|
|
496
|
-
type: AUTH_TYPE.API_KEY,
|
|
497
|
-
apiKey: 'xxxxx'
|
|
498
|
-
},
|
|
499
|
-
region: 'us-west-2',
|
|
500
|
-
url: 'https://apikeytest.testcustomdomain.com/graphql',
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
504
|
-
expect((link as any).keepAliveTimeout).toBeUndefined();
|
|
505
|
-
|
|
506
|
-
const sub = execute(link, { query }).subscribe({
|
|
507
|
-
error: (err) => {
|
|
508
|
-
console.log(JSON.stringify(err));
|
|
509
|
-
fail();
|
|
510
|
-
},
|
|
511
|
-
next: (data) => {
|
|
512
|
-
expect((link as any).keepAliveTimeout).toBe(99999);
|
|
513
|
-
done();
|
|
514
|
-
sub.unsubscribe();
|
|
515
|
-
},
|
|
516
|
-
complete: () => {
|
|
517
|
-
console.log('done with this');
|
|
518
|
-
fail();
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
test("Uses service-provided timeout when no custom keepAliveTimeoutMs is configured", (done) => {
|
|
515
|
+
const id = "abcd-efgh-ijkl-mnop";
|
|
516
|
+
uuid.mockImplementationOnce(() => id);
|
|
517
|
+
|
|
518
|
+
expect.assertions(5);
|
|
519
|
+
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
520
|
+
jest.fn(() => {
|
|
521
|
+
return "2019-11-13T18:47:04.733Z";
|
|
522
|
+
})
|
|
523
|
+
);
|
|
524
|
+
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
525
|
+
(url, protocol) => {
|
|
526
|
+
expect(url).toBe(
|
|
527
|
+
"wss://apikeytest.testcustomdomain.com/graphql/realtime?header=eyJob3N0IjoiYXBpa2V5dGVzdC50ZXN0Y3VzdG9tZG9tYWluLmNvbSIsIngtYW16LWRhdGUiOiIyMDE5MTExM1QxODQ3MDRaIiwieC1hcGkta2V5IjoieHh4eHgifQ==&payload=e30="
|
|
528
|
+
);
|
|
529
|
+
expect(protocol).toBe("graphql-ws");
|
|
530
|
+
const socket = new myWebSocket();
|
|
531
|
+
|
|
532
|
+
setTimeout(() => {
|
|
533
|
+
socket.close = () => {};
|
|
534
|
+
socket.onopen.call(socket, undefined as unknown as Event);
|
|
535
|
+
socket.send = (msg: string) => {
|
|
536
|
+
const { type } = JSON.parse(msg);
|
|
537
|
+
|
|
538
|
+
switch (type) {
|
|
539
|
+
case MESSAGE_TYPES.GQL_CONNECTION_INIT:
|
|
540
|
+
socket.onmessage.call(socket, {
|
|
541
|
+
data: JSON.stringify({
|
|
542
|
+
type: MESSAGE_TYPES.GQL_CONNECTION_ACK,
|
|
543
|
+
payload: {
|
|
544
|
+
connectionTimeoutMs: 99999,
|
|
545
|
+
},
|
|
546
|
+
}),
|
|
547
|
+
} as MessageEvent);
|
|
548
|
+
setTimeout(() => {
|
|
549
|
+
socket.onmessage.call(socket, {
|
|
550
|
+
data: JSON.stringify({
|
|
551
|
+
id,
|
|
552
|
+
type: MESSAGE_TYPES.GQL_DATA,
|
|
553
|
+
payload: {
|
|
554
|
+
data: { something: 123 },
|
|
555
|
+
},
|
|
556
|
+
}),
|
|
557
|
+
} as MessageEvent);
|
|
558
|
+
}, 100);
|
|
559
|
+
break;
|
|
519
560
|
}
|
|
520
|
-
|
|
521
|
-
});
|
|
561
|
+
};
|
|
562
|
+
}, 100);
|
|
563
|
+
|
|
564
|
+
return socket;
|
|
565
|
+
}
|
|
566
|
+
);
|
|
567
|
+
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
568
|
+
auth: {
|
|
569
|
+
type: AUTH_TYPE.API_KEY,
|
|
570
|
+
apiKey: "xxxxx",
|
|
571
|
+
},
|
|
572
|
+
region: "us-west-2",
|
|
573
|
+
url: "https://apikeytest.testcustomdomain.com/graphql",
|
|
522
574
|
});
|
|
523
575
|
|
|
524
|
-
|
|
576
|
+
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
577
|
+
expect((link as any).keepAliveTimeout).toBeUndefined();
|
|
578
|
+
|
|
579
|
+
const sub = execute(link, { query }, { client: mockClient }).subscribe({
|
|
580
|
+
error: (err) => {
|
|
581
|
+
console.log(JSON.stringify(err));
|
|
582
|
+
fail();
|
|
583
|
+
},
|
|
584
|
+
next: (data) => {
|
|
585
|
+
expect((link as any).keepAliveTimeout).toBe(99999);
|
|
586
|
+
done();
|
|
587
|
+
sub.unsubscribe();
|
|
588
|
+
},
|
|
589
|
+
complete: () => {
|
|
590
|
+
console.log("done with this");
|
|
591
|
+
fail();
|
|
592
|
+
},
|
|
593
|
+
});
|
|
594
|
+
});
|
|
525
595
|
});
|