nuxt-graphql-middleware 5.0.0-alpha.2 → 5.0.0-alpha.20

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.
Files changed (93) hide show
  1. package/README.md +101 -19
  2. package/dist/client/200.html +10 -10
  3. package/dist/client/404.html +10 -10
  4. package/dist/client/_nuxt/BM34SYth.js +1 -0
  5. package/dist/client/_nuxt/CROlboVl.js +1 -0
  6. package/dist/client/_nuxt/D5hBL5aZ.js +25 -0
  7. package/dist/client/_nuxt/FTbv7CO6.js +1 -0
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/de61b0f7-ec5c-4f2f-addb-b5017c30afb1.json +1 -0
  10. package/dist/client/_nuxt/entry.Cn9qfNGa.css +1 -0
  11. package/dist/client/_nuxt/error-404.ehK72JOs.css +1 -0
  12. package/dist/client/_nuxt/error-500._g0akJim.css +1 -0
  13. package/dist/client/_nuxt/index.DGEN-H8t.css +1 -0
  14. package/dist/client/_nuxt/lIgCBhS_.js +2 -0
  15. package/dist/client/index.html +10 -10
  16. package/dist/client-options.d.mts +6 -0
  17. package/dist/client-options.mjs +5 -0
  18. package/dist/module.d.mts +74 -340
  19. package/dist/module.json +4 -4
  20. package/dist/module.mjs +1384 -589
  21. package/dist/runtime/components/CodeFrame.vue +52 -0
  22. package/dist/runtime/components/CodeFrame.vue.d.ts +7 -0
  23. package/dist/runtime/components/DevModeOverlay.vue +52 -0
  24. package/dist/runtime/components/DevModeOverlay.vue.d.ts +3 -0
  25. package/dist/runtime/components/ErrorExtensions.vue +21 -0
  26. package/dist/runtime/components/ErrorExtensions.vue.d.ts +5 -0
  27. package/dist/runtime/components/ErrorGroup.vue +78 -0
  28. package/dist/runtime/components/ErrorGroup.vue.d.ts +9 -0
  29. package/dist/runtime/composables/nuxtApp.d.ts +2 -2
  30. package/dist/runtime/composables/nuxtApp.js +21 -1
  31. package/dist/runtime/composables/useAsyncGraphqlQuery.d.ts +7 -7
  32. package/dist/runtime/composables/useAsyncGraphqlQuery.js +10 -2
  33. package/dist/runtime/composables/useGraphqlMutation.d.ts +4 -4
  34. package/dist/runtime/composables/useGraphqlMutation.js +1 -1
  35. package/dist/runtime/composables/useGraphqlQuery.d.ts +4 -4
  36. package/dist/runtime/composables/useGraphqlQuery.js +1 -1
  37. package/dist/runtime/composables/useGraphqlState.d.ts +1 -1
  38. package/dist/runtime/composables/useGraphqlState.js +1 -1
  39. package/dist/runtime/composables/useGraphqlUploadMutation.d.ts +4 -4
  40. package/dist/runtime/composables/useGraphqlUploadMutation.js +2 -2
  41. package/dist/runtime/css/output.css +1 -0
  42. package/dist/runtime/helpers/composables.d.ts +17 -20
  43. package/dist/runtime/helpers/composables.js +0 -5
  44. package/dist/runtime/plugins/devMode.d.ts +2 -0
  45. package/dist/runtime/plugins/devMode.js +23 -0
  46. package/dist/runtime/plugins/provideState.d.ts +1 -1
  47. package/dist/runtime/{serverHandler → server/api}/debug.js +3 -7
  48. package/dist/runtime/server/api/mutation.js +29 -0
  49. package/dist/runtime/server/api/query.js +30 -0
  50. package/dist/runtime/server/api/upload.d.ts +2 -0
  51. package/dist/runtime/{serverHandler → server/api}/upload.js +13 -11
  52. package/dist/runtime/{serverHandler → server}/helpers/index.d.ts +10 -12
  53. package/dist/runtime/{serverHandler → server}/helpers/index.js +9 -26
  54. package/dist/runtime/server/utils/doGraphqlRequest.d.ts +18 -0
  55. package/dist/runtime/server/utils/doGraphqlRequest.js +68 -0
  56. package/dist/runtime/server/utils/index.d.ts +1 -1
  57. package/dist/runtime/server/utils/index.js +1 -1
  58. package/dist/runtime/server/utils/useGraphqlMutation.d.ts +4 -4
  59. package/dist/runtime/server/utils/useGraphqlQuery.d.ts +4 -4
  60. package/dist/runtime/settings/index.d.ts +0 -14
  61. package/dist/runtime/settings/index.js +0 -6
  62. package/dist/runtime/types.d.ts +204 -3
  63. package/dist/server-options.d.mts +8 -0
  64. package/dist/server-options.mjs +5 -0
  65. package/dist/shared/nuxt-graphql-middleware.xfMm4rGk.d.mts +523 -0
  66. package/dist/types.d.mts +1 -7
  67. package/dist/utils.d.mts +15 -0
  68. package/dist/utils.mjs +18 -0
  69. package/package.json +64 -57
  70. package/dist/client/_nuxt/BS583yk8.js +0 -25
  71. package/dist/client/_nuxt/CZ2Qwgdk.js +0 -2
  72. package/dist/client/_nuxt/DpxjPVZy.js +0 -1
  73. package/dist/client/_nuxt/GOrnHr4p.js +0 -1
  74. package/dist/client/_nuxt/builds/meta/f823ebfd-daab-468f-8f6f-07a236da64bd.json +0 -1
  75. package/dist/client/_nuxt/entry.AjgXSF89.css +0 -1
  76. package/dist/client/_nuxt/error-404.BJkSn6RI.css +0 -1
  77. package/dist/client/_nuxt/error-500.TOCKLquH.css +0 -1
  78. package/dist/client/_nuxt/exxdaCPN.js +0 -1
  79. package/dist/client/_nuxt/index.D19Q16VT.css +0 -1
  80. package/dist/module.cjs +0 -5
  81. package/dist/module.d.ts +0 -358
  82. package/dist/runtime/clientOptions/index.d.ts +0 -2
  83. package/dist/runtime/clientOptions/index.js +0 -3
  84. package/dist/runtime/serverHandler/index.js +0 -78
  85. package/dist/runtime/serverHandler/tsconfig.json +0 -3
  86. package/dist/runtime/serverOptions/defineGraphqlServerOptions.d.ts +0 -3
  87. package/dist/runtime/serverOptions/defineGraphqlServerOptions.js +0 -3
  88. package/dist/runtime/serverOptions/index.d.ts +0 -2
  89. package/dist/runtime/serverOptions/index.js +0 -2
  90. package/dist/types.d.ts +0 -7
  91. /package/dist/runtime/{serverHandler → server/api}/debug.d.ts +0 -0
  92. /package/dist/runtime/{serverHandler/index.d.ts → server/api/mutation.d.ts} +0 -0
  93. /package/dist/runtime/{serverHandler/upload.d.ts → server/api/query.d.ts} +0 -0
@@ -0,0 +1,52 @@
1
+ <template>
2
+ <div class="nuxt-graphql-middleware-errors-code">
3
+ <div>
4
+ <div
5
+ v-for="(l, i) in lines"
6
+ :key="'lineNumber' + i"
7
+ class="nuxt-graphql-middleware-errors-code-line-number"
8
+ :class="{ 'ngm-is-highlighted': l.isHighlighted }"
9
+ >
10
+ <div v-html="l.lineNumber" />
11
+ </div>
12
+ </div>
13
+ <div>
14
+ <div
15
+ v-for="(l, i) in lines"
16
+ :key="'code' + i"
17
+ class="nuxt-graphql-middleware-errors-code-code"
18
+ :class="{ 'ngm-is-highlighted': l.isHighlighted }"
19
+ >
20
+ <div v-html="l.code" />
21
+ </div>
22
+ </div>
23
+ </div>
24
+ </template>
25
+
26
+ <script setup>
27
+ import { computed } from "#imports";
28
+ const props = defineProps({
29
+ source: { type: String, required: true },
30
+ line: { type: Number, required: true },
31
+ column: { type: Number, required: true }
32
+ });
33
+ const before = 20;
34
+ const after = 20;
35
+ const lines = computed(() => {
36
+ const fullLines = props.source.split("\n");
37
+ const indexStart = Math.max(props.line - before - 1, 0);
38
+ const indexEnd = Math.min(props.line + after, fullLines.length);
39
+ const sliced = fullLines.slice(indexStart, indexEnd);
40
+ while (sliced.length && !sliced[sliced.length - 1]?.trim()) {
41
+ sliced.pop();
42
+ }
43
+ return sliced.map((code, i) => {
44
+ const lineNumber = indexStart + i + 1;
45
+ return {
46
+ lineNumber,
47
+ code,
48
+ isHighlighted: lineNumber === props.line
49
+ };
50
+ });
51
+ });
52
+ </script>
@@ -0,0 +1,7 @@
1
+ type __VLS_Props = {
2
+ source: string;
3
+ line: number;
4
+ column: number;
5
+ };
6
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ export default _default;
@@ -0,0 +1,52 @@
1
+ <template>
2
+ <div v-if="groups.length" id="nuxt-graphql-middleware">
3
+ <div id="nuxt-graphql-middleware-errors">
4
+ <div
5
+ id="nuxt-graphql-middleware-errors-background"
6
+ @click="clearErrors"
7
+ />
8
+ <div id="nuxt-graphql-middleware-errors-content">
9
+ <header>
10
+ <h1>nuxt-graphql-middleware</h1>
11
+ <button @click="clearErrors">Close</button>
12
+ </header>
13
+
14
+ <ErrorGroup
15
+ v-for="group in groups"
16
+ v-bind="group"
17
+ :key="group.operation + group.operationName"
18
+ />
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </template>
23
+
24
+ <script setup>
25
+ import "./../css/output.css";
26
+ import { useState, computed } from "#imports";
27
+ import ErrorGroup from "./ErrorGroup.vue";
28
+ const errors = useState(
29
+ "nuxt-graphql-middleware-errors",
30
+ () => []
31
+ );
32
+ const groups = computed(() => {
33
+ return [
34
+ ...errors.value.reduce((acc, v) => {
35
+ const key = `${v.operation}_${v.operationName}`;
36
+ if (!acc.has(key)) {
37
+ acc.set(key, {
38
+ operation: v.operation,
39
+ operationName: v.operationName,
40
+ errors: [],
41
+ stack: v.stack
42
+ });
43
+ }
44
+ acc.get(key).errors.push(...v.errors);
45
+ return acc;
46
+ }, /* @__PURE__ */ new Map()).values()
47
+ ];
48
+ });
49
+ function clearErrors() {
50
+ errors.value = [];
51
+ }
52
+ </script>
@@ -0,0 +1,3 @@
1
+ import './../css/output.css.js';
2
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
3
+ export default _default;
@@ -0,0 +1,21 @@
1
+ <template>
2
+ <tr v-for="item in mapped" :key="item.key">
3
+ <td>{{ item.key }}</td>
4
+ <td>{{ item.value }}</td>
5
+ </tr>
6
+ </template>
7
+
8
+ <script setup>
9
+ import { computed } from "#imports";
10
+ const props = defineProps({
11
+ extensions: { type: Object, required: false }
12
+ });
13
+ const mapped = computed(() => {
14
+ if (!props.extensions) {
15
+ return [];
16
+ }
17
+ return Object.entries(props.extensions).map(([key, value]) => {
18
+ return { key, value };
19
+ });
20
+ });
21
+ </script>
@@ -0,0 +1,5 @@
1
+ type __VLS_Props = {
2
+ extensions?: Record<string, unknown>;
3
+ };
4
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ export default _default;
@@ -0,0 +1,78 @@
1
+ <template>
2
+ <table class="nuxt-graphql-middleware-error-group">
3
+ <tbody>
4
+ <tr>
5
+ <td>Operation</td>
6
+ <td>{{ operation }}</td>
7
+ </tr>
8
+
9
+ <tr></tr>
10
+ <tr>
11
+ <td>Name</td>
12
+ <td>{{ operationName }}</td>
13
+ </tr>
14
+
15
+ <tr>
16
+ <td>File</td>
17
+ <td>{{ filePath }}</td>
18
+ </tr>
19
+ <tr v-if="stack">
20
+ <td>Stack</td>
21
+ <td v-text="stack" />
22
+ </tr>
23
+ <template v-for="error in uniqueErrors" :key="error.key">
24
+ <tr>
25
+ <td>Path</td>
26
+ <td>{{ error.path.join(' - ') }}</td>
27
+ </tr>
28
+ <tr>
29
+ <td colspan="2" class="ngm-large">{{ error.message }}</td>
30
+ </tr>
31
+
32
+ <template v-if="source">
33
+ <tr
34
+ v-for="(location, i) in error.locations"
35
+ :key="error.key + 'code' + i"
36
+ >
37
+ <td colspan="2">
38
+ <CodeFrame v-bind="location" :source />
39
+ </td>
40
+ </tr>
41
+ </template>
42
+
43
+ <ErrorExtensions :extensions="error.extensions" />
44
+ </template>
45
+ </tbody>
46
+ </table>
47
+ </template>
48
+
49
+ <script setup>
50
+ import { documents } from "#nuxt-graphql-middleware/documents";
51
+ import { operationSources } from "#nuxt-graphql-middleware/sources";
52
+ import { computed } from "#imports";
53
+ import CodeFrame from "./CodeFrame.vue";
54
+ import ErrorExtensions from "./ErrorExtensions.vue";
55
+ const props = defineProps({
56
+ operation: { type: String, required: true },
57
+ operationName: { type: String, required: true },
58
+ errors: { type: Array, required: true },
59
+ stack: { type: String, required: false }
60
+ });
61
+ const key = computed(() => props.operation + "_" + props.operationName);
62
+ const filePath = computed(() => {
63
+ return operationSources[key.value];
64
+ });
65
+ const source = computed(
66
+ () => documents[props.operation]?.[props.operationName]
67
+ );
68
+ const uniqueErrors = computed(() => {
69
+ return props.errors.reduce((acc, v) => {
70
+ const key2 = v.message;
71
+ if (!acc.has(key2)) {
72
+ acc.set(key2, { ...v, key: key2, count: 0 });
73
+ }
74
+ acc.get(key2).count++;
75
+ return acc;
76
+ }, /* @__PURE__ */ new Map()).values().toArray();
77
+ });
78
+ </script>
@@ -0,0 +1,9 @@
1
+ import type { GraphqlResponseError } from '../types.js';
2
+ type __VLS_Props = {
3
+ operation: string;
4
+ operationName: string;
5
+ errors: GraphqlResponseError[];
6
+ stack?: string;
7
+ };
8
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ export default _default;
@@ -1,7 +1,7 @@
1
1
  import type { FetchOptions } from 'ofetch';
2
2
  import { GraphqlMiddlewareCache } from '../helpers/ClientCache.js';
3
- import type { GraphqlResponse } from '#graphql-middleware-server-options-build';
4
- import type { RequestCacheOptions } from '#graphql-middleware/types';
3
+ import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
4
+ import type { RequestCacheOptions } from './../types.js';
5
5
  export declare function performRequest<T>(operation: string, operationName: string, method: 'get' | 'post', options: FetchOptions, cacheOptions?: RequestCacheOptions): Promise<GraphqlResponse<T>>;
6
6
  declare module '#app' {
7
7
  interface NuxtApp {
@@ -1,7 +1,7 @@
1
1
  import { useGraphqlState } from "./useGraphqlState.js";
2
- import { getEndpoint } from "./../helpers/composables.js";
3
2
  import { hash } from "ohash";
4
3
  import { GraphqlMiddlewareCache } from "../helpers/ClientCache.js";
4
+ import { getEndpoint } from "#nuxt-graphql-middleware/helpers";
5
5
  import { useNuxtApp, useAppConfig } from "#imports";
6
6
  export function performRequest(operation, operationName, method, options, cacheOptions) {
7
7
  const state = useGraphqlState();
@@ -22,6 +22,18 @@ export function performRequest(operation, operationName, method, options, cacheO
22
22
  }
23
23
  const cached = app.$graphqlCache.get(key);
24
24
  if (cached) {
25
+ if (import.meta.dev) {
26
+ cached.then((response) => {
27
+ if (response.errors.length) {
28
+ app.callHook("nuxt-graphql-middleware:errors", {
29
+ operation,
30
+ operationName,
31
+ errors: response.errors,
32
+ stack: Error().stack
33
+ });
34
+ }
35
+ });
36
+ }
25
37
  return cached;
26
38
  }
27
39
  }
@@ -34,6 +46,14 @@ export function performRequest(operation, operationName, method, options, cacheO
34
46
  method
35
47
  }
36
48
  ).then((v) => {
49
+ if (import.meta.dev && v.errors?.length) {
50
+ app.callHook("nuxt-graphql-middleware:errors", {
51
+ operation,
52
+ operationName,
53
+ errors: v.errors,
54
+ stack: Error().stack
55
+ });
56
+ }
37
57
  return {
38
58
  ...v,
39
59
  data: v.data,
@@ -1,12 +1,12 @@
1
- import { type GraphqlMiddlewareQueryName, type KeysOf, type PickFrom } from './../helpers/composables.js';
1
+ import { type KeysOf, type PickFrom } from './../helpers/composables.js';
2
2
  import type { FetchOptions } from 'ofetch';
3
3
  import { type Ref } from 'vue';
4
- import { type GraphqlClientContext } from '#graphql-middleware-client-options';
5
- import type { GraphqlMiddlewareQuery } from '#nuxt-graphql-middleware/generated-types';
6
- import type { GraphqlResponse } from '#graphql-middleware-server-options-build';
7
- import type { RequestCacheOptions } from '#graphql-middleware/types';
4
+ import { type GraphqlClientContext } from '#nuxt-graphql-middleware/client-options';
5
+ import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
6
+ import type { RequestCacheOptions } from './../types.js';
8
7
  import type { AsyncData, AsyncDataOptions, NuxtError } from '#app';
9
8
  import type { DefaultAsyncDataValue } from 'nuxt/app/defaults';
9
+ import type { Query } from '#nuxt-graphql-middleware/operation-types';
10
10
  type AsyncGraphqlQueryOptions<FetchOptions, ResT, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DefaultAsyncDataValue> = AsyncDataOptions<ResT, DataT, PickKeys, DefaultT> & {
11
11
  /**
12
12
  * Control how the GraphQL response can be cached.
@@ -23,14 +23,14 @@ type AsyncGraphqlQueryOptions<FetchOptions, ResT, DataT = ResT, PickKeys extends
23
23
  */
24
24
  clientContext?: Partial<GraphqlClientContext>;
25
25
  };
26
- export declare function useAsyncGraphqlQuery<Name extends GraphqlMiddlewareQueryName, VarType extends GraphqlMiddlewareQuery[Name][0], VarsOptional extends GraphqlMiddlewareQuery[Name][1], ResT extends GraphqlResponse<GraphqlMiddlewareQuery[Name][2]>, FetchO extends FetchOptions<'json'>, NuxtErrorDataT = unknown, DataT = ResT, DefaultT = undefined, PickKeys extends KeysOf<DataT> = KeysOf<DataT>>(name: Name, ...args: VarsOptional extends true ? [
26
+ export declare function useAsyncGraphqlQuery<Name extends keyof Query, Operation extends Query[Name] = Query[Name], ResT extends GraphqlResponse<Operation['response']> = GraphqlResponse<Operation['response']>, FetchO extends FetchOptions<'json'> = FetchOptions<'json'>, VarType extends Operation['variables'] = Operation['variables'], NuxtErrorDataT = unknown, DataT = ResT, DefaultT = undefined, PickKeys extends KeysOf<DataT> = KeysOf<DataT>>(name: Name, ...args: Operation['needsVariables'] extends false ? [
27
27
  (undefined | null | Record<string, never> | VarType | Ref<VarType>)?,
28
28
  AsyncGraphqlQueryOptions<FetchO, ResT, DataT, PickKeys, DefaultT>?
29
29
  ] : [
30
30
  VarType | Ref<VarType>,
31
31
  (undefined | null | AsyncGraphqlQueryOptions<FetchO, ResT, DataT, PickKeys, DefaultT>)?
32
32
  ]): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
33
- export declare function useAsyncGraphqlQuery<Name extends GraphqlMiddlewareQueryName, VarType extends GraphqlMiddlewareQuery[Name][0], VarsOptional extends GraphqlMiddlewareQuery[Name][1], ResT extends GraphqlResponse<GraphqlMiddlewareQuery[Name][2]>, FetchO extends FetchOptions<'json'>, NuxtErrorDataT = unknown, DataT = ResT, DefaultT = DataT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>>(name: Name, ...args: VarsOptional extends true ? [
33
+ export declare function useAsyncGraphqlQuery<Name extends keyof Query, Operation extends Query[Name] = Query[Name], ResT extends GraphqlResponse<Operation['response']> = GraphqlResponse<Operation['response']>, FetchO extends FetchOptions<'json'> = FetchOptions<'json'>, VarType extends Operation['variables'] = Operation['variables'], NuxtErrorDataT = unknown, DataT = ResT, DefaultT = DataT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>>(name: Name, ...args: Operation['needsVariables'] extends false ? [
34
34
  (undefined | null | Record<string, never> | VarType | Ref<VarType>)?,
35
35
  AsyncGraphqlQueryOptions<FetchO, ResT, DataT, PickKeys, DefaultT>?
36
36
  ] : [
@@ -6,7 +6,7 @@ import { buildRequestParams } from "./../helpers/index.js";
6
6
  import { performRequest } from "./nuxtApp.js";
7
7
  import {
8
8
  clientOptions
9
- } from "#graphql-middleware-client-options";
9
+ } from "#nuxt-graphql-middleware/client-options";
10
10
  import { useAsyncData, useAppConfig, useNuxtApp } from "#imports";
11
11
  import { hash } from "ohash";
12
12
  export function useAsyncGraphqlQuery(name, ...args) {
@@ -32,7 +32,7 @@ export function useAsyncGraphqlQuery(name, ...args) {
32
32
  };
33
33
  }
34
34
  }
35
- return useAsyncData(
35
+ const result = useAsyncData(
36
36
  key,
37
37
  () => {
38
38
  const globalClientContext = clientOptions.buildClientContext ? clientOptions.buildClientContext() : {};
@@ -56,4 +56,12 @@ export function useAsyncGraphqlQuery(name, ...args) {
56
56
  },
57
57
  asyncDataOptions
58
58
  );
59
+ if (import.meta.hot) {
60
+ import.meta.hot.on("nuxt-graphql-middleware:reload", (data) => {
61
+ if (data.operations.includes(name)) {
62
+ result.refresh();
63
+ }
64
+ });
65
+ }
66
+ return result;
59
67
  }
@@ -1,7 +1,7 @@
1
- import { type GraphqlMiddlewareMutationName, type GetMutationArgs, type MutationObjectArgs, type GetMutationResult } from './../helpers/composables.js';
2
- import type { GraphqlMiddlewareMutation } from '#nuxt-graphql-middleware/generated-types';
3
- import type { GraphqlResponse } from '#graphql-middleware-server-options-build';
1
+ import { type GetMutationArgs, type MutationObjectArgs, type GetMutationResult } from './../helpers/composables.js';
2
+ import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
3
+ import type { Mutation } from '#nuxt-graphql-middleware/operation-types';
4
4
  /**
5
5
  * Performs a GraphQL mutation.
6
6
  */
7
- export declare function useGraphqlMutation<T extends GraphqlMiddlewareMutationName, R extends GetMutationResult<T, GraphqlMiddlewareMutation>>(...args: GetMutationArgs<T, GraphqlMiddlewareMutation> | [MutationObjectArgs<T, GraphqlMiddlewareMutation>]): Promise<GraphqlResponse<R>>;
7
+ export declare function useGraphqlMutation<K extends keyof Mutation, R extends GetMutationResult<K>>(...args: GetMutationArgs<K> | [MutationObjectArgs<K>]): Promise<GraphqlResponse<R>>;
@@ -2,7 +2,7 @@ import {
2
2
  encodeContext
3
3
  } from "./../helpers/composables.js";
4
4
  import { performRequest } from "./nuxtApp.js";
5
- import { clientOptions } from "#graphql-middleware-client-options";
5
+ import { clientOptions } from "#nuxt-graphql-middleware/client-options";
6
6
  export function useGraphqlMutation(...args) {
7
7
  const [name, body, fetchOptions = {}, overrideClientContext = {}] = typeof args[0] === "string" ? [args[0], args[1], args[2]?.fetchOptions, args[2]?.clientContext] : [
8
8
  args[0].name,
@@ -1,7 +1,7 @@
1
- import { type GraphqlMiddlewareQueryName, type GetQueryArgs, type QueryObjectArgs, type GetQueryResult } from './../helpers/composables.js';
2
- import type { GraphqlMiddlewareQuery } from '#nuxt-graphql-middleware/generated-types';
3
- import type { GraphqlResponse } from '#graphql-middleware-server-options-build';
1
+ import { type GetQueryArgs, type QueryObjectArgs, type GetQueryResult } from './../helpers/composables.js';
2
+ import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
3
+ import type { Query } from '#nuxt-graphql-middleware/operation-types';
4
4
  /**
5
5
  * Performs a GraphQL query.
6
6
  */
7
- export declare function useGraphqlQuery<T extends GraphqlMiddlewareQueryName, R extends GetQueryResult<T, GraphqlMiddlewareQuery>>(...args: GetQueryArgs<T, GraphqlMiddlewareQuery> | [QueryObjectArgs<T, GraphqlMiddlewareQuery>]): Promise<GraphqlResponse<R>>;
7
+ export declare function useGraphqlQuery<K extends keyof Query, R extends GetQueryResult<K>>(...args: GetQueryArgs<K> | [QueryObjectArgs<K>]): Promise<GraphqlResponse<R>>;
@@ -3,7 +3,7 @@ import {
3
3
  } from "./../helpers/composables.js";
4
4
  import { buildRequestParams } from "./../helpers/index.js";
5
5
  import { performRequest } from "./nuxtApp.js";
6
- import { clientOptions } from "#graphql-middleware-client-options";
6
+ import { clientOptions } from "#nuxt-graphql-middleware/client-options";
7
7
  export function useGraphqlQuery(...args) {
8
8
  const [
9
9
  name,
@@ -1,3 +1,3 @@
1
1
  import type { NuxtApp } from '#app';
2
- import type { GraphqlMiddlewareState } from '#graphql-middleware/types';
2
+ import type { GraphqlMiddlewareState } from './../types.js';
3
3
  export declare const useGraphqlState: (providedApp?: NuxtApp) => GraphqlMiddlewareState | null;
@@ -5,7 +5,7 @@ export const useGraphqlState = function(providedApp) {
5
5
  if (app.$graphqlState) {
6
6
  return app.$graphqlState;
7
7
  }
8
- } catch (_e) {
8
+ } catch {
9
9
  }
10
10
  return null;
11
11
  };
@@ -1,7 +1,7 @@
1
- import { type GraphqlMiddlewareMutationName, type GetMutationArgs, type MutationObjectArgs, type GetMutationResult } from './../helpers/composables.js';
2
- import type { GraphqlMiddlewareMutation } from '#nuxt-graphql-middleware/generated-types';
3
- import type { GraphqlResponse } from '#graphql-middleware-server-options-build';
1
+ import { type GetMutationArgs, type MutationObjectArgs, type GetMutationResult } from './../helpers/composables.js';
2
+ import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
3
+ import type { Mutation } from '#nuxt-graphql-middleware/operation-types';
4
4
  /**
5
5
  * Performs a GraphQL upload mutation.
6
6
  */
7
- export declare function useGraphqlUploadMutation<T extends GraphqlMiddlewareMutationName, R extends GetMutationResult<T, GraphqlMiddlewareMutation>>(...args: GetMutationArgs<T, GraphqlMiddlewareMutation> | [MutationObjectArgs<T, GraphqlMiddlewareMutation>]): Promise<GraphqlResponse<R>>;
7
+ export declare function useGraphqlUploadMutation<K extends keyof Mutation, R extends GetMutationResult<K>>(...args: GetMutationArgs<K> | [MutationObjectArgs<K>]): Promise<GraphqlResponse<R>>;
@@ -1,9 +1,9 @@
1
1
  import {
2
- getEndpoint,
3
2
  encodeContext
4
3
  } from "./../helpers/composables.js";
5
- import { clientOptions } from "#graphql-middleware-client-options";
4
+ import { clientOptions } from "#nuxt-graphql-middleware/client-options";
6
5
  import { useGraphqlState } from "#imports";
6
+ import { getEndpoint } from "#nuxt-graphql-middleware/helpers";
7
7
  function createFormData(variables) {
8
8
  const formData = new FormData();
9
9
  formData.append("operations", "{}");
@@ -0,0 +1 @@
1
+ :root{--ngm-tw-border-spacing-x:0;--ngm-tw-border-spacing-y:0;--ngm-tw-translate-x:0;--ngm-tw-translate-y:0;--ngm-tw-rotate:0;--ngm-tw-skew-x:0;--ngm-tw-skew-y:0;--ngm-tw-scale-x:1;--ngm-tw-scale-y:1;--ngm-tw-pan-x: ;--ngm-tw-pan-y: ;--ngm-tw-pinch-zoom: ;--ngm-tw-scroll-snap-strictness:proximity;--ngm-tw-gradient-from-position: ;--ngm-tw-gradient-via-position: ;--ngm-tw-gradient-to-position: ;--ngm-tw-ordinal: ;--ngm-tw-slashed-zero: ;--ngm-tw-numeric-figure: ;--ngm-tw-numeric-spacing: ;--ngm-tw-numeric-fraction: ;--ngm-tw-ring-inset: ;--ngm-tw-ring-offset-width:0px;--ngm-tw-ring-offset-color:#fff;--ngm-tw-ring-color:rgba(59,130,246,.5);--ngm-tw-ring-offset-shadow:0 0 #0000;--ngm-tw-ring-shadow:0 0 #0000;--ngm-tw-shadow:0 0 #0000;--ngm-tw-shadow-colored:0 0 #0000;--ngm-tw-blur: ;--ngm-tw-brightness: ;--ngm-tw-contrast: ;--ngm-tw-grayscale: ;--ngm-tw-hue-rotate: ;--ngm-tw-invert: ;--ngm-tw-saturate: ;--ngm-tw-sepia: ;--ngm-tw-drop-shadow: ;--ngm-tw-backdrop-blur: ;--ngm-tw-backdrop-brightness: ;--ngm-tw-backdrop-contrast: ;--ngm-tw-backdrop-grayscale: ;--ngm-tw-backdrop-hue-rotate: ;--ngm-tw-backdrop-invert: ;--ngm-tw-backdrop-opacity: ;--ngm-tw-backdrop-saturate: ;--ngm-tw-backdrop-sepia: ;--ngm-tw-contain-size: ;--ngm-tw-contain-layout: ;--ngm-tw-contain-paint: ;--ngm-tw-contain-style: }::backdrop{--ngm-tw-border-spacing-x:0;--ngm-tw-border-spacing-y:0;--ngm-tw-translate-x:0;--ngm-tw-translate-y:0;--ngm-tw-rotate:0;--ngm-tw-skew-x:0;--ngm-tw-skew-y:0;--ngm-tw-scale-x:1;--ngm-tw-scale-y:1;--ngm-tw-pan-x: ;--ngm-tw-pan-y: ;--ngm-tw-pinch-zoom: ;--ngm-tw-scroll-snap-strictness:proximity;--ngm-tw-gradient-from-position: ;--ngm-tw-gradient-via-position: ;--ngm-tw-gradient-to-position: ;--ngm-tw-ordinal: ;--ngm-tw-slashed-zero: ;--ngm-tw-numeric-figure: ;--ngm-tw-numeric-spacing: ;--ngm-tw-numeric-fraction: ;--ngm-tw-ring-inset: ;--ngm-tw-ring-offset-width:0px;--ngm-tw-ring-offset-color:#fff;--ngm-tw-ring-color:rgba(59,130,246,.5);--ngm-tw-ring-offset-shadow:0 0 #0000;--ngm-tw-ring-shadow:0 0 #0000;--ngm-tw-shadow:0 0 #0000;--ngm-tw-shadow-colored:0 0 #0000;--ngm-tw-blur: ;--ngm-tw-brightness: ;--ngm-tw-contrast: ;--ngm-tw-grayscale: ;--ngm-tw-hue-rotate: ;--ngm-tw-invert: ;--ngm-tw-saturate: ;--ngm-tw-sepia: ;--ngm-tw-drop-shadow: ;--ngm-tw-backdrop-blur: ;--ngm-tw-backdrop-brightness: ;--ngm-tw-backdrop-contrast: ;--ngm-tw-backdrop-grayscale: ;--ngm-tw-backdrop-hue-rotate: ;--ngm-tw-backdrop-invert: ;--ngm-tw-backdrop-opacity: ;--ngm-tw-backdrop-saturate: ;--ngm-tw-backdrop-sepia: ;--ngm-tw-contain-size: ;--ngm-tw-contain-layout: ;--ngm-tw-contain-paint: ;--ngm-tw-contain-style: }:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *):after,:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *):before{border:0 solid #e5e7eb;box-sizing:border-box}:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *):after,:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *):before{--ngm-tw-content:""}#nuxt-graphql-middleware{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent;line-height:inherit;margin:0}hr:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){border-top-width:1px;color:inherit;height:0}abbr:where([title]):where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),h2:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),h3:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),h4:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),h5:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),h6:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){font-size:inherit;font-weight:inherit}a:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){color:inherit;text-decoration:inherit}b:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),strong:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){font-weight:bolder}code:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),kbd:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),pre:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),samp:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){font-size:80%}sub:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),sup:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){bottom:-.25em}sup:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){top:-.5em}table:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){border-collapse:collapse;border-color:inherit;text-indent:0}button:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),input:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),optgroup:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),select:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),textarea:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),select:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){text-transform:none}button:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),input:where([type=button]):where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),input:where([type=reset]):where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),input:where([type=submit]):where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){outline:auto}:-moz-ui-invalid:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){box-shadow:none}progress:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){vertical-align:baseline}:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *) ::-webkit-inner-spin-button,:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *) ::-webkit-outer-spin-button{height:auto}[type=search]:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){-webkit-appearance:textfield;outline-offset:-2px}:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *) ::-webkit-search-decoration{-webkit-appearance:none}:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *) ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){display:list-item}blockquote:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),dd:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),dl:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),figure:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),h1:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),h2:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),h3:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),h4:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),h5:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),h6:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),hr:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),p:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),pre:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){margin:0}fieldset:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){margin:0;padding:0}legend:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){padding:0}menu:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),ol:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),ul:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){list-style:none;margin:0;padding:0}dialog:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){padding:0}textarea:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){resize:vertical}:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *) input::-moz-placeholder,:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *) textarea::-moz-placeholder{color:#9ca3af;opacity:1}:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *) input::placeholder,:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *) textarea::placeholder{color:#9ca3af;opacity:1}[role=button]:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),button:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){cursor:pointer}:disabled:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){cursor:default}audio:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),canvas:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),embed:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),iframe:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),img:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),object:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),svg:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),video:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){display:block;vertical-align:middle}img:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *),video:where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])):where(#nuxt-graphql-middleware,#nuxt-graphql-middleware *){display:none}#nuxt-graphql-middleware-errors{align-items:flex-start;display:flex;height:100%;justify-content:center;left:0;padding:1.25rem;position:fixed;top:0;width:100%;z-index:999999999999}#nuxt-graphql-middleware-errors-background{background-color:rgba(68,64,60,.95);height:100%;left:0;position:absolute;top:0;width:100%}#nuxt-graphql-middleware-errors-content{border-radius:.25rem;max-width:1200px;overflow:auto;position:relative;width:100%;z-index:50;--ngm-tw-bg-opacity:1;background-color:rgb(28 25 23/var(--ngm-tw-bg-opacity,1));padding:1.75rem;--ngm-tw-shadow:0 25px 50px -12px rgba(0,0,0,.25);--ngm-tw-shadow-colored:0 25px 50px -12px var(--ngm-tw-shadow-color);box-shadow:var(--ngm-tw-ring-offset-shadow,0 0 #0000),var(--ngm-tw-ring-shadow,0 0 #0000),var(--ngm-tw-shadow);max-height:calc(100vh - 40px)}#nuxt-graphql-middleware-errors-content header{border-bottom-width:1px;display:flex;justify-content:space-between;margin-bottom:.75rem;--ngm-tw-border-opacity:1;border-bottom-color:rgb(68 64 60/var(--ngm-tw-border-opacity,1));padding-bottom:1.25rem}#nuxt-graphql-middleware-errors-content header h1{font-size:1.25rem;font-weight:700;line-height:1.75rem;--ngm-tw-text-opacity:1;color:rgb(255 255 255/var(--ngm-tw-text-opacity,1))}#nuxt-graphql-middleware-errors-content header button{border-radius:.25rem;--ngm-tw-bg-opacity:1;background-color:rgb(87 83 78/var(--ngm-tw-bg-opacity,1));font-size:.875rem;font-weight:700;letter-spacing:.1em;line-height:1.25rem;padding:.5rem .625rem;text-transform:uppercase;--ngm-tw-text-opacity:1;color:rgb(245 245 244/var(--ngm-tw-text-opacity,1))}#nuxt-graphql-middleware-errors-content header button:hover{--ngm-tw-bg-opacity:1;background-color:rgb(231 229 228/var(--ngm-tw-bg-opacity,1));--ngm-tw-text-opacity:1;color:rgb(28 25 23/var(--ngm-tw-text-opacity,1))}.nuxt-graphql-middleware-error-group{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;--ngm-tw-text-opacity:1;color:rgb(245 245 244/var(--ngm-tw-text-opacity,1))}.nuxt-graphql-middleware-error-group td{padding-bottom:.375rem;padding-top:.375rem}.nuxt-graphql-middleware-error-group td:first-child{padding-right:2.5rem}.nuxt-graphql-middleware-error-group td:nth-child(2){overflow:auto;white-space:pre-wrap}.nuxt-graphql-middleware-error-group td.ngm-large{font-size:1.5rem;font-weight:700;line-height:2rem;padding-bottom:.75rem;padding-top:.75rem}.nuxt-graphql-middleware-error-group code{--ngm-tw-bg-opacity:1;background-color:rgb(28 25 23/var(--ngm-tw-bg-opacity,1))}.nuxt-graphql-middleware-errors-code{border-radius:.25rem;border-width:1px;display:block;margin-bottom:1rem;margin-top:1rem;white-space:pre;--ngm-tw-border-opacity:1;border-color:rgb(87 83 78/var(--ngm-tw-border-opacity,1));--ngm-tw-bg-opacity:1;background-color:rgb(41 37 36/var(--ngm-tw-bg-opacity,1));font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;padding:.75rem;--ngm-tw-text-opacity:1;color:rgb(255 255 255/var(--ngm-tw-text-opacity,1));display:flex;gap:2rem}.nuxt-graphql-middleware-errors-code-code.ngm-is-highlighted{border-radius:.25rem;border-width:1px;--ngm-tw-border-opacity:1;border-color:rgb(185 28 28/var(--ngm-tw-border-opacity,1));--ngm-tw-bg-opacity:1;background-color:rgb(127 29 29/var(--ngm-tw-bg-opacity,1))}.nuxt-graphql-middleware-errors-code-line-number{text-align:right}.table{display:table}
@@ -1,40 +1,37 @@
1
1
  import type { FetchOptions } from 'ofetch';
2
- import type { GraphqlMiddlewareQuery, GraphqlMiddlewareMutation } from '#nuxt-graphql-middleware/generated-types';
3
- import type { RequestCacheOptions } from '#graphql-middleware/types';
4
- import type { GraphqlClientContext } from '#graphql-middleware-client-options';
5
- export type GraphqlMiddlewareQueryName = keyof GraphqlMiddlewareQuery;
6
- export type GraphqlMiddlewareMutationName = keyof GraphqlMiddlewareMutation;
2
+ import type { RequestCacheOptions } from './../types.js';
3
+ import type { GraphqlClientContext } from '#nuxt-graphql-middleware/client-options';
4
+ import type { Query, Mutation } from '#nuxt-graphql-middleware/operation-types';
7
5
  export type GraphqlComposableOptions = {
8
6
  fetchOptions?: FetchOptions;
9
7
  graphqlCaching?: RequestCacheOptions;
10
8
  clientContext?: Partial<GraphqlClientContext>;
11
9
  };
12
- export type GetQueryArgs<T extends GraphqlMiddlewareQueryName, M extends GraphqlMiddlewareQuery> = M[T][0] extends null ? [T, (null | undefined)?, GraphqlComposableOptions?] : M[T][1] extends false ? [T, M[T][0], GraphqlComposableOptions?] : [T, M[T][0]?, GraphqlComposableOptions?];
13
- export type GetMutationArgs<T extends GraphqlMiddlewareMutationName, M extends GraphqlMiddlewareMutation> = M[T][0] extends null ? [T, (null | undefined)?, GraphqlComposableOptions?] : M[T][1] extends false ? [T, M[T][0], GraphqlComposableOptions?] : [T, M[T][0]?, GraphqlComposableOptions?];
14
- export type GetQueryResult<T extends GraphqlMiddlewareQueryName, M extends GraphqlMiddlewareQuery> = M[T] extends undefined ? undefined : M[T][2];
15
- export type GetMutationResult<T extends GraphqlMiddlewareMutationName, M extends GraphqlMiddlewareMutation> = M[T] extends undefined ? undefined : M[T][2];
16
- export declare function getEndpoint(operation: string, operationName: string): string;
17
- export type QueryObjectArgs<T extends GraphqlMiddlewareQueryName, M extends GraphqlMiddlewareQuery> = M[T][0] extends null ? {
18
- name: T;
10
+ export type GetQueryArgs<K extends keyof Query, Q extends Query[K] = Query[K]> = Q['variables'] extends null ? [K, (null | undefined)?, GraphqlComposableOptions?] : Q['needsVariables'] extends true ? [K, Q['variables'], GraphqlComposableOptions?] : [K, (Q['variables'] | null)?, GraphqlComposableOptions?];
11
+ export type GetMutationArgs<K extends keyof Mutation, M extends Mutation[K] = Mutation[K]> = M['needsVariables'] extends true ? [K, M['variables'], GraphqlComposableOptions?] : [K, (M['variables'] | null)?, GraphqlComposableOptions?];
12
+ export type GetQueryResult<K extends keyof Query, Q extends Query[K] = Query[K]> = Q['response'];
13
+ export type GetMutationResult<K extends keyof Mutation, M extends Mutation[K] = Mutation[K]> = M['response'];
14
+ export type QueryObjectArgs<K extends keyof Query, Q extends Query[K] = Query[K]> = Q['needsVariables'] extends true ? {
15
+ name: K;
19
16
  fetchOptions?: FetchOptions;
20
17
  graphqlCaching?: RequestCacheOptions;
21
18
  clientContext?: Partial<GraphqlClientContext>;
22
- variables?: null;
19
+ variables: Q['variables'];
23
20
  } : {
24
- name: T;
25
- variables: M[T][0];
21
+ name: K;
22
+ variables?: Q['variables'] | null;
26
23
  fetchOptions?: FetchOptions;
27
24
  graphqlCaching?: RequestCacheOptions;
28
25
  clientContext?: Partial<GraphqlClientContext>;
29
26
  };
30
- export type MutationObjectArgs<T extends GraphqlMiddlewareMutationName, M extends GraphqlMiddlewareMutation> = M[T][0] extends null ? {
31
- name: T;
32
- variables?: null;
27
+ export type MutationObjectArgs<K extends keyof Mutation, M extends Mutation[K] = Mutation[K]> = M['needsVariables'] extends true ? {
28
+ name: K;
29
+ variables: M['variables'];
33
30
  fetchOptions?: FetchOptions;
34
31
  clientContext?: Partial<GraphqlClientContext>;
35
32
  } : {
36
- name: T;
37
- variables: M[T][0];
33
+ name: K;
34
+ variables?: M['variables'] | null;
38
35
  fetchOptions?: FetchOptions;
39
36
  clientContext?: Partial<GraphqlClientContext>;
40
37
  };
@@ -1,9 +1,4 @@
1
- import { useRuntimeConfig } from "#imports";
2
1
  import { CLIENT_CONTEXT_PREFIX } from "../settings/index.js";
3
- export function getEndpoint(operation, operationName) {
4
- const config = useRuntimeConfig();
5
- return `${config?.public?.["nuxt-graphql-middleware"]?.serverApiPrefix}/${operation}/${operationName}`;
6
- }
7
2
  export function encodeContext(context) {
8
3
  return Object.entries(context).reduce(
9
4
  (acc, [key, value]) => {
@@ -0,0 +1,2 @@
1
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import { defineNuxtPlugin, useState } from "#imports";
2
+ import { createApp } from "vue";
3
+ import DevModeOverlay from "../components/DevModeOverlay.vue";
4
+ export default defineNuxtPlugin({
5
+ name: "nuxt-graphql-middleware:dev-mode",
6
+ setup(nuxtApp) {
7
+ const errors = useState(
8
+ "nuxt-graphql-middleware-errors",
9
+ () => []
10
+ );
11
+ nuxtApp.hook("nuxt-graphql-middleware:errors", (value) => {
12
+ errors.value.push(value);
13
+ });
14
+ if (import.meta.client) {
15
+ nuxtApp.hook("app:mounted", () => {
16
+ const container = document.createElement("div");
17
+ document.body.appendChild(container);
18
+ const instance = createApp(DevModeOverlay);
19
+ instance.mount(container);
20
+ });
21
+ }
22
+ }
23
+ });
@@ -1,4 +1,4 @@
1
- import { type GraphqlMiddlewareState } from '#graphql-middleware/types';
1
+ import type { GraphqlMiddlewareState } from './../types.js';
2
2
  /**
3
3
  * Create and provide the state singleton for the composables.
4
4
  */
@@ -1,14 +1,10 @@
1
1
  import { defineEventHandler } from "h3";
2
- import { operations } from "#graphql-documents";
3
- import { useRuntimeConfig } from "#imports";
2
+ import { documents } from "#nuxt-graphql-middleware/documents";
3
+ import { getEndpoint } from "#nuxt-graphql-middleware/helpers";
4
4
  export default defineEventHandler(() => {
5
- function getEndpoint(operation, operationName) {
6
- const config = useRuntimeConfig();
7
- return `${config?.public?.["nuxt-graphql-middleware"]?.serverApiPrefix}/${operation}/${operationName}`;
8
- }
9
5
  let body = "<h1>nuxt-graphql-middleware debug</h1>";
10
6
  body += "<table><tbody>";
11
- Object.entries(operations).forEach(([operationType, items]) => {
7
+ Object.entries(documents).forEach(([operationType, items]) => {
12
8
  Object.entries(items).forEach(([operationName, operation]) => {
13
9
  body += "<tr>";
14
10
  body += `<td style="font-size: 1.5rem">${operationType}</td>`;