@constructive-io/graphql-types 2.13.0 → 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 +69 -0
- package/adapter.js +9 -0
- package/esm/adapter.js +8 -0
- package/index.d.ts +1 -0
- package/package.json +2 -2
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
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.
|
|
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",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"makage": "^0.1.10"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "0f129a3a6f3e939d2c8c0597a9f3a689442b3dcc"
|
|
50
50
|
}
|