graphile-realtime-test 1.19.12 → 1.19.14
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/README.md +1 -1
- package/context.d.ts +1 -1
- package/esm/notify.js +5 -4
- package/esm/subscribe.js +7 -4
- package/esm/ws-server.js +4 -4
- package/notify.d.ts +3 -3
- package/notify.js +5 -4
- package/package.json +5 -5
- package/subscribe.js +6 -3
- package/ws-server.js +4 -4
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ Fires a DML NOTIFY with the standard payload format.
|
|
|
91
91
|
|
|
92
92
|
### `notifyInvalidate(client, schema, table)`
|
|
93
93
|
|
|
94
|
-
Fires
|
|
94
|
+
Fires a legacy INVALIDATE NOTIFY for protocol rejection tests. Valid overflow is produced only after a batch of visible row IDs exceeds the subscriber's throttle limit.
|
|
95
95
|
|
|
96
96
|
### `buildPayload(operation, rowIds)`
|
|
97
97
|
|
package/context.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export interface RealtimeTestContext {
|
|
|
58
58
|
*/
|
|
59
59
|
notifyChange(table: string, operation: 'INSERT' | 'UPDATE' | 'DELETE', rowIds: string[], schema?: string): Promise<void>;
|
|
60
60
|
/**
|
|
61
|
-
* Fire
|
|
61
|
+
* Fire a legacy INVALIDATE NOTIFY for protocol rejection tests.
|
|
62
62
|
*/
|
|
63
63
|
notifyInvalidate(table: string, schema?: string): Promise<void>;
|
|
64
64
|
/**
|
package/esm/notify.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { realtimeChannel } from 'graphile-realtime-subscriptions';
|
|
1
2
|
/**
|
|
2
3
|
* Fire a pg_notify on the realtime channel for a given schema.table.
|
|
3
4
|
*
|
|
4
5
|
* The channel format matches what emit_change uses:
|
|
5
|
-
* `realtime
|
|
6
|
+
* `realtime:` plus the hash of the length-framed schema and table names.
|
|
6
7
|
*
|
|
7
8
|
* @param client - A pg Client (or PoolClient) to run the NOTIFY on
|
|
8
9
|
* @param schema - The PostgreSQL schema name (e.g. 'public')
|
|
@@ -10,7 +11,7 @@
|
|
|
10
11
|
* @param payload - The NOTIFY payload string
|
|
11
12
|
*/
|
|
12
13
|
export async function notify(client, schema, table, payload) {
|
|
13
|
-
const channel =
|
|
14
|
+
const channel = realtimeChannel(schema, table);
|
|
14
15
|
await client.query(`SELECT pg_notify($1, $2)`, [channel, payload]);
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
@@ -27,7 +28,7 @@ export function buildPayload(operation, rowIds) {
|
|
|
27
28
|
return `${operation}:${rowIds.join(',')}`;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
|
-
* Build
|
|
31
|
+
* Build a legacy INVALIDATE payload for protocol rejection tests.
|
|
31
32
|
*/
|
|
32
33
|
export function buildInvalidatePayload() {
|
|
33
34
|
return 'INVALIDATE';
|
|
@@ -45,7 +46,7 @@ export async function notifyChange(client, schema, table, operation, rowIds) {
|
|
|
45
46
|
await notify(client, schema, table, buildPayload(operation, rowIds));
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
+
* Fire a legacy INVALIDATE NOTIFY for protocol rejection tests.
|
|
49
50
|
*/
|
|
50
51
|
export async function notifyInvalidate(client, schema, table) {
|
|
51
52
|
await notify(client, schema, table, buildInvalidatePayload());
|
package/esm/subscribe.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { subscribe as grafastSubscribe } from 'grafast';
|
|
1
|
+
import { hookArgs, subscribe as grafastSubscribe } from 'grafast';
|
|
2
2
|
import { parse } from 'graphql';
|
|
3
3
|
/**
|
|
4
4
|
* Call grafast.subscribe() and return the raw async iterator.
|
|
@@ -11,13 +11,16 @@ import { parse } from 'graphql';
|
|
|
11
11
|
*/
|
|
12
12
|
export async function subscribe(opts) {
|
|
13
13
|
const document = typeof opts.query === 'string' ? parse(opts.query) : opts.query;
|
|
14
|
-
const
|
|
14
|
+
const args = {
|
|
15
15
|
schema: opts.schema,
|
|
16
16
|
document,
|
|
17
17
|
variableValues: opts.variables ?? undefined,
|
|
18
|
-
contextValue:
|
|
18
|
+
contextValue: {},
|
|
19
19
|
resolvedPreset: opts.resolvedPreset,
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
|
+
await hookArgs(args);
|
|
22
|
+
Object.assign(args.contextValue, opts.contextValue);
|
|
23
|
+
const result = await grafastSubscribe(args);
|
|
21
24
|
return result;
|
|
22
25
|
}
|
|
23
26
|
/**
|
package/esm/ws-server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createServer } from 'node:http';
|
|
2
|
-
import { subscribe as grafastSubscribe } from 'grafast';
|
|
3
2
|
import { createClient } from 'graphql-ws';
|
|
4
3
|
import { useServer } from 'graphql-ws/use/ws';
|
|
5
4
|
import { WebSocket, WebSocketServer } from 'ws';
|
|
5
|
+
import { subscribe as subscribeHelper } from './subscribe.js';
|
|
6
6
|
export async function createWsTestServer(input) {
|
|
7
7
|
const { schema, resolvedPreset, pgSubscriber, pgSubscriberKey = 'pgSubscriber', buildPgSettings, } = input;
|
|
8
8
|
const httpServer = createServer();
|
|
@@ -26,10 +26,10 @@ export async function createWsTestServer(input) {
|
|
|
26
26
|
contextValue['pgSettings'] = pgSettings;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
const result = await
|
|
29
|
+
const result = await subscribeHelper({
|
|
30
30
|
schema: args.schema,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
query: args.document,
|
|
32
|
+
variables: args.variableValues,
|
|
33
33
|
contextValue,
|
|
34
34
|
resolvedPreset,
|
|
35
35
|
});
|
package/notify.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Client } from 'pg';
|
|
|
3
3
|
* Fire a pg_notify on the realtime channel for a given schema.table.
|
|
4
4
|
*
|
|
5
5
|
* The channel format matches what emit_change uses:
|
|
6
|
-
* `realtime
|
|
6
|
+
* `realtime:` plus the hash of the length-framed schema and table names.
|
|
7
7
|
*
|
|
8
8
|
* @param client - A pg Client (or PoolClient) to run the NOTIFY on
|
|
9
9
|
* @param schema - The PostgreSQL schema name (e.g. 'public')
|
|
@@ -20,7 +20,7 @@ export declare function notify(client: Client, schema: string, table: string, pa
|
|
|
20
20
|
*/
|
|
21
21
|
export declare function buildPayload(operation: 'INSERT' | 'UPDATE' | 'DELETE', rowIds: string[]): string;
|
|
22
22
|
/**
|
|
23
|
-
* Build
|
|
23
|
+
* Build a legacy INVALIDATE payload for protocol rejection tests.
|
|
24
24
|
*/
|
|
25
25
|
export declare function buildInvalidatePayload(): string;
|
|
26
26
|
/**
|
|
@@ -34,6 +34,6 @@ export declare function buildInvalidatePayload(): string;
|
|
|
34
34
|
*/
|
|
35
35
|
export declare function notifyChange(client: Client, schema: string, table: string, operation: 'INSERT' | 'UPDATE' | 'DELETE', rowIds: string[]): Promise<void>;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Fire a legacy INVALIDATE NOTIFY for protocol rejection tests.
|
|
38
38
|
*/
|
|
39
39
|
export declare function notifyInvalidate(client: Client, schema: string, table: string): Promise<void>;
|
package/notify.js
CHANGED
|
@@ -5,11 +5,12 @@ exports.buildPayload = buildPayload;
|
|
|
5
5
|
exports.buildInvalidatePayload = buildInvalidatePayload;
|
|
6
6
|
exports.notifyChange = notifyChange;
|
|
7
7
|
exports.notifyInvalidate = notifyInvalidate;
|
|
8
|
+
const graphile_realtime_subscriptions_1 = require("graphile-realtime-subscriptions");
|
|
8
9
|
/**
|
|
9
10
|
* Fire a pg_notify on the realtime channel for a given schema.table.
|
|
10
11
|
*
|
|
11
12
|
* The channel format matches what emit_change uses:
|
|
12
|
-
* `realtime
|
|
13
|
+
* `realtime:` plus the hash of the length-framed schema and table names.
|
|
13
14
|
*
|
|
14
15
|
* @param client - A pg Client (or PoolClient) to run the NOTIFY on
|
|
15
16
|
* @param schema - The PostgreSQL schema name (e.g. 'public')
|
|
@@ -17,7 +18,7 @@ exports.notifyInvalidate = notifyInvalidate;
|
|
|
17
18
|
* @param payload - The NOTIFY payload string
|
|
18
19
|
*/
|
|
19
20
|
async function notify(client, schema, table, payload) {
|
|
20
|
-
const channel =
|
|
21
|
+
const channel = (0, graphile_realtime_subscriptions_1.realtimeChannel)(schema, table);
|
|
21
22
|
await client.query(`SELECT pg_notify($1, $2)`, [channel, payload]);
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
@@ -34,7 +35,7 @@ function buildPayload(operation, rowIds) {
|
|
|
34
35
|
return `${operation}:${rowIds.join(',')}`;
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
|
-
* Build
|
|
38
|
+
* Build a legacy INVALIDATE payload for protocol rejection tests.
|
|
38
39
|
*/
|
|
39
40
|
function buildInvalidatePayload() {
|
|
40
41
|
return 'INVALIDATE';
|
|
@@ -52,7 +53,7 @@ async function notifyChange(client, schema, table, operation, rowIds) {
|
|
|
52
53
|
await notify(client, schema, table, buildPayload(operation, rowIds));
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
55
|
-
*
|
|
56
|
+
* Fire a legacy INVALIDATE NOTIFY for protocol rejection tests.
|
|
56
57
|
*/
|
|
57
58
|
async function notifyInvalidate(client, schema, table) {
|
|
58
59
|
await notify(client, schema, table, buildInvalidatePayload());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-realtime-test",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.14",
|
|
4
4
|
"description": "Subscription testing utilities for graphile-realtime-subscriptions — smart tag injection, grafast.subscribe() helpers, and pg_notify simulation",
|
|
5
5
|
"author": "Constructive <developers@constructive.io>",
|
|
6
6
|
"homepage": "https://github.com/constructive-io/constructive",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"url": "https://github.com/constructive-io/constructive/issues"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"graphile-realtime-subscriptions": "^1.13.
|
|
43
|
-
"graphile-test": "^5.19.
|
|
42
|
+
"graphile-realtime-subscriptions": "^1.13.1",
|
|
43
|
+
"graphile-test": "^5.19.13"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"grafast": "^1.1.1",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"express": "^5.2.1",
|
|
61
61
|
"grafserv": "1.0.1",
|
|
62
62
|
"makage": "^0.8.0",
|
|
63
|
-
"pgsql-test": "^5.20.
|
|
63
|
+
"pgsql-test": "^5.20.12",
|
|
64
64
|
"postgraphile": "5.1.4"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "e15394db7b2bff2c7c0f4d45af6e223ea6719081"
|
|
67
67
|
}
|
package/subscribe.js
CHANGED
|
@@ -16,13 +16,16 @@ const graphql_1 = require("graphql");
|
|
|
16
16
|
*/
|
|
17
17
|
async function subscribe(opts) {
|
|
18
18
|
const document = typeof opts.query === 'string' ? (0, graphql_1.parse)(opts.query) : opts.query;
|
|
19
|
-
const
|
|
19
|
+
const args = {
|
|
20
20
|
schema: opts.schema,
|
|
21
21
|
document,
|
|
22
22
|
variableValues: opts.variables ?? undefined,
|
|
23
|
-
contextValue:
|
|
23
|
+
contextValue: {},
|
|
24
24
|
resolvedPreset: opts.resolvedPreset,
|
|
25
|
-
}
|
|
25
|
+
};
|
|
26
|
+
await (0, grafast_1.hookArgs)(args);
|
|
27
|
+
Object.assign(args.contextValue, opts.contextValue);
|
|
28
|
+
const result = await (0, grafast_1.subscribe)(args);
|
|
26
29
|
return result;
|
|
27
30
|
}
|
|
28
31
|
/**
|
package/ws-server.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWsTestServer = createWsTestServer;
|
|
4
4
|
const node_http_1 = require("node:http");
|
|
5
|
-
const grafast_1 = require("grafast");
|
|
6
5
|
const graphql_ws_1 = require("graphql-ws");
|
|
7
6
|
const ws_1 = require("graphql-ws/use/ws");
|
|
8
7
|
const ws_2 = require("ws");
|
|
8
|
+
const subscribe_js_1 = require("./subscribe.js");
|
|
9
9
|
async function createWsTestServer(input) {
|
|
10
10
|
const { schema, resolvedPreset, pgSubscriber, pgSubscriberKey = 'pgSubscriber', buildPgSettings, } = input;
|
|
11
11
|
const httpServer = (0, node_http_1.createServer)();
|
|
@@ -29,10 +29,10 @@ async function createWsTestServer(input) {
|
|
|
29
29
|
contextValue['pgSettings'] = pgSettings;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
const result = await (0,
|
|
32
|
+
const result = await (0, subscribe_js_1.subscribe)({
|
|
33
33
|
schema: args.schema,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
query: args.document,
|
|
35
|
+
variables: args.variableValues,
|
|
36
36
|
contextValue,
|
|
37
37
|
resolvedPreset,
|
|
38
38
|
});
|