nuxt-graphql-middleware 4.0.0-beta.3 → 4.0.0-beta.4
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
|
@@ -20,7 +20,7 @@ import { oldVisit } from '@graphql-codegen/plugin-helpers';
|
|
|
20
20
|
import { pascalCase } from 'change-case-all';
|
|
21
21
|
|
|
22
22
|
const name = "nuxt-graphql-middleware";
|
|
23
|
-
const version = "4.0.0-beta.
|
|
23
|
+
const version = "4.0.0-beta.4";
|
|
24
24
|
|
|
25
25
|
const DEVTOOLS_UI_ROUTE = "/__nuxt-graphql-middleware";
|
|
26
26
|
const DEVTOOLS_UI_LOCAL_PORT = 3300;
|
|
@@ -600,7 +600,7 @@ const module = defineNuxtModule({
|
|
|
600
600
|
documents: []
|
|
601
601
|
};
|
|
602
602
|
let rpc = null;
|
|
603
|
-
if (options.devtools
|
|
603
|
+
if (options.devtools) {
|
|
604
604
|
const clientPath = moduleResolver("./client");
|
|
605
605
|
setupDevToolsUI(nuxt, clientPath);
|
|
606
606
|
const setupRpc = () => {
|
|
@@ -679,7 +679,7 @@ const module = defineNuxtModule({
|
|
|
679
679
|
});
|
|
680
680
|
}
|
|
681
681
|
};
|
|
682
|
-
generateHandler(true);
|
|
682
|
+
await generateHandler(true);
|
|
683
683
|
nuxt.options.runtimeConfig.public["nuxt-graphql-middleware"] = {
|
|
684
684
|
serverApiPrefix: options.serverApiPrefix
|
|
685
685
|
};
|
|
@@ -11,7 +11,7 @@ type GraphqlResponse<T> = {
|
|
|
11
11
|
};
|
|
12
12
|
type GetQueryResult<T extends GraphqlMiddlewareQueryName, M extends GraphqlMiddlewareQuery> = M[T] extends undefined ? undefined : GraphqlResponse<M[T][2]>;
|
|
13
13
|
type GetMutationResult<T extends GraphqlMiddlewareMutationName, M extends GraphqlMiddlewareMutation> = M[T] extends undefined ? undefined : GraphqlResponse<M[T][2]>;
|
|
14
|
-
export declare const useGraphqlState: () => GraphqlMiddlewareState;
|
|
14
|
+
export declare const useGraphqlState: () => GraphqlMiddlewareState | null;
|
|
15
15
|
type QueryObjectArgs<T extends GraphqlMiddlewareQueryName, M extends GraphqlMiddlewareQuery> = M[T][0] extends null ? {
|
|
16
16
|
name: T;
|
|
17
17
|
fetchOptions?: FetchOptions;
|
|
@@ -4,16 +4,20 @@ function getEndpoint(operation, operationName) {
|
|
|
4
4
|
const config = useRuntimeConfig();
|
|
5
5
|
return `${config?.public?.["nuxt-graphql-middleware"]?.serverApiPrefix}/${operation}/${operationName}`;
|
|
6
6
|
}
|
|
7
|
-
const state = {
|
|
8
|
-
fetchOptions: {}
|
|
9
|
-
};
|
|
10
7
|
export const useGraphqlState = function() {
|
|
11
|
-
|
|
8
|
+
try {
|
|
9
|
+
const app = useNuxtApp();
|
|
10
|
+
if (app.$graphqlState) {
|
|
11
|
+
return app.$graphqlState;
|
|
12
|
+
}
|
|
13
|
+
} catch (_e) {
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
12
16
|
};
|
|
13
17
|
function performRequest(operation, operationName, method, options) {
|
|
14
|
-
const
|
|
18
|
+
const state = useGraphqlState();
|
|
15
19
|
return $fetch(getEndpoint(operation, operationName), {
|
|
16
|
-
...
|
|
20
|
+
...state && state.fetchOptions ? state.fetchOptions : {},
|
|
17
21
|
...options,
|
|
18
22
|
method
|
|
19
23
|
}).then((v) => {
|