nuxt-graphql-middleware 5.2.3 → 5.3.1

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 (133) hide show
  1. package/README.md +2 -0
  2. package/dist/client/200.html +1 -1
  3. package/dist/client/404.html +1 -1
  4. package/dist/client/_nuxt/CqRv5mwS.js +2 -0
  5. package/dist/client/_nuxt/{gyQx9VSj.js → D95LLO0l.js} +1 -1
  6. package/dist/client/_nuxt/{DyBqp5hr.js → DZ-uq6Vd.js} +1 -1
  7. package/dist/client/_nuxt/DrXVleME.js +4 -0
  8. package/dist/client/_nuxt/{BPB7Y782.js → Dx-h1-qv.js} +1 -1
  9. package/dist/client/_nuxt/builds/latest.json +1 -1
  10. package/dist/client/_nuxt/builds/meta/efa6c0a0-833e-4e5a-bc2d-ba9d0d3e4562.json +1 -0
  11. package/dist/client/index.html +1 -1
  12. package/dist/module.d.mts +1 -1
  13. package/dist/module.json +3 -3
  14. package/dist/module.mjs +1526 -70
  15. package/dist/runtime/components/CodeFrame.d.vue.ts +8 -0
  16. package/dist/runtime/components/CodeFrame.vue.d.ts +2 -1
  17. package/dist/runtime/components/DevModeOverlay.d.vue.ts +4 -0
  18. package/dist/runtime/components/DevModeOverlay.vue.d.ts +2 -1
  19. package/dist/runtime/components/ErrorExtensions.d.vue.ts +6 -0
  20. package/dist/runtime/components/ErrorExtensions.vue.d.ts +2 -1
  21. package/dist/runtime/components/ErrorGroup.d.vue.ts +10 -0
  22. package/dist/runtime/components/ErrorGroup.vue.d.ts +2 -1
  23. package/dist/runtime/helpers/composables.d.ts +1 -40
  24. package/dist/runtime/helpers/composables.js +3 -12
  25. package/dist/runtime/helpers/shared-types.d.ts +40 -0
  26. package/dist/runtime/helpers/shared-types.js +12 -0
  27. package/dist/runtime/server/api/doRequest.d.ts +2 -0
  28. package/dist/runtime/server/api/doRequest.js +18 -0
  29. package/dist/runtime/server/helpers/index.js +1 -1
  30. package/dist/runtime/server/mcp/handler.d.ts +2 -0
  31. package/dist/runtime/server/mcp/handler.js +63 -0
  32. package/dist/runtime/server/mcp/resources/docs.d.ts +2 -0
  33. package/dist/runtime/server/mcp/resources/docs.js +36 -0
  34. package/dist/runtime/server/mcp/tools/fragments-get/index.d.ts +1 -0
  35. package/dist/runtime/server/mcp/tools/fragments-get/index.js +35 -0
  36. package/dist/runtime/server/mcp/tools/fragments-get/types.d.ts +20 -0
  37. package/dist/runtime/server/mcp/tools/fragments-get/types.js +13 -0
  38. package/dist/runtime/server/mcp/tools/fragments-get-source/index.d.ts +1 -0
  39. package/dist/runtime/server/mcp/tools/fragments-get-source/index.js +34 -0
  40. package/dist/runtime/server/mcp/tools/fragments-get-source/types.d.ts +10 -0
  41. package/dist/runtime/server/mcp/tools/fragments-get-source/types.js +9 -0
  42. package/dist/runtime/server/mcp/tools/fragments-list/index.d.ts +1 -0
  43. package/dist/runtime/server/mcp/tools/fragments-list/index.js +36 -0
  44. package/dist/runtime/server/mcp/tools/fragments-list/types.d.ts +20 -0
  45. package/dist/runtime/server/mcp/tools/fragments-list/types.js +14 -0
  46. package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.d.ts +1 -0
  47. package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.js +39 -0
  48. package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.d.ts +31 -0
  49. package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.js +23 -0
  50. package/dist/runtime/server/mcp/tools/graphql-execute/index.d.ts +1 -0
  51. package/dist/runtime/server/mcp/tools/graphql-execute/index.js +59 -0
  52. package/dist/runtime/server/mcp/tools/module-get-config/index.d.ts +1 -0
  53. package/dist/runtime/server/mcp/tools/module-get-config/index.js +23 -0
  54. package/dist/runtime/server/mcp/tools/module-get-config/types.d.ts +39 -0
  55. package/dist/runtime/server/mcp/tools/module-get-config/types.js +26 -0
  56. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.d.ts +1 -0
  57. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.js +36 -0
  58. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.d.ts +49 -0
  59. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.js +24 -0
  60. package/dist/runtime/server/mcp/tools/operations-execute/index.d.ts +1 -0
  61. package/dist/runtime/server/mcp/tools/operations-execute/index.js +63 -0
  62. package/dist/runtime/server/mcp/tools/operations-get/index.d.ts +1 -0
  63. package/dist/runtime/server/mcp/tools/operations-get/index.js +40 -0
  64. package/dist/runtime/server/mcp/tools/operations-get/types.d.ts +32 -0
  65. package/dist/runtime/server/mcp/tools/operations-get/types.js +18 -0
  66. package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.d.ts +1 -0
  67. package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.js +39 -0
  68. package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.d.ts +38 -0
  69. package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.js +19 -0
  70. package/dist/runtime/server/mcp/tools/operations-get-source/index.d.ts +1 -0
  71. package/dist/runtime/server/mcp/tools/operations-get-source/index.js +39 -0
  72. package/dist/runtime/server/mcp/tools/operations-get-source/types.d.ts +10 -0
  73. package/dist/runtime/server/mcp/tools/operations-get-source/types.js +9 -0
  74. package/dist/runtime/server/mcp/tools/operations-list/index.d.ts +1 -0
  75. package/dist/runtime/server/mcp/tools/operations-list/index.js +46 -0
  76. package/dist/runtime/server/mcp/tools/operations-list/types.d.ts +53 -0
  77. package/dist/runtime/server/mcp/tools/operations-list/types.js +33 -0
  78. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.d.ts +1 -0
  79. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.js +37 -0
  80. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.d.ts +24 -0
  81. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.js +16 -0
  82. package/dist/runtime/server/mcp/tools/schema-get-type/index.d.ts +1 -0
  83. package/dist/runtime/server/mcp/tools/schema-get-type/index.js +31 -0
  84. package/dist/runtime/server/mcp/tools/schema-get-type/types.d.ts +112 -0
  85. package/dist/runtime/server/mcp/tools/schema-get-type/types.js +45 -0
  86. package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.d.ts +1 -0
  87. package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.js +33 -0
  88. package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.d.ts +10 -0
  89. package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.js +9 -0
  90. package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.d.ts +1 -0
  91. package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.js +35 -0
  92. package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.d.ts +39 -0
  93. package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.js +17 -0
  94. package/dist/runtime/server/mcp/tools/schema-get-union-members/index.d.ts +1 -0
  95. package/dist/runtime/server/mcp/tools/schema-get-union-members/index.js +35 -0
  96. package/dist/runtime/server/mcp/tools/schema-get-union-members/types.d.ts +24 -0
  97. package/dist/runtime/server/mcp/tools/schema-get-union-members/types.js +16 -0
  98. package/dist/runtime/server/mcp/tools/schema-list-types/index.d.ts +1 -0
  99. package/dist/runtime/server/mcp/tools/schema-list-types/index.js +37 -0
  100. package/dist/runtime/server/mcp/tools/schema-list-types/types.d.ts +53 -0
  101. package/dist/runtime/server/mcp/tools/schema-list-types/types.js +21 -0
  102. package/dist/runtime/server/mcp/tools/schema-validate-document/index.d.ts +1 -0
  103. package/dist/runtime/server/mcp/tools/schema-validate-document/index.js +31 -0
  104. package/dist/runtime/server/mcp/tools/schema-validate-document/types.d.ts +26 -0
  105. package/dist/runtime/server/mcp/tools/schema-validate-document/types.js +21 -0
  106. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.d.ts +1 -0
  107. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.js +36 -0
  108. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.d.ts +49 -0
  109. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.js +24 -0
  110. package/dist/runtime/server/mcp/utils/index.d.ts +48 -0
  111. package/dist/runtime/server/mcp/utils/index.js +35 -0
  112. package/dist/runtime/server/utils/useGraphqlMutation.d.ts +1 -1
  113. package/dist/runtime/server/utils/useGraphqlMutation.js +1 -1
  114. package/dist/runtime/server/utils/useGraphqlQuery.d.ts +1 -1
  115. package/dist/runtime/server/utils/useGraphqlQuery.js +1 -1
  116. package/dist/shared/{nuxt-graphql-middleware.ct2xvPoD.d.mts → nuxt-graphql-middleware.COufMnWs.d.mts} +119 -2
  117. package/dist/utils.d.mts +1 -1
  118. package/docs/composables/useAsyncGraphqlQuery.md +313 -0
  119. package/docs/composables/useGraphqlMutation.md +29 -0
  120. package/docs/composables/useGraphqlQuery.md +73 -0
  121. package/docs/composables/useGraphqlState.md +58 -0
  122. package/docs/composables/useGraphqlUploadMutation.md +57 -0
  123. package/docs/configuration/client-options.md +121 -0
  124. package/docs/configuration/module-hooks.md +112 -0
  125. package/docs/configuration/module-utils.md +53 -0
  126. package/docs/configuration/module.md +415 -0
  127. package/docs/configuration/runtime-config.md +23 -0
  128. package/docs/configuration/server-options.md +230 -0
  129. package/package.json +101 -44
  130. package/dist/client/_nuxt/Bkyil6hz.js +0 -2
  131. package/dist/client/_nuxt/C9p-Va5c.js +0 -29
  132. package/dist/client/_nuxt/builds/meta/77b9a31d-6d5c-4e28-9320-cbd287a46883.json +0 -1
  133. package/dist/runtime/server/tsconfig.json +0 -3
@@ -0,0 +1,8 @@
1
+ type __VLS_Props = {
2
+ source: string;
3
+ line: number;
4
+ column: number;
5
+ };
6
+ declare const __VLS_export: 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
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -3,5 +3,6 @@ type __VLS_Props = {
3
3
  line: number;
4
4
  column: number;
5
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>;
6
+ declare const __VLS_export: 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
+ declare const _default: typeof __VLS_export;
7
8
  export default _default;
@@ -0,0 +1,4 @@
1
+ import './../css/output.css.js';
2
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
3
+ declare const _default: typeof __VLS_export;
4
+ export default _default;
@@ -1,3 +1,4 @@
1
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>;
2
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
3
+ declare const _default: typeof __VLS_export;
3
4
  export default _default;
@@ -0,0 +1,6 @@
1
+ type __VLS_Props = {
2
+ extensions?: Record<string, unknown>;
3
+ };
4
+ declare const __VLS_export: 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
+ declare const _default: typeof __VLS_export;
6
+ export default _default;
@@ -1,5 +1,6 @@
1
1
  type __VLS_Props = {
2
2
  extensions?: Record<string, unknown>;
3
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>;
4
+ declare const __VLS_export: 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
+ declare const _default: typeof __VLS_export;
5
6
  export default _default;
@@ -0,0 +1,10 @@
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 __VLS_export: 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
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -5,5 +5,6 @@ type __VLS_Props = {
5
5
  errors: GraphqlResponseError[];
6
6
  stack?: string;
7
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>;
8
+ declare const __VLS_export: 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
+ declare const _default: typeof __VLS_export;
9
10
  export default _default;
@@ -1,44 +1,5 @@
1
- import type { FetchOptions } from 'ofetch';
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';
5
1
  import type { NuxtApp } from '#app';
6
2
  import type { AppConfig } from 'nuxt/schema';
7
3
  import { GraphqlMiddlewareCache } from './ClientCache.js';
8
- export type GraphqlComposableOptions = {
9
- fetchOptions?: FetchOptions;
10
- graphqlCaching?: RequestCacheOptions;
11
- clientContext?: Partial<GraphqlClientContext>;
12
- };
13
- 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?];
14
- 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?];
15
- export type GetQueryResult<K extends keyof Query, Q extends Query[K] = Query[K]> = Q['response'];
16
- export type GetMutationResult<K extends keyof Mutation, M extends Mutation[K] = Mutation[K]> = M['response'];
17
- export type QueryObjectArgs<K extends keyof Query, Q extends Query[K] = Query[K]> = Q['needsVariables'] extends true ? {
18
- name: K;
19
- fetchOptions?: FetchOptions;
20
- graphqlCaching?: RequestCacheOptions;
21
- clientContext?: Partial<GraphqlClientContext>;
22
- variables: Q['variables'];
23
- } : {
24
- name: K;
25
- variables?: Q['variables'] | null;
26
- fetchOptions?: FetchOptions;
27
- graphqlCaching?: RequestCacheOptions;
28
- clientContext?: Partial<GraphqlClientContext>;
29
- };
30
- export type MutationObjectArgs<K extends keyof Mutation, M extends Mutation[K] = Mutation[K]> = M['needsVariables'] extends true ? {
31
- name: K;
32
- variables: M['variables'];
33
- fetchOptions?: FetchOptions;
34
- clientContext?: Partial<GraphqlClientContext>;
35
- } : {
36
- name: K;
37
- variables?: M['variables'] | null;
38
- fetchOptions?: FetchOptions;
39
- clientContext?: Partial<GraphqlClientContext>;
40
- };
41
- export type PickFrom<T, K extends Array<string>> = T extends Array<any> ? T : T extends Record<string, any> ? keyof T extends K[number] ? T : K[number] extends never ? T : Pick<T, K[number]> : T;
42
- export type KeysOf<T> = Array<T extends T ? (keyof T extends string ? keyof T : never) : never>;
43
- export declare function encodeContext(context: Record<string, string | null | undefined>): Record<string, string>;
4
+ export { type GraphqlComposableOptions, type GetQueryArgs, type GetMutationArgs, type GetQueryResult, type GetMutationResult, type QueryObjectArgs, type MutationObjectArgs, type PickFrom, type KeysOf, encodeContext, } from './shared-types.js';
44
5
  export declare function getOrCreateClientCache(app: NuxtApp, config: AppConfig): GraphqlMiddlewareCache | undefined;
@@ -1,20 +1,11 @@
1
- import { CLIENT_CONTEXT_PREFIX } from "../settings/index.js";
2
1
  import { GraphqlMiddlewareCache } from "./ClientCache.js";
3
2
  import {
4
3
  clientCacheEnabledAtBuild,
5
4
  importMetaServer
6
5
  } from "#nuxt-graphql-middleware/config";
7
- export function encodeContext(context) {
8
- return Object.entries(context).reduce(
9
- (acc, [key, value]) => {
10
- if (typeof value === "string") {
11
- acc[CLIENT_CONTEXT_PREFIX + key] = value;
12
- }
13
- return acc;
14
- },
15
- {}
16
- );
17
- }
6
+ export {
7
+ encodeContext
8
+ } from "./shared-types.js";
18
9
  export function getOrCreateClientCache(app, config) {
19
10
  if (importMetaServer || !clientCacheEnabledAtBuild) {
20
11
  return;
@@ -0,0 +1,40 @@
1
+ import type { FetchOptions } from 'ofetch';
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';
5
+ export type GraphqlComposableOptions = {
6
+ fetchOptions?: FetchOptions;
7
+ graphqlCaching?: RequestCacheOptions;
8
+ clientContext?: Partial<GraphqlClientContext>;
9
+ };
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;
16
+ fetchOptions?: FetchOptions;
17
+ graphqlCaching?: RequestCacheOptions;
18
+ clientContext?: Partial<GraphqlClientContext>;
19
+ variables: Q['variables'];
20
+ } : {
21
+ name: K;
22
+ variables?: Q['variables'] | null;
23
+ fetchOptions?: FetchOptions;
24
+ graphqlCaching?: RequestCacheOptions;
25
+ clientContext?: Partial<GraphqlClientContext>;
26
+ };
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'];
30
+ fetchOptions?: FetchOptions;
31
+ clientContext?: Partial<GraphqlClientContext>;
32
+ } : {
33
+ name: K;
34
+ variables?: M['variables'] | null;
35
+ fetchOptions?: FetchOptions;
36
+ clientContext?: Partial<GraphqlClientContext>;
37
+ };
38
+ export type PickFrom<T, K extends Array<string>> = T extends Array<any> ? T : T extends Record<string, any> ? keyof T extends K[number] ? T : K[number] extends never ? T : Pick<T, K[number]> : T;
39
+ export type KeysOf<T> = Array<T extends T ? (keyof T extends string ? keyof T : never) : never>;
40
+ export declare function encodeContext(context: Record<string, string | null | undefined>): Record<string, string>;
@@ -0,0 +1,12 @@
1
+ import { CLIENT_CONTEXT_PREFIX } from "../settings/index.js";
2
+ export function encodeContext(context) {
3
+ return Object.entries(context).reduce(
4
+ (acc, [key, value]) => {
5
+ if (typeof value === "string") {
6
+ acc[CLIENT_CONTEXT_PREFIX + key] = value;
7
+ }
8
+ return acc;
9
+ },
10
+ {}
11
+ );
12
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
2
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import { defineEventHandler, readBody } from "h3";
2
+ import { doGraphqlRequest } from "../utils/doGraphqlRequest.js";
3
+ export default defineEventHandler(async (event) => {
4
+ const body = await readBody(event);
5
+ const { document, variables, operationName } = body || {};
6
+ if (!document || typeof document !== "string") {
7
+ return { data: null, errors: [{ message: "Missing or invalid document" }] };
8
+ }
9
+ return doGraphqlRequest(
10
+ {
11
+ query: document,
12
+ variables: variables || {},
13
+ operationName: operationName || void 0
14
+ },
15
+ null,
16
+ event
17
+ );
18
+ });
@@ -93,6 +93,6 @@ export function onServerError(serverOptions, event, error, operation, operationN
93
93
  throw createError({
94
94
  statusCode: 500,
95
95
  statusMessage: "Couldn't execute GraphQL query: " + message,
96
- data: error && "message" in error ? error.message : error
96
+ data: error.response?._data
97
97
  });
98
98
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,63 @@
1
+ import { defineMcpHandler } from "#imports";
2
+ import {
3
+ mcpServerRoute,
4
+ includeComposables
5
+ } from "#nuxt-graphql-middleware/mcp";
6
+ import { listOperationsTool } from "./tools/operations-list/index.js";
7
+ import { getOperationTool } from "./tools/operations-get/index.js";
8
+ import { getOperationSourceTool } from "./tools/operations-get-source/index.js";
9
+ import { getFieldUsageTool } from "./tools/operations-get-field-usage/index.js";
10
+ import { executeOperationTool } from "./tools/operations-execute/index.js";
11
+ import { listFragmentsTool } from "./tools/fragments-list/index.js";
12
+ import { getFragmentTool } from "./tools/fragments-get/index.js";
13
+ import { getFragmentSourceTool } from "./tools/fragments-get-source/index.js";
14
+ import { getFragmentsForTypeTool } from "./tools/fragments-list-for-type/index.js";
15
+ import { getSchemaTypeTool } from "./tools/schema-get-type/index.js";
16
+ import { getSchemaTypeDefinitionTool } from "./tools/schema-get-type-definition/index.js";
17
+ import { listSchemaTypesTool } from "./tools/schema-list-types/index.js";
18
+ import { getTypesImplementingInterfaceTool } from "./tools/schema-get-interface-implementors/index.js";
19
+ import { getUnionMembersTool } from "./tools/schema-get-union-members/index.js";
20
+ import { getTypeUsageTool } from "./tools/schema-get-type-usage/index.js";
21
+ import { validateDocumentTool } from "./tools/schema-validate-document/index.js";
22
+ import { executeGraphqlTool } from "./tools/graphql-execute/index.js";
23
+ import { vueGraphqlComposableExampleTool } from "./tools/vue-graphql-composable-example/index.js";
24
+ import { nitroGraphqlServerUtilsExampleTool } from "./tools/nitro-graphql-server-utils-example/index.js";
25
+ import { moduleGetConfigTool } from "./tools/module-get-config/index.js";
26
+ import docsResource from "./resources/docs.js";
27
+ const tools = [
28
+ // Operation tools.
29
+ listOperationsTool,
30
+ getOperationTool,
31
+ getOperationSourceTool,
32
+ getFieldUsageTool,
33
+ // Fragment tools.
34
+ listFragmentsTool,
35
+ getFragmentTool,
36
+ getFragmentSourceTool,
37
+ getFragmentsForTypeTool,
38
+ // Schema tools.
39
+ getSchemaTypeTool,
40
+ getSchemaTypeDefinitionTool,
41
+ listSchemaTypesTool,
42
+ getTypesImplementingInterfaceTool,
43
+ getUnionMembersTool,
44
+ getTypeUsageTool,
45
+ validateDocumentTool,
46
+ // Execution tools.
47
+ executeGraphqlTool,
48
+ executeOperationTool,
49
+ // Module tools.
50
+ moduleGetConfigTool
51
+ ];
52
+ if (includeComposables) {
53
+ tools.push(vueGraphqlComposableExampleTool);
54
+ tools.push(nitroGraphqlServerUtilsExampleTool);
55
+ }
56
+ export default defineMcpHandler({
57
+ name: "nuxt-graphql-middleware",
58
+ version: "1.0.0",
59
+ route: mcpServerRoute,
60
+ tools,
61
+ resources: [docsResource],
62
+ browserRedirect: "/"
63
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,36 @@
1
+ import { defineMcpResource } from "#imports";
2
+ import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { docs } from "#nuxt-graphql-middleware/mcp";
4
+ export default defineMcpResource({
5
+ name: "docs",
6
+ title: "Documentation",
7
+ description: "Documentation for nuxt-graphql-middleware composables and utilities.",
8
+ uri: new ResourceTemplate("docs://{+path}", {
9
+ list: async () => {
10
+ return {
11
+ resources: docs.map((doc) => ({
12
+ uri: doc.uri,
13
+ name: doc.name,
14
+ title: doc.name,
15
+ mimeType: "text/markdown",
16
+ description: doc.description
17
+ }))
18
+ };
19
+ }
20
+ }),
21
+ metadata: { mimeType: "text/markdown" },
22
+ handler: async (uri, variables) => {
23
+ const path = variables.path;
24
+ const doc = docs.find((d) => d.uri === `docs://${path}`);
25
+ const content = doc?.content || `Documentation not found for: ${path}`;
26
+ return {
27
+ contents: [
28
+ {
29
+ uri: uri.toString(),
30
+ mimeType: "text/markdown",
31
+ text: content
32
+ }
33
+ ]
34
+ };
35
+ }
36
+ });
@@ -0,0 +1 @@
1
+ export declare const getFragmentTool: any;
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
4
+ import { getFragmentOutputSchema } from "./types.js";
5
+ export const getFragmentTool = defineMcpTool({
6
+ name: "fragments-get",
7
+ title: "Get Fragment",
8
+ description: "Get detailed information about a specific GraphQL fragment. Returns the fragment name, the type it is defined on, file path, and dependencies on other fragments. Use fragments-get-source to get the GraphQL source code.",
9
+ annotations: {
10
+ readOnlyHint: true,
11
+ destructiveHint: false,
12
+ idempotentHint: true,
13
+ openWorldHint: false
14
+ },
15
+ inputSchema: {
16
+ fragmentName: z.string().describe("The name of the GraphQL fragment to get details for")
17
+ },
18
+ outputSchema: getFragmentOutputSchema,
19
+ handler: async ({ fragmentName }) => {
20
+ const response = await fetchFromMcpHandler(
21
+ "fragments-get",
22
+ { name: fragmentName }
23
+ );
24
+ if (response.error) {
25
+ return structuredResult({ error: response.error });
26
+ }
27
+ const frag = response.fragment;
28
+ return structuredResult({
29
+ name: frag.name,
30
+ typeName: frag.typeName,
31
+ filePath: frag.relativeFilePath,
32
+ dependencies: frag.dependencies
33
+ });
34
+ }
35
+ });
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ export declare const GetFragmentResponseSchema: z.ZodObject<{
3
+ fragment: z.ZodNullable<z.ZodObject<{
4
+ name: z.ZodString;
5
+ typeName: z.ZodString;
6
+ filePath: z.ZodString;
7
+ relativeFilePath: z.ZodString;
8
+ source: z.ZodString;
9
+ dependencies: z.ZodArray<z.ZodString>;
10
+ }, z.core.$strip>>;
11
+ error: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strip>;
13
+ export declare const getFragmentOutputSchema: {
14
+ name: z.ZodOptional<z.ZodString>;
15
+ typeName: z.ZodOptional<z.ZodString>;
16
+ filePath: z.ZodOptional<z.ZodString>;
17
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
18
+ error: z.ZodOptional<z.ZodString>;
19
+ };
20
+ export type GetFragmentResponse = z.infer<typeof GetFragmentResponseSchema>;
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ import { FragmentInfoSchema } from "../fragments-list-for-type/types.js";
3
+ export const GetFragmentResponseSchema = z.object({
4
+ fragment: FragmentInfoSchema.nullable(),
5
+ error: z.string().optional().describe("Error message if fragment not found")
6
+ });
7
+ export const getFragmentOutputSchema = {
8
+ name: z.string().optional().describe("Fragment name"),
9
+ typeName: z.string().optional().describe("The GraphQL type this fragment is defined on"),
10
+ filePath: z.string().optional().describe("Path to the file containing the fragment"),
11
+ dependencies: z.array(z.string()).optional().describe("Names of other fragments this fragment depends on"),
12
+ error: z.string().optional().describe("Error message if fragment not found")
13
+ };
@@ -0,0 +1 @@
1
+ export declare const getFragmentSourceTool: any;
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
4
+ import {
5
+ getFragmentSourceOutputSchema
6
+ } from "./types.js";
7
+ export const getFragmentSourceTool = defineMcpTool({
8
+ name: "fragments-get-source",
9
+ title: "Get Fragment Source",
10
+ description: "Get the raw GraphQL source code of a fragment. By default returns just the fragment source. Set includeDependencies to true to include all fragment definitions this fragment depends on.",
11
+ annotations: {
12
+ readOnlyHint: true,
13
+ destructiveHint: false,
14
+ idempotentHint: true,
15
+ openWorldHint: false
16
+ },
17
+ inputSchema: {
18
+ fragmentName: z.string().describe("The name of the GraphQL fragment to get the source for"),
19
+ includeDependencies: z.boolean().optional().default(false).describe(
20
+ "If true, includes all fragment definitions this fragment depends on. Default is false."
21
+ )
22
+ },
23
+ outputSchema: getFragmentSourceOutputSchema,
24
+ handler: async ({ fragmentName, includeDependencies }) => {
25
+ const response = await fetchFromMcpHandler(
26
+ "fragments-get-source",
27
+ { name: fragmentName, includeDependencies: includeDependencies ?? false }
28
+ );
29
+ if (response.error) {
30
+ return structuredResult({ error: response.error });
31
+ }
32
+ return structuredResult({ source: response.source });
33
+ }
34
+ });
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ export declare const GetFragmentSourceResponseSchema: z.ZodObject<{
3
+ source: z.ZodNullable<z.ZodString>;
4
+ error: z.ZodOptional<z.ZodString>;
5
+ }, z.core.$strip>;
6
+ export declare const getFragmentSourceOutputSchema: {
7
+ source: z.ZodOptional<z.ZodString>;
8
+ error: z.ZodOptional<z.ZodString>;
9
+ };
10
+ export type GetFragmentSourceResponse = z.infer<typeof GetFragmentSourceResponseSchema>;
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ export const GetFragmentSourceResponseSchema = z.object({
3
+ source: z.string().nullable().describe("The GraphQL source code of the fragment"),
4
+ error: z.string().optional().describe("Error message if fragment not found")
5
+ });
6
+ export const getFragmentSourceOutputSchema = {
7
+ source: z.string().optional().describe("The GraphQL source code of the fragment"),
8
+ error: z.string().optional().describe("Error message if fragment not found")
9
+ };
@@ -0,0 +1 @@
1
+ export declare const listFragmentsTool: any;
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
4
+ import { listFragmentsOutputSchema } from "./types.js";
5
+ export const listFragmentsTool = defineMcpTool({
6
+ name: "fragments-list",
7
+ title: "List Fragments",
8
+ description: "List all GraphQL fragments available in the project. Returns fragment names, the types they are defined on, and file paths.",
9
+ annotations: {
10
+ readOnlyHint: true,
11
+ destructiveHint: false,
12
+ idempotentHint: true,
13
+ openWorldHint: false
14
+ },
15
+ inputSchema: {
16
+ nameFilter: z.string().optional().describe(
17
+ 'Optional filter to match fragment names. Can be a plain string for substring matching or a regex pattern (e.g., "^User" to match names starting with "User")'
18
+ )
19
+ },
20
+ outputSchema: listFragmentsOutputSchema,
21
+ handler: async ({ nameFilter }) => {
22
+ const response = await fetchFromMcpHandler(
23
+ "fragments-list",
24
+ { nameFilter }
25
+ );
26
+ const summary = response.fragments.map((frag) => ({
27
+ name: frag.name,
28
+ typeName: frag.typeName,
29
+ filePath: frag.relativeFilePath
30
+ }));
31
+ return structuredResult({
32
+ count: response.fragments.length,
33
+ fragments: summary
34
+ });
35
+ }
36
+ });
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ export declare const ListFragmentsResponseSchema: z.ZodObject<{
3
+ fragments: z.ZodArray<z.ZodObject<{
4
+ name: z.ZodString;
5
+ typeName: z.ZodString;
6
+ filePath: z.ZodString;
7
+ relativeFilePath: z.ZodString;
8
+ source: z.ZodString;
9
+ dependencies: z.ZodArray<z.ZodString>;
10
+ }, z.core.$strip>>;
11
+ }, z.core.$strip>;
12
+ export declare const listFragmentsOutputSchema: {
13
+ count: z.ZodNumber;
14
+ fragments: z.ZodArray<z.ZodObject<{
15
+ name: z.ZodString;
16
+ typeName: z.ZodString;
17
+ filePath: z.ZodString;
18
+ }, z.core.$strip>>;
19
+ };
20
+ export type ListFragmentsResponse = z.infer<typeof ListFragmentsResponseSchema>;
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ import { FragmentInfoSchema } from "../fragments-list-for-type/types.js";
3
+ export const ListFragmentsResponseSchema = z.object({
4
+ fragments: z.array(FragmentInfoSchema)
5
+ });
6
+ const FragmentSummaryMcpSchema = z.object({
7
+ name: z.string().describe("Fragment name"),
8
+ typeName: z.string().describe("The GraphQL type this fragment is defined on"),
9
+ filePath: z.string().describe("Path to the file relative to the project root")
10
+ });
11
+ export const listFragmentsOutputSchema = {
12
+ count: z.number().describe("Total number of fragments"),
13
+ fragments: z.array(FragmentSummaryMcpSchema).describe("List of all fragments")
14
+ };
@@ -0,0 +1 @@
1
+ export declare const getFragmentsForTypeTool: any;
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
4
+ import {
5
+ getFragmentsForTypeOutputSchema
6
+ } from "./types.js";
7
+ export const getFragmentsForTypeTool = defineMcpTool({
8
+ name: "fragments-list-for-type",
9
+ title: "List Fragments for Type",
10
+ description: "Get all GraphQL fragments defined for a specific type. Returns fragment names, file paths, and dependencies on other fragments. Use fragments-get-source to get the GraphQL source code.",
11
+ annotations: {
12
+ readOnlyHint: true,
13
+ destructiveHint: false,
14
+ idempotentHint: true,
15
+ openWorldHint: false
16
+ },
17
+ inputSchema: {
18
+ typeName: z.string().describe(
19
+ 'The name of the GraphQL type to get fragments for (e.g., "User", "Post")'
20
+ )
21
+ },
22
+ outputSchema: getFragmentsForTypeOutputSchema,
23
+ handler: async ({ typeName }) => {
24
+ const response = await fetchFromMcpHandler(
25
+ "fragments-list-for-type",
26
+ { name: typeName }
27
+ );
28
+ if (response.error) {
29
+ return structuredResult({ fragments: [], error: response.error });
30
+ }
31
+ const fragments = response.fragments.map((frag) => ({
32
+ name: frag.name,
33
+ typeName: frag.typeName,
34
+ filePath: frag.relativeFilePath,
35
+ dependencies: frag.dependencies
36
+ }));
37
+ return structuredResult({ fragments });
38
+ }
39
+ });
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ export declare const FragmentInfoSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ typeName: z.ZodString;
5
+ filePath: z.ZodString;
6
+ relativeFilePath: z.ZodString;
7
+ source: z.ZodString;
8
+ dependencies: z.ZodArray<z.ZodString>;
9
+ }, z.core.$strip>;
10
+ export declare const GetFragmentsForTypeResponseSchema: z.ZodObject<{
11
+ fragments: z.ZodArray<z.ZodObject<{
12
+ name: z.ZodString;
13
+ typeName: z.ZodString;
14
+ filePath: z.ZodString;
15
+ relativeFilePath: z.ZodString;
16
+ source: z.ZodString;
17
+ dependencies: z.ZodArray<z.ZodString>;
18
+ }, z.core.$strip>>;
19
+ error: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>;
21
+ export declare const getFragmentsForTypeOutputSchema: {
22
+ fragments: z.ZodArray<z.ZodObject<{
23
+ name: z.ZodString;
24
+ typeName: z.ZodString;
25
+ filePath: z.ZodString;
26
+ dependencies: z.ZodArray<z.ZodString>;
27
+ }, z.core.$strip>>;
28
+ error: z.ZodOptional<z.ZodString>;
29
+ };
30
+ export type FragmentInfo = z.infer<typeof FragmentInfoSchema>;
31
+ export type GetFragmentsForTypeResponse = z.infer<typeof GetFragmentsForTypeResponseSchema>;