@constructive-io/graphql-test 2.15.2 → 2.16.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/adapter.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * GraphQL Test Adapter
3
+ *
4
+ * Provides a GraphQLAdapter implementation for use with graphile-test,
5
+ * allowing the generated ORM client to work with the test infrastructure
6
+ * without needing an HTTP server.
7
+ */
8
+ import type { GraphQLQueryFn } from 'graphile-test';
9
+ import type { GraphQLAdapter, QueryResult } from '@constructive-io/graphql-types';
10
+ /**
11
+ * GraphQL adapter that wraps the graphile-test query function.
12
+ * This implements the GraphQLAdapter interface, allowing the SDK
13
+ * to work with the graphile-test infrastructure without an HTTP server.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { getConnections } from '@constructive-io/graphql-test';
18
+ * import { GraphQLTestAdapter } from '@constructive-io/graphql-test';
19
+ * import { createClient } from '@my-org/my-sdk';
20
+ *
21
+ * const db = getConnections({ ... });
22
+ * const { query } = db;
23
+ *
24
+ * const sdk = createClient({ adapter: new GraphQLTestAdapter(query) });
25
+ * const result = await sdk.user.findMany({ select: { id: true } }).execute();
26
+ * ```
27
+ */
28
+ export declare class GraphQLTestAdapter implements GraphQLAdapter {
29
+ private queryFn;
30
+ constructor(queryFn: GraphQLQueryFn);
31
+ execute<T>(document: string, variables?: Record<string, unknown>): Promise<QueryResult<T>>;
32
+ }
package/adapter.js ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * GraphQL Test Adapter
4
+ *
5
+ * Provides a GraphQLAdapter implementation for use with graphile-test,
6
+ * allowing the generated ORM client to work with the test infrastructure
7
+ * without needing an HTTP server.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.GraphQLTestAdapter = void 0;
11
+ /**
12
+ * GraphQL adapter that wraps the graphile-test query function.
13
+ * This implements the GraphQLAdapter interface, allowing the SDK
14
+ * to work with the graphile-test infrastructure without an HTTP server.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { getConnections } from '@constructive-io/graphql-test';
19
+ * import { GraphQLTestAdapter } from '@constructive-io/graphql-test';
20
+ * import { createClient } from '@my-org/my-sdk';
21
+ *
22
+ * const db = getConnections({ ... });
23
+ * const { query } = db;
24
+ *
25
+ * const sdk = createClient({ adapter: new GraphQLTestAdapter(query) });
26
+ * const result = await sdk.user.findMany({ select: { id: true } }).execute();
27
+ * ```
28
+ */
29
+ class GraphQLTestAdapter {
30
+ queryFn;
31
+ constructor(queryFn) {
32
+ this.queryFn = queryFn;
33
+ }
34
+ async execute(document, variables) {
35
+ const result = await this.queryFn(document, variables);
36
+ if (result.errors && result.errors.length > 0) {
37
+ return {
38
+ ok: false,
39
+ data: null,
40
+ errors: result.errors,
41
+ };
42
+ }
43
+ return {
44
+ ok: true,
45
+ data: result.data,
46
+ errors: undefined,
47
+ };
48
+ }
49
+ }
50
+ exports.GraphQLTestAdapter = GraphQLTestAdapter;
package/esm/adapter.js ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * GraphQL Test Adapter
3
+ *
4
+ * Provides a GraphQLAdapter implementation for use with graphile-test,
5
+ * allowing the generated ORM client to work with the test infrastructure
6
+ * without needing an HTTP server.
7
+ */
8
+ /**
9
+ * GraphQL adapter that wraps the graphile-test query function.
10
+ * This implements the GraphQLAdapter interface, allowing the SDK
11
+ * to work with the graphile-test infrastructure without an HTTP server.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { getConnections } from '@constructive-io/graphql-test';
16
+ * import { GraphQLTestAdapter } from '@constructive-io/graphql-test';
17
+ * import { createClient } from '@my-org/my-sdk';
18
+ *
19
+ * const db = getConnections({ ... });
20
+ * const { query } = db;
21
+ *
22
+ * const sdk = createClient({ adapter: new GraphQLTestAdapter(query) });
23
+ * const result = await sdk.user.findMany({ select: { id: true } }).execute();
24
+ * ```
25
+ */
26
+ export class GraphQLTestAdapter {
27
+ queryFn;
28
+ constructor(queryFn) {
29
+ this.queryFn = queryFn;
30
+ }
31
+ async execute(document, variables) {
32
+ const result = await this.queryFn(document, variables);
33
+ if (result.errors && result.errors.length > 0) {
34
+ return {
35
+ ok: false,
36
+ data: null,
37
+ errors: result.errors,
38
+ };
39
+ }
40
+ return {
41
+ ok: true,
42
+ data: result.data,
43
+ errors: undefined,
44
+ };
45
+ }
46
+ }
package/esm/index.js CHANGED
@@ -2,3 +2,5 @@
2
2
  export { GraphQLTest } from './graphile-test';
3
3
  export * from './get-connections';
4
4
  export { seed, snapshot } from 'pgsql-test';
5
+ // Export GraphQL test adapter for SDK integration
6
+ export { GraphQLTestAdapter } from './adapter';
package/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export { type GraphQLQueryOptions, type GraphQLTestContext, type GetConnectionsI
2
2
  export { GraphQLTest } from './graphile-test';
3
3
  export * from './get-connections';
4
4
  export { seed, snapshot } from 'pgsql-test';
5
+ export { GraphQLTestAdapter } from './adapter';
package/index.js CHANGED
@@ -14,7 +14,7 @@ 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.snapshot = exports.seed = exports.GraphQLTest = void 0;
17
+ exports.GraphQLTestAdapter = exports.snapshot = exports.seed = exports.GraphQLTest = void 0;
18
18
  // Override with our custom implementations that use graphile-settings
19
19
  var graphile_test_1 = require("./graphile-test");
20
20
  Object.defineProperty(exports, "GraphQLTest", { enumerable: true, get: function () { return graphile_test_1.GraphQLTest; } });
@@ -22,3 +22,6 @@ __exportStar(require("./get-connections"), exports);
22
22
  var pgsql_test_1 = require("pgsql-test");
23
23
  Object.defineProperty(exports, "seed", { enumerable: true, get: function () { return pgsql_test_1.seed; } });
24
24
  Object.defineProperty(exports, "snapshot", { enumerable: true, get: function () { return pgsql_test_1.snapshot; } });
25
+ // Export GraphQL test adapter for SDK integration
26
+ var adapter_1 = require("./adapter");
27
+ Object.defineProperty(exports, "GraphQLTestAdapter", { enumerable: true, get: function () { return adapter_1.GraphQLTestAdapter; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-test",
3
- "version": "2.15.2",
3
+ "version": "2.16.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "Constructive GraphQL Testing with all plugins loaded",
6
6
  "main": "index.js",
@@ -34,11 +34,11 @@
34
34
  "makage": "^0.1.10"
35
35
  },
36
36
  "dependencies": {
37
- "@constructive-io/graphql-env": "^2.9.2",
38
- "@constructive-io/graphql-types": "^2.13.0",
37
+ "@constructive-io/graphql-env": "^2.9.3",
38
+ "@constructive-io/graphql-types": "^2.14.0",
39
39
  "@pgpmjs/types": "^2.15.0",
40
- "graphile-settings": "^2.14.2",
41
- "graphile-test": "^2.15.2",
40
+ "graphile-settings": "^2.14.3",
41
+ "graphile-test": "^2.15.3",
42
42
  "graphql": "15.10.1",
43
43
  "mock-req": "^0.2.0",
44
44
  "pg": "^8.17.1",
@@ -52,5 +52,5 @@
52
52
  "constructive",
53
53
  "test"
54
54
  ],
55
- "gitHead": "eb66bc6e0ee3f0bcfcfeda2b5885b05c153de517"
55
+ "gitHead": "0f129a3a6f3e939d2c8c0597a9f3a689442b3dcc"
56
56
  }