graphile-test 2.8.6 → 2.8.8

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 CHANGED
@@ -194,6 +194,19 @@ expect(result.data.createUser.username).toBe('alice');
194
194
  * Start with `getConnections()` for most use cases.
195
195
  * Consider `getConnectionsUnwrapped()` for cleaner test assertions.
196
196
 
197
+ ## Snapshot Utilities
198
+
199
+ The `graphile-test/utils` module provides utilities for sanitizing query results for snapshot testing. These helpers replace dynamic values (IDs, UUIDs, dates, hashes) with stable placeholders, making snapshots deterministic.
200
+
201
+ ```ts
202
+ import { snapshot } from 'graphile-test/utils';
203
+
204
+ const res = await query(`query { allUsers { nodes { id name createdAt } } }`);
205
+ expect(snapshot(res.data)).toMatchSnapshot();
206
+ ```
207
+
208
+ See [`pgsql-test` Snapshot Utilities](https://www.npmjs.com/package/pgsql-test#snapshot-utilities) for the full API reference.
209
+
197
210
  ---
198
211
 
199
212
  ## Education and Tutorials
@@ -27,7 +27,8 @@ const createConnectionsBase = async (input, seedAdapters) => {
27
27
  db,
28
28
  teardown,
29
29
  baseQuery,
30
- baseQueryPositional
30
+ baseQueryPositional,
31
+ gqlContext
31
32
  };
32
33
  };
33
34
  // ============================================================================
@@ -37,12 +38,13 @@ const createConnectionsBase = async (input, seedAdapters) => {
37
38
  * Creates connections with raw GraphQL responses
38
39
  */
39
40
  export const getConnectionsObject = async (input, seedAdapters) => {
40
- const { pg, db, teardown, baseQuery } = await createConnectionsBase(input, seedAdapters);
41
+ const { pg, db, teardown, baseQuery, gqlContext } = await createConnectionsBase(input, seedAdapters);
41
42
  return {
42
43
  pg,
43
44
  db,
44
45
  teardown,
45
- query: baseQuery
46
+ query: baseQuery,
47
+ gqlContext
46
48
  };
47
49
  };
48
50
  /**
package/esm/index.js CHANGED
@@ -1,6 +1,5 @@
1
- export * from './clean';
2
1
  export * from './context';
3
2
  export * from './get-connections';
4
3
  export * from './graphile-test';
5
4
  export * from './types';
6
- export { seed } from 'pgsql-test';
5
+ export { seed, snapshot } from 'pgsql-test';
package/esm/utils.js ADDED
@@ -0,0 +1 @@
1
+ export * from 'pgsql-test/utils';
@@ -1,7 +1,7 @@
1
1
  import type { GetConnectionOpts } from 'pgsql-test';
2
2
  import type { SeedAdapter } from 'pgsql-test/seed/types';
3
3
  import type { PgTestClient } from 'pgsql-test/test-client';
4
- import type { GetConnectionsInput, GraphQLQueryFn, GraphQLQueryFnObj, GraphQLQueryUnwrappedFn, GraphQLQueryUnwrappedFnObj } from './types';
4
+ import type { GetConnectionsInput, GraphQLQueryFn, GraphQLQueryFnObj, GraphQLQueryUnwrappedFn, GraphQLQueryUnwrappedFnObj, GraphQLTestContext } from './types';
5
5
  /**
6
6
  * Creates connections with raw GraphQL responses
7
7
  */
@@ -10,6 +10,7 @@ export declare const getConnectionsObject: (input: GetConnectionsInput & GetConn
10
10
  db: PgTestClient;
11
11
  teardown: () => Promise<void>;
12
12
  query: GraphQLQueryFnObj;
13
+ gqlContext: GraphQLTestContext;
13
14
  }>;
14
15
  /**
15
16
  * Creates connections with unwrapped GraphQL responses (throws on errors)
@@ -30,7 +30,8 @@ const createConnectionsBase = async (input, seedAdapters) => {
30
30
  db,
31
31
  teardown,
32
32
  baseQuery,
33
- baseQueryPositional
33
+ baseQueryPositional,
34
+ gqlContext
34
35
  };
35
36
  };
36
37
  // ============================================================================
@@ -40,12 +41,13 @@ const createConnectionsBase = async (input, seedAdapters) => {
40
41
  * Creates connections with raw GraphQL responses
41
42
  */
42
43
  const getConnectionsObject = async (input, seedAdapters) => {
43
- const { pg, db, teardown, baseQuery } = await createConnectionsBase(input, seedAdapters);
44
+ const { pg, db, teardown, baseQuery, gqlContext } = await createConnectionsBase(input, seedAdapters);
44
45
  return {
45
46
  pg,
46
47
  db,
47
48
  teardown,
48
- query: baseQuery
49
+ query: baseQuery,
50
+ gqlContext
49
51
  };
50
52
  };
51
53
  exports.getConnectionsObject = getConnectionsObject;
package/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- export * from './clean';
2
1
  export * from './context';
3
2
  export * from './get-connections';
4
3
  export * from './graphile-test';
5
4
  export * from './types';
6
- export { seed } from 'pgsql-test';
5
+ export { seed, snapshot } from 'pgsql-test';
package/index.js CHANGED
@@ -14,11 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.seed = void 0;
18
- __exportStar(require("./clean"), exports);
17
+ exports.snapshot = exports.seed = void 0;
19
18
  __exportStar(require("./context"), exports);
20
19
  __exportStar(require("./get-connections"), exports);
21
20
  __exportStar(require("./graphile-test"), exports);
22
21
  __exportStar(require("./types"), exports);
23
22
  var pgsql_test_1 = require("pgsql-test");
24
23
  Object.defineProperty(exports, "seed", { enumerable: true, get: function () { return pgsql_test_1.seed; } });
24
+ Object.defineProperty(exports, "snapshot", { enumerable: true, get: function () { return pgsql_test_1.snapshot; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphile-test",
3
- "version": "2.8.6",
3
+ "version": "2.8.8",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
5
  "description": "PostGraphile Testing",
6
6
  "main": "index.js",
@@ -38,7 +38,7 @@
38
38
  "graphql": "15.10.1",
39
39
  "mock-req": "^0.2.0",
40
40
  "pg": "^8.16.0",
41
- "pgsql-test": "^2.14.9",
41
+ "pgsql-test": "^2.14.11",
42
42
  "postgraphile": "^4.14.1"
43
43
  },
44
44
  "keywords": [
@@ -48,5 +48,5 @@
48
48
  "launchql",
49
49
  "test"
50
50
  ],
51
- "gitHead": "1da5f98bd18b47382b652e104cdc4db1b9ee79db"
51
+ "gitHead": "ff477433074d91c28be6017e858b601fa99aa568"
52
52
  }
package/utils.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from 'pgsql-test/utils';
package/utils.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("pgsql-test/utils"), exports);