@lewebsimple/nuxt-graphql 0.6.9 → 0.6.11
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
|
@@ -2,7 +2,7 @@ import type { QueryName, ResultOf, VariablesOf } from "#graphql/registry";
|
|
|
2
2
|
import { type ComputedRef, type MaybeRef, type Ref } from "#imports";
|
|
3
3
|
type PageInfoFragment = {
|
|
4
4
|
hasNextPage: boolean;
|
|
5
|
-
endCursor: string |
|
|
5
|
+
endCursor: string | undefined;
|
|
6
6
|
};
|
|
7
7
|
type Connection<TItem> = {
|
|
8
8
|
nodes: TItem[];
|
|
@@ -7,7 +7,11 @@ type GraphQLExecutionRequest = ExecutionRequest<GraphQLVariables, GraphQLContext
|
|
|
7
7
|
headers?: HeadersInput;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
type GraphQLExecutionResult<TData = unknown> = ExecutionResult<TData
|
|
10
|
+
type GraphQLExecutionResult<TData = unknown> = ExecutionResult<TData> & {
|
|
11
|
+
extensions?: {
|
|
12
|
+
headers?: HeadersInput;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
11
15
|
export type GraphQLRemoteExecHooks<TData = unknown> = {
|
|
12
16
|
onRequest?: (request: GraphQLExecutionRequest) => void | Promise<void>;
|
|
13
17
|
onResult?: (result: GraphQLExecutionResult<TData>) => void | Promise<void>;
|
|
@@ -18,6 +18,14 @@ export function getRemoteExecutor({ endpoint, headers, hooks }) {
|
|
|
18
18
|
throw new Error(`GraphQL HTTP ${response.status}`);
|
|
19
19
|
}
|
|
20
20
|
const result = await response.json();
|
|
21
|
+
const responseHeaders = {};
|
|
22
|
+
response.headers.forEach((value, key) => {
|
|
23
|
+
responseHeaders[key] = value;
|
|
24
|
+
});
|
|
25
|
+
result.extensions = {
|
|
26
|
+
...result.extensions && typeof result.extensions === "object" ? result.extensions : {},
|
|
27
|
+
headers: responseHeaders
|
|
28
|
+
};
|
|
21
29
|
for (const hook of hooks) {
|
|
22
30
|
await hook.onResult?.(result);
|
|
23
31
|
}
|