@lewebsimple/nuxt-graphql 0.7.5 → 0.7.6
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import zodPreset from '@lewebsimple/graphql-codegen-zod';
|
|
|
16
16
|
import { createRequire } from 'node:module';
|
|
17
17
|
import { resolveCacheConfig } from '../dist/runtime/app/lib/cache-config.js';
|
|
18
18
|
|
|
19
|
-
const version = "0.7.
|
|
19
|
+
const version = "0.7.6";
|
|
20
20
|
|
|
21
21
|
const buildCache = /* @__PURE__ */ new Map();
|
|
22
22
|
function getCachedLoader(baseKey, loader) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { GraphQLContext } from "#graphql/context";
|
|
1
2
|
/** GraphQL remote executor request. */
|
|
2
|
-
type GraphQLRemoteExecutorRequest = {
|
|
3
|
+
export type GraphQLRemoteExecutorRequest<TContext extends Record<string, unknown> = GraphQLContext> = {
|
|
3
4
|
/** GraphQL document node. */
|
|
4
5
|
document: unknown;
|
|
5
6
|
/** Operation variables. */
|
|
@@ -12,25 +13,25 @@ type GraphQLRemoteExecutorRequest = {
|
|
|
12
13
|
headers?: Record<string, string>;
|
|
13
14
|
};
|
|
14
15
|
/** Execution context. */
|
|
15
|
-
context?:
|
|
16
|
+
context?: TContext;
|
|
16
17
|
};
|
|
17
18
|
/** Remote executor hook handlers. */
|
|
18
|
-
type GraphQLRemoteExecutorHook = {
|
|
19
|
+
export type GraphQLRemoteExecutorHook<TContext extends Record<string, unknown> = GraphQLContext> = {
|
|
19
20
|
/** Called before sending remote request. */
|
|
20
|
-
onRequest?: (request: GraphQLRemoteExecutorRequest
|
|
21
|
+
onRequest?: (request: GraphQLRemoteExecutorRequest<TContext>, context: TContext | undefined) => void | Promise<void>;
|
|
21
22
|
/** Called after receiving a result. */
|
|
22
|
-
onResult?: (result: unknown, context:
|
|
23
|
+
onResult?: (result: unknown, context: TContext | undefined) => void | Promise<void>;
|
|
23
24
|
/** Called when execution throws. */
|
|
24
|
-
onError?: (error: unknown, context:
|
|
25
|
+
onError?: (error: unknown, context: TContext | undefined) => void | Promise<void>;
|
|
25
26
|
};
|
|
26
27
|
/** Remote executor factory input. */
|
|
27
|
-
type RemoteExecutorInput = {
|
|
28
|
+
type RemoteExecutorInput<TContext extends Record<string, unknown> = GraphQLContext> = {
|
|
28
29
|
/** Remote GraphQL endpoint URL. */
|
|
29
30
|
endpoint: string;
|
|
30
31
|
/** Static request headers. */
|
|
31
32
|
headers: Record<string, string>;
|
|
32
33
|
/** Hook handlers. */
|
|
33
|
-
hooks: GraphQLRemoteExecutorHook[];
|
|
34
|
+
hooks: GraphQLRemoteExecutorHook<TContext>[];
|
|
34
35
|
};
|
|
35
36
|
/**
|
|
36
37
|
* Create a remote GraphQL executor bound to an endpoint.
|
|
@@ -38,12 +39,12 @@ type RemoteExecutorInput = {
|
|
|
38
39
|
* @param input Remote executor options.
|
|
39
40
|
* @returns Async executor function.
|
|
40
41
|
*/
|
|
41
|
-
export declare function getRemoteExecutor({ endpoint, headers, hooks }: RemoteExecutorInput): (request: GraphQLRemoteExecutorRequest) => Promise<unknown>;
|
|
42
|
+
export declare function getRemoteExecutor<TContext extends Record<string, unknown> = GraphQLContext>({ endpoint, headers, hooks, }: RemoteExecutorInput<TContext>): (request: GraphQLRemoteExecutorRequest<TContext>) => Promise<unknown>;
|
|
42
43
|
/**
|
|
43
44
|
* Define remote executor hooks with proper typing.
|
|
44
45
|
*
|
|
45
46
|
* @param hooks Hooks implementation.
|
|
46
47
|
* @returns The same hooks object.
|
|
47
48
|
*/
|
|
48
|
-
export declare function defineRemoteExecutorHooks(hooks: GraphQLRemoteExecutorHook): GraphQLRemoteExecutorHook
|
|
49
|
+
export declare function defineRemoteExecutorHooks<TContext extends Record<string, unknown> = GraphQLContext>(hooks: GraphQLRemoteExecutorHook<TContext>): GraphQLRemoteExecutorHook<TContext>;
|
|
49
50
|
export {};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { print } from "graphql";
|
|
2
|
-
export function getRemoteExecutor({
|
|
2
|
+
export function getRemoteExecutor({
|
|
3
|
+
endpoint,
|
|
4
|
+
headers,
|
|
5
|
+
hooks
|
|
6
|
+
}) {
|
|
3
7
|
return async function execute(request) {
|
|
4
8
|
const context = request.context;
|
|
5
9
|
try {
|