nuxt-graphql-middleware 4.0.0-beta.2 → 4.0.0-beta.3

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-graphql-middleware",
3
3
  "configKey": "graphqlMiddleware",
4
- "version": "4.0.0-beta.2",
4
+ "version": "4.0.0-beta.3",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.1.0"
7
7
  }
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.2";
23
+ const version = "4.0.0-beta.3";
24
24
 
25
25
  const DEVTOOLS_UI_ROUTE = "/__nuxt-graphql-middleware";
26
26
  const DEVTOOLS_UI_LOCAL_PORT = 3300;
@@ -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 | null;
14
+ export declare const useGraphqlState: () => GraphqlMiddlewareState;
15
15
  type QueryObjectArgs<T extends GraphqlMiddlewareQueryName, M extends GraphqlMiddlewareQuery> = M[T][0] extends null ? {
16
16
  name: T;
17
17
  fetchOptions?: FetchOptions;
@@ -4,20 +4,16 @@ 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
+ };
7
10
  export const useGraphqlState = function() {
8
- try {
9
- const app = useNuxtApp();
10
- if (app.$graphqlState) {
11
- return app.$graphqlState;
12
- }
13
- } catch (_e) {
14
- }
15
- return null;
11
+ return state;
16
12
  };
17
13
  function performRequest(operation, operationName, method, options) {
18
- const state = useGraphqlState();
14
+ const state2 = useGraphqlState();
19
15
  return $fetch(getEndpoint(operation, operationName), {
20
- ...state && state.fetchOptions ? state.fetchOptions : {},
16
+ ...state2 && state2.fetchOptions ? state2.fetchOptions : {},
21
17
  ...options,
22
18
  method
23
19
  }).then((v) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-graphql-middleware",
3
- "version": "4.0.0-beta.2",
3
+ "version": "4.0.0-beta.3",
4
4
  "description": "Module to perform GraphQL requests as a server middleware.",
5
5
  "repository": {
6
6
  "type": "git",