nuxt-graphql-middleware 5.0.0-alpha.1 → 5.0.0-alpha.12

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 (65) hide show
  1. package/dist/client/200.html +11 -0
  2. package/dist/client/404.html +11 -0
  3. package/dist/client/_nuxt/AZpplOcD.js +1 -0
  4. package/dist/client/_nuxt/B2Rg1ezw.js +1 -0
  5. package/dist/client/_nuxt/Bt6N0bOg.js +2 -0
  6. package/dist/client/_nuxt/M311G39J.js +25 -0
  7. package/dist/client/_nuxt/builds/latest.json +1 -0
  8. package/dist/client/_nuxt/builds/meta/88c25798-8ea2-4139-90f2-506f3146e7b3.json +1 -0
  9. package/dist/client/_nuxt/entry.Cn9qfNGa.css +1 -0
  10. package/dist/client/_nuxt/error-404.ehK72JOs.css +1 -0
  11. package/dist/client/_nuxt/error-500._g0akJim.css +1 -0
  12. package/dist/client/_nuxt/index.DGEN-H8t.css +1 -0
  13. package/dist/client/_nuxt/u9er1db2.js +1 -0
  14. package/dist/client/index.html +11 -0
  15. package/dist/module.d.mts +57 -205
  16. package/dist/module.d.ts +57 -205
  17. package/dist/module.json +2 -2
  18. package/dist/module.mjs +1138 -563
  19. package/dist/runtime/components/CodeFrame.vue +61 -0
  20. package/dist/runtime/components/DevModeOverlay.vue +60 -0
  21. package/dist/runtime/components/ErrorExtensions.vue +23 -0
  22. package/dist/runtime/components/ErrorGroup.vue +89 -0
  23. package/dist/runtime/composables/nuxtApp.d.ts +2 -2
  24. package/dist/runtime/composables/nuxtApp.js +21 -1
  25. package/dist/runtime/composables/useAsyncGraphqlQuery.d.ts +7 -7
  26. package/dist/runtime/composables/useAsyncGraphqlQuery.js +10 -2
  27. package/dist/runtime/composables/useGraphqlMutation.d.ts +4 -4
  28. package/dist/runtime/composables/useGraphqlMutation.js +1 -1
  29. package/dist/runtime/composables/useGraphqlQuery.d.ts +4 -4
  30. package/dist/runtime/composables/useGraphqlQuery.js +1 -1
  31. package/dist/runtime/composables/useGraphqlState.d.ts +1 -1
  32. package/dist/runtime/composables/useGraphqlState.js +1 -1
  33. package/dist/runtime/composables/useGraphqlUploadMutation.d.ts +4 -4
  34. package/dist/runtime/composables/useGraphqlUploadMutation.js +2 -2
  35. package/dist/runtime/css/output.css +1 -0
  36. package/dist/runtime/helpers/composables.d.ts +17 -20
  37. package/dist/runtime/helpers/composables.js +0 -5
  38. package/dist/runtime/plugins/devMode.d.ts +2 -0
  39. package/dist/runtime/plugins/devMode.js +23 -0
  40. package/dist/runtime/plugins/provideState.d.ts +1 -1
  41. package/dist/runtime/{serverHandler → server/api}/debug.js +3 -7
  42. package/dist/runtime/server/api/mutation.js +28 -0
  43. package/dist/runtime/server/api/query.js +29 -0
  44. package/dist/runtime/server/api/upload.d.ts +2 -0
  45. package/dist/runtime/{serverHandler → server/api}/upload.js +13 -11
  46. package/dist/runtime/{serverHandler → server}/helpers/index.d.ts +10 -12
  47. package/dist/runtime/{serverHandler → server}/helpers/index.js +9 -26
  48. package/dist/runtime/server/utils/doGraphqlRequest.d.ts +18 -0
  49. package/dist/runtime/server/utils/doGraphqlRequest.js +67 -0
  50. package/dist/runtime/server/utils/index.d.ts +1 -1
  51. package/dist/runtime/server/utils/index.js +1 -1
  52. package/dist/runtime/server/utils/useGraphqlMutation.d.ts +4 -4
  53. package/dist/runtime/server/utils/useGraphqlQuery.d.ts +4 -4
  54. package/dist/runtime/serverOptions/defineGraphqlServerOptions.d.ts +4 -3
  55. package/dist/runtime/settings/index.d.ts +0 -14
  56. package/dist/runtime/settings/index.js +0 -6
  57. package/dist/runtime/types.d.ts +204 -3
  58. package/dist/types.d.mts +5 -5
  59. package/dist/types.d.ts +5 -5
  60. package/package.json +39 -36
  61. package/dist/runtime/serverHandler/index.js +0 -78
  62. package/dist/runtime/serverHandler/tsconfig.json +0 -3
  63. /package/dist/runtime/{serverHandler → server/api}/debug.d.ts +0 -0
  64. /package/dist/runtime/{serverHandler/index.d.ts → server/api/mutation.d.ts} +0 -0
  65. /package/dist/runtime/{serverHandler/upload.d.ts → server/api/query.d.ts} +0 -0
@@ -0,0 +1,61 @@
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 lang="ts">
27
+ import { computed } from '#imports'
28
+
29
+ const props = defineProps<{
30
+ source: string
31
+ line: number
32
+ column: number
33
+ }>()
34
+
35
+ const before = 20
36
+ const after = 20
37
+
38
+ const lines = computed(() => {
39
+ const fullLines = props.source.split('\n')
40
+ const indexStart = Math.max(props.line - before - 1, 0)
41
+ const indexEnd = Math.min(props.line + after, fullLines.length)
42
+
43
+ // Take only the lines we care about
44
+ const sliced = fullLines.slice(indexStart, indexEnd)
45
+
46
+ // Remove trailing empty lines
47
+ while (sliced.length && !sliced[sliced.length - 1]?.trim()) {
48
+ sliced.pop()
49
+ }
50
+
51
+ // Map to your final structure
52
+ return sliced.map((code, i) => {
53
+ const lineNumber = indexStart + i + 1
54
+ return {
55
+ lineNumber,
56
+ code,
57
+ isHighlighted: lineNumber === props.line,
58
+ }
59
+ })
60
+ })
61
+ </script>
@@ -0,0 +1,60 @@
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 lang="ts">
25
+ import './../css/output.css'
26
+ import { useState, computed } from '#imports'
27
+
28
+ import type { OperationResponseError } from '../types'
29
+ import ErrorGroup from './ErrorGroup.vue'
30
+
31
+ const errors = useState<OperationResponseError[]>(
32
+ 'nuxt-graphql-middleware-errors',
33
+ () => [],
34
+ )
35
+
36
+ const groups = computed<OperationResponseError[]>(() => {
37
+ return [
38
+ ...errors.value
39
+ .reduce<Map<string, OperationResponseError>>((acc, v) => {
40
+ const key = `${v.operation}_${v.operationName}`
41
+ if (!acc.has(key)) {
42
+ acc.set(key, {
43
+ operation: v.operation,
44
+ operationName: v.operationName,
45
+ errors: [],
46
+ stack: v.stack,
47
+ })
48
+ }
49
+ acc.get(key)!.errors.push(...v.errors)
50
+ return acc
51
+ }, new Map())
52
+ .values(),
53
+ ]
54
+ })
55
+
56
+ /** Clear the error state => close/hide the overlay */
57
+ function clearErrors() {
58
+ errors.value = []
59
+ }
60
+ </script>
@@ -0,0 +1,23 @@
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 lang="ts">
9
+ import { computed } from '#imports'
10
+
11
+ const props = defineProps<{
12
+ extensions?: Record<string, unknown>
13
+ }>()
14
+
15
+ const mapped = computed(() => {
16
+ if (!props.extensions) {
17
+ return []
18
+ }
19
+ return Object.entries(props.extensions).map(([key, value]) => {
20
+ return { key, value }
21
+ })
22
+ })
23
+ </script>
@@ -0,0 +1,89 @@
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 lang="ts" setup>
50
+ import type { GraphqlResponseError } from '../types'
51
+ import { documents } from '#nuxt-graphql-middleware/documents'
52
+ import { operationSources } from '#nuxt-graphql-middleware/sources'
53
+ import { computed } from '#imports'
54
+ import CodeFrame from './CodeFrame.vue'
55
+ import ErrorExtensions from './ErrorExtensions.vue'
56
+
57
+ type MappedError = GraphqlResponseError & { count: number; key: string }
58
+
59
+ const props = defineProps<{
60
+ operation: string
61
+ operationName: string
62
+ errors: GraphqlResponseError[]
63
+ stack?: string
64
+ }>()
65
+
66
+ const key = computed(() => props.operation + '_' + props.operationName)
67
+
68
+ const filePath = computed(() => {
69
+ return operationSources[key.value]
70
+ })
71
+
72
+ const source = computed(
73
+ () => (documents as any)[props.operation]?.[props.operationName],
74
+ )
75
+
76
+ const uniqueErrors = computed<MappedError[]>(() => {
77
+ return props.errors
78
+ .reduce<Map<string, MappedError>>((acc, v) => {
79
+ const key = v.message
80
+ if (!acc.has(key)) {
81
+ acc.set(key, { ...v, key, count: 0 })
82
+ }
83
+ acc.get(key)!.count++
84
+ return acc
85
+ }, new Map())
86
+ .values()
87
+ .toArray()
88
+ })
89
+ </script>
@@ -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>`;
@@ -0,0 +1,28 @@
1
+ import { defineEventHandler, getQuery, getRouterParam, readBody } from "h3";
2
+ import {
3
+ extractRequestContext,
4
+ isValidMutation,
5
+ throwError
6
+ } from "./../helpers/index.js";
7
+ import { GraphqlMiddlewareOperation } from "./../../settings/index.js";
8
+ import { documents } from "#nuxt-graphql-middleware/documents";
9
+ import { doGraphqlRequest } from "../utils/doGraphqlRequest.js";
10
+ export default defineEventHandler(async (event) => {
11
+ const operationName = getRouterParam(event, "name");
12
+ if (!isValidMutation(operationName)) {
13
+ return throwError("Invalid mutation name.");
14
+ }
15
+ const operationDocument = documents.mutation[operationName];
16
+ const queryParams = getQuery(event);
17
+ const context = extractRequestContext(queryParams);
18
+ const variables = await readBody(event);
19
+ return doGraphqlRequest(
20
+ {
21
+ query: operationDocument,
22
+ variables,
23
+ operation: GraphqlMiddlewareOperation.Mutation
24
+ },
25
+ context,
26
+ event
27
+ );
28
+ });