@constructive-io/graphql-types 2.12.13 → 2.14.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,69 @@
1
+ /**
2
+ * GraphQL Adapter Types
3
+ *
4
+ * These types define the interface for GraphQL execution adapters,
5
+ * allowing different execution strategies (HTTP fetch, direct query, etc.)
6
+ * to be used with the generated ORM client.
7
+ */
8
+ /**
9
+ * GraphQL error structure
10
+ */
11
+ export interface GraphQLError {
12
+ message: string;
13
+ locations?: Array<{
14
+ line: number;
15
+ column: number;
16
+ }>;
17
+ path?: Array<string | number>;
18
+ extensions?: Record<string, unknown>;
19
+ }
20
+ /**
21
+ * Discriminated union result type for GraphQL operations.
22
+ * Either succeeds with data or fails with errors.
23
+ */
24
+ export type QueryResult<T> = {
25
+ ok: true;
26
+ data: T;
27
+ errors: undefined;
28
+ } | {
29
+ ok: false;
30
+ data: null;
31
+ errors: GraphQLError[];
32
+ };
33
+ /**
34
+ * Interface for GraphQL execution adapters.
35
+ * Implement this interface to create custom execution strategies.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // HTTP adapter (default)
40
+ * class FetchAdapter implements GraphQLAdapter {
41
+ * async execute<T>(document: string, variables?: Record<string, unknown>): Promise<QueryResult<T>> {
42
+ * const response = await fetch(this.endpoint, { ... });
43
+ * // ...
44
+ * }
45
+ * }
46
+ *
47
+ * // Test adapter
48
+ * class TestAdapter implements GraphQLAdapter {
49
+ * async execute<T>(document: string, variables?: Record<string, unknown>): Promise<QueryResult<T>> {
50
+ * const result = await this.queryFn(document, variables);
51
+ * // ...
52
+ * }
53
+ * }
54
+ * ```
55
+ */
56
+ export interface GraphQLAdapter {
57
+ /**
58
+ * Execute a GraphQL operation
59
+ */
60
+ execute<T>(document: string, variables?: Record<string, unknown>): Promise<QueryResult<T>>;
61
+ /**
62
+ * Set headers for the adapter (optional, primarily for HTTP adapters)
63
+ */
64
+ setHeaders?(headers: Record<string, string>): void;
65
+ /**
66
+ * Get the endpoint URL (optional, primarily for HTTP adapters)
67
+ */
68
+ getEndpoint?(): string;
69
+ }
package/adapter.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * GraphQL Adapter Types
4
+ *
5
+ * These types define the interface for GraphQL execution adapters,
6
+ * allowing different execution strategies (HTTP fetch, direct query, etc.)
7
+ * to be used with the generated ORM client.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
package/esm/adapter.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * GraphQL Adapter Types
3
+ *
4
+ * These types define the interface for GraphQL execution adapters,
5
+ * allowing different execution strategies (HTTP fetch, direct query, etc.)
6
+ * to be used with the generated ORM client.
7
+ */
8
+ export {};
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from '@pgpmjs/types';
2
2
  export { GraphileOptions, GraphileFeatureOptions, ApiOptions, graphileDefaults, graphileFeatureDefaults, apiDefaults } from './graphile';
3
3
  export { ConstructiveGraphQLOptions, ConstructiveOptions, constructiveGraphqlDefaults, constructiveDefaults } from './constructive';
4
+ export { GraphQLAdapter, GraphQLError, QueryResult } from './adapter';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-types",
3
- "version": "2.12.13",
3
+ "version": "2.14.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "Constructive GraphQL/Graphile types for PostGraphile integration",
6
6
  "main": "index.js",
@@ -29,10 +29,10 @@
29
29
  "test:watch": "jest --watch"
30
30
  },
31
31
  "dependencies": {
32
- "@pgpmjs/types": "^2.14.1",
32
+ "@pgpmjs/types": "^2.15.0",
33
33
  "deepmerge": "^4.3.1",
34
34
  "graphile-build": "^4.14.1",
35
- "pg-env": "^1.2.5",
35
+ "pg-env": "^1.3.0",
36
36
  "postgraphile": "^4.14.1"
37
37
  },
38
38
  "keywords": [
@@ -46,5 +46,5 @@
46
46
  "devDependencies": {
47
47
  "makage": "^0.1.10"
48
48
  },
49
- "gitHead": "049ab1b8c49c5711ede9a47c8e8dbb7bbbdf5a1f"
49
+ "gitHead": "0f129a3a6f3e939d2c8c0597a9f3a689442b3dcc"
50
50
  }