@vladimirdev635/gql-client 0.0.13
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/dist/execute.d.ts +9 -0
- package/dist/execute.js +21 -0
- package/dist/graphql.d.ts +6256 -0
- package/dist/graphql.js +2696 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/parser.d.ts +2 -0
- package/dist/parser.js +7 -0
- package/dist/serializers/index.d.ts +3 -0
- package/dist/serializers/index.js +3 -0
- package/dist/serializers/json.d.ts +2 -0
- package/dist/serializers/json.js +20 -0
- package/dist/serializers/multipart.d.ts +2 -0
- package/dist/serializers/multipart.js +67 -0
- package/dist/serializers/serializer.d.ts +3 -0
- package/dist/serializers/serializer.js +27 -0
- package/dist/serializers/tests/json.spec.d.ts +1 -0
- package/dist/serializers/tests/json.spec.js +42 -0
- package/dist/serializers/tests/multipart.spec.d.ts +1 -0
- package/dist/serializers/tests/multipart.spec.js +50 -0
- package/dist/types.d.ts +32 -0
- package/dist/types.js +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { ClientConfig, Operation } from './types.js';
|
|
3
|
+
export interface ExecuteResult<T extends Operation> {
|
|
4
|
+
result: z.infer<T['resultSchema']>;
|
|
5
|
+
response: Response;
|
|
6
|
+
}
|
|
7
|
+
export declare function execute<TContext, T extends Operation>(config: ClientConfig<TContext>, operation: T, variables: z.infer<T['variablesSchema']>): Promise<ExecuteResult<T>>;
|
|
8
|
+
export type Executor = <T extends Operation>(operation: T, variables: z.infer<T['variablesSchema']>) => Promise<ExecuteResult<T>>;
|
|
9
|
+
export declare function bindConfigToExecute<TContext>(config: ClientConfig<TContext>): Executor;
|
package/dist/execute.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export async function execute(config, operation, variables) {
|
|
2
|
+
for (const middleware of config.middlewares.beforeSerialization) {
|
|
3
|
+
[operation, variables] = await middleware(config.context, operation, variables);
|
|
4
|
+
}
|
|
5
|
+
let init = await config.serializer.serializeRequest(config.context, operation, variables);
|
|
6
|
+
for (const middleware of config.middlewares.afterSerialization) {
|
|
7
|
+
init = await middleware(config.context, operation, variables, init);
|
|
8
|
+
}
|
|
9
|
+
let response = await config.fetcher(init);
|
|
10
|
+
for (const middleware of config.middlewares.beforeParsing) {
|
|
11
|
+
response = await middleware(config.context, operation, variables, init, response);
|
|
12
|
+
}
|
|
13
|
+
let result = await config.parser.parseBody(config.context, operation, response);
|
|
14
|
+
for (const middleware of config.middlewares.afterParsing) {
|
|
15
|
+
result = await middleware(config.context, operation, variables, init, response, result);
|
|
16
|
+
}
|
|
17
|
+
return { result, response };
|
|
18
|
+
}
|
|
19
|
+
export function bindConfigToExecute(config) {
|
|
20
|
+
return (operation, variables) => execute(config, operation, variables);
|
|
21
|
+
}
|