nuxt-graphql-middleware 5.2.2 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/client/200.html +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/CqRv5mwS.js +2 -0
- package/dist/client/_nuxt/{DKGPmQRi.js → D95LLO0l.js} +1 -1
- package/dist/client/_nuxt/DZ-uq6Vd.js +1 -0
- package/dist/client/_nuxt/DrXVleME.js +4 -0
- package/dist/client/_nuxt/{CLvFsrJf.js → Dx-h1-qv.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/f3f3372e-493e-4c8e-9dbd-18d4c5406f44.json +1 -0
- package/dist/client/_nuxt/{entry.DUAtNXP_.css → entry.Cyocd7ae.css} +1 -1
- package/dist/client/_nuxt/error-404.BLrjNXsr.css +1 -0
- package/dist/client/_nuxt/error-500.DLkAwcfL.css +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.d.mts +1 -1
- package/dist/module.json +3 -3
- package/dist/module.mjs +1526 -70
- package/dist/runtime/components/CodeFrame.d.vue.ts +8 -0
- package/dist/runtime/components/CodeFrame.vue.d.ts +2 -1
- package/dist/runtime/components/DevModeOverlay.d.vue.ts +4 -0
- package/dist/runtime/components/DevModeOverlay.vue +1 -1
- package/dist/runtime/components/DevModeOverlay.vue.d.ts +2 -1
- package/dist/runtime/components/ErrorExtensions.d.vue.ts +6 -0
- package/dist/runtime/components/ErrorExtensions.vue.d.ts +2 -1
- package/dist/runtime/components/ErrorGroup.d.vue.ts +10 -0
- package/dist/runtime/components/ErrorGroup.vue.d.ts +2 -1
- package/dist/runtime/css/output.css +1 -1
- package/dist/runtime/helpers/composables.d.ts +1 -40
- package/dist/runtime/helpers/composables.js +3 -12
- package/dist/runtime/helpers/shared-types.d.ts +40 -0
- package/dist/runtime/helpers/shared-types.js +12 -0
- package/dist/runtime/server/api/doRequest.d.ts +2 -0
- package/dist/runtime/server/api/doRequest.js +18 -0
- package/dist/runtime/server/helpers/index.js +1 -1
- package/dist/runtime/server/mcp/index.d.ts +2 -0
- package/dist/runtime/server/mcp/index.js +63 -0
- package/dist/runtime/server/mcp/resources/docs.d.ts +2 -0
- package/dist/runtime/server/mcp/resources/docs.js +36 -0
- package/dist/runtime/server/mcp/tools/fragments-get/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/fragments-get/index.js +35 -0
- package/dist/runtime/server/mcp/tools/fragments-get/types.d.ts +20 -0
- package/dist/runtime/server/mcp/tools/fragments-get/types.js +13 -0
- package/dist/runtime/server/mcp/tools/fragments-get-source/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/fragments-get-source/index.js +34 -0
- package/dist/runtime/server/mcp/tools/fragments-get-source/types.d.ts +10 -0
- package/dist/runtime/server/mcp/tools/fragments-get-source/types.js +9 -0
- package/dist/runtime/server/mcp/tools/fragments-list/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/fragments-list/index.js +36 -0
- package/dist/runtime/server/mcp/tools/fragments-list/types.d.ts +20 -0
- package/dist/runtime/server/mcp/tools/fragments-list/types.js +14 -0
- package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.js +39 -0
- package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.d.ts +31 -0
- package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.js +23 -0
- package/dist/runtime/server/mcp/tools/graphql-execute/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/graphql-execute/index.js +59 -0
- package/dist/runtime/server/mcp/tools/module-get-config/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/module-get-config/index.js +23 -0
- package/dist/runtime/server/mcp/tools/module-get-config/types.d.ts +39 -0
- package/dist/runtime/server/mcp/tools/module-get-config/types.js +26 -0
- package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.js +36 -0
- package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.d.ts +49 -0
- package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.js +24 -0
- package/dist/runtime/server/mcp/tools/operations-execute/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/operations-execute/index.js +63 -0
- package/dist/runtime/server/mcp/tools/operations-get/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/operations-get/index.js +40 -0
- package/dist/runtime/server/mcp/tools/operations-get/types.d.ts +32 -0
- package/dist/runtime/server/mcp/tools/operations-get/types.js +18 -0
- package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.js +39 -0
- package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.d.ts +38 -0
- package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.js +19 -0
- package/dist/runtime/server/mcp/tools/operations-get-source/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/operations-get-source/index.js +39 -0
- package/dist/runtime/server/mcp/tools/operations-get-source/types.d.ts +10 -0
- package/dist/runtime/server/mcp/tools/operations-get-source/types.js +9 -0
- package/dist/runtime/server/mcp/tools/operations-list/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/operations-list/index.js +46 -0
- package/dist/runtime/server/mcp/tools/operations-list/types.d.ts +53 -0
- package/dist/runtime/server/mcp/tools/operations-list/types.js +33 -0
- package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.js +37 -0
- package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.d.ts +24 -0
- package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.js +16 -0
- package/dist/runtime/server/mcp/tools/schema-get-type/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-get-type/index.js +31 -0
- package/dist/runtime/server/mcp/tools/schema-get-type/types.d.ts +112 -0
- package/dist/runtime/server/mcp/tools/schema-get-type/types.js +45 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.js +33 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.d.ts +10 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.js +9 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.js +35 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.d.ts +39 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.js +17 -0
- package/dist/runtime/server/mcp/tools/schema-get-union-members/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-get-union-members/index.js +35 -0
- package/dist/runtime/server/mcp/tools/schema-get-union-members/types.d.ts +24 -0
- package/dist/runtime/server/mcp/tools/schema-get-union-members/types.js +16 -0
- package/dist/runtime/server/mcp/tools/schema-list-types/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-list-types/index.js +37 -0
- package/dist/runtime/server/mcp/tools/schema-list-types/types.d.ts +53 -0
- package/dist/runtime/server/mcp/tools/schema-list-types/types.js +21 -0
- package/dist/runtime/server/mcp/tools/schema-validate-document/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-validate-document/index.js +31 -0
- package/dist/runtime/server/mcp/tools/schema-validate-document/types.d.ts +26 -0
- package/dist/runtime/server/mcp/tools/schema-validate-document/types.js +21 -0
- package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.js +36 -0
- package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.d.ts +49 -0
- package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.js +24 -0
- package/dist/runtime/server/mcp/utils/index.d.ts +48 -0
- package/dist/runtime/server/mcp/utils/index.js +35 -0
- package/dist/runtime/server/utils/useGraphqlMutation.d.ts +1 -1
- package/dist/runtime/server/utils/useGraphqlMutation.js +1 -1
- package/dist/runtime/server/utils/useGraphqlQuery.d.ts +1 -1
- package/dist/runtime/server/utils/useGraphqlQuery.js +1 -1
- package/dist/runtime/types.d.ts +1 -1
- package/dist/shared/{nuxt-graphql-middleware.ct2xvPoD.d.mts → nuxt-graphql-middleware.COufMnWs.d.mts} +119 -2
- package/dist/utils.d.mts +1 -1
- package/docs/composables/useAsyncGraphqlQuery.md +313 -0
- package/docs/composables/useGraphqlMutation.md +29 -0
- package/docs/composables/useGraphqlQuery.md +73 -0
- package/docs/composables/useGraphqlState.md +58 -0
- package/docs/composables/useGraphqlUploadMutation.md +57 -0
- package/docs/configuration/client-options.md +121 -0
- package/docs/configuration/module-hooks.md +112 -0
- package/docs/configuration/module-utils.md +53 -0
- package/docs/configuration/module.md +415 -0
- package/docs/configuration/runtime-config.md +23 -0
- package/docs/configuration/server-options.md +230 -0
- package/package.json +102 -44
- package/dist/client/_nuxt/CKZE-Gmz.js +0 -2
- package/dist/client/_nuxt/CYCWsMRt.js +0 -1
- package/dist/client/_nuxt/DPP_zJIh.js +0 -25
- package/dist/client/_nuxt/builds/meta/1a5c6b94-502b-4ab8-a5c9-f955b10f2b06.json +0 -1
- package/dist/client/_nuxt/error-404.DlVPZ4GE.css +0 -1
- package/dist/client/_nuxt/error-500.DjyirMQI.css +0 -1
- package/dist/runtime/server/tsconfig.json +0 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineMcpTool } from "#imports";
|
|
3
|
+
import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
|
|
4
|
+
import {
|
|
5
|
+
getUnionMembersOutputSchema
|
|
6
|
+
} from "./types.js";
|
|
7
|
+
export const getUnionMembersTool = defineMcpTool({
|
|
8
|
+
name: "schema-get-union-members",
|
|
9
|
+
title: "Get Union Members",
|
|
10
|
+
description: "Get all types that are members of a GraphQL union. Returns the member type names and descriptions.",
|
|
11
|
+
annotations: {
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
destructiveHint: false,
|
|
14
|
+
idempotentHint: true,
|
|
15
|
+
openWorldHint: false
|
|
16
|
+
},
|
|
17
|
+
inputSchema: {
|
|
18
|
+
unionName: z.string().describe('The name of the GraphQL union (e.g., "SearchResult")')
|
|
19
|
+
},
|
|
20
|
+
outputSchema: getUnionMembersOutputSchema,
|
|
21
|
+
handler: async ({ unionName }) => {
|
|
22
|
+
const response = await fetchFromMcpHandler(
|
|
23
|
+
"schema-get-union-members",
|
|
24
|
+
{ name: unionName }
|
|
25
|
+
);
|
|
26
|
+
if (response.error) {
|
|
27
|
+
return structuredResult({ error: response.error });
|
|
28
|
+
}
|
|
29
|
+
return structuredResult({
|
|
30
|
+
unionName: response.unionName,
|
|
31
|
+
count: response.members.length,
|
|
32
|
+
members: response.members
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const UnionMemberSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
description: z.ZodNullable<z.ZodString>;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const GetUnionMembersResponseSchema: z.ZodObject<{
|
|
7
|
+
unionName: z.ZodString;
|
|
8
|
+
members: z.ZodArray<z.ZodObject<{
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
description: z.ZodNullable<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>>;
|
|
12
|
+
error: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const getUnionMembersOutputSchema: {
|
|
15
|
+
unionName: z.ZodOptional<z.ZodString>;
|
|
16
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
members: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
description: z.ZodNullable<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>>>;
|
|
21
|
+
error: z.ZodOptional<z.ZodString>;
|
|
22
|
+
};
|
|
23
|
+
export type UnionMember = z.infer<typeof UnionMemberSchema>;
|
|
24
|
+
export type GetUnionMembersResponse = z.infer<typeof GetUnionMembersResponseSchema>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const UnionMemberSchema = z.object({
|
|
3
|
+
name: z.string().describe("Type name"),
|
|
4
|
+
description: z.string().nullable().describe("Type description")
|
|
5
|
+
});
|
|
6
|
+
export const GetUnionMembersResponseSchema = z.object({
|
|
7
|
+
unionName: z.string().describe("The union name"),
|
|
8
|
+
members: z.array(UnionMemberSchema),
|
|
9
|
+
error: z.string().optional().describe("Error message if union not found")
|
|
10
|
+
});
|
|
11
|
+
export const getUnionMembersOutputSchema = {
|
|
12
|
+
unionName: z.string().optional().describe("The union name"),
|
|
13
|
+
count: z.number().optional().describe("Number of union members"),
|
|
14
|
+
members: z.array(UnionMemberSchema).optional().describe("Types that are part of the union"),
|
|
15
|
+
error: z.string().optional().describe("Error message if union not found")
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const listSchemaTypesTool: any;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineMcpTool } from "#imports";
|
|
3
|
+
import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
|
|
4
|
+
import {
|
|
5
|
+
listSchemaTypesOutputSchema
|
|
6
|
+
} from "./types.js";
|
|
7
|
+
export const listSchemaTypesTool = defineMcpTool({
|
|
8
|
+
name: "schema-list-types",
|
|
9
|
+
title: "List Schema Types",
|
|
10
|
+
description: "List all types in the GraphQL schema. Can be filtered by kind (OBJECT, INPUT_OBJECT, ENUM, UNION, INTERFACE, SCALAR). Returns type names, kinds, and descriptions.",
|
|
11
|
+
annotations: {
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
destructiveHint: false,
|
|
14
|
+
idempotentHint: true,
|
|
15
|
+
openWorldHint: false
|
|
16
|
+
},
|
|
17
|
+
inputSchema: {
|
|
18
|
+
kind: z.enum(["OBJECT", "INPUT_OBJECT", "ENUM", "UNION", "INTERFACE", "SCALAR"]).optional().describe(
|
|
19
|
+
"Optional filter by type kind. If not provided, returns all types."
|
|
20
|
+
)
|
|
21
|
+
},
|
|
22
|
+
outputSchema: listSchemaTypesOutputSchema,
|
|
23
|
+
handler: async ({ kind }) => {
|
|
24
|
+
const params = {};
|
|
25
|
+
if (kind) {
|
|
26
|
+
params.kind = kind;
|
|
27
|
+
}
|
|
28
|
+
const response = await fetchFromMcpHandler(
|
|
29
|
+
"schema-list-types",
|
|
30
|
+
Object.keys(params).length > 0 ? params : void 0
|
|
31
|
+
);
|
|
32
|
+
return structuredResult({
|
|
33
|
+
count: response.types.length,
|
|
34
|
+
types: response.types
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SchemaTypeKindFilterSchema: z.ZodEnum<{
|
|
3
|
+
OBJECT: "OBJECT";
|
|
4
|
+
INPUT_OBJECT: "INPUT_OBJECT";
|
|
5
|
+
ENUM: "ENUM";
|
|
6
|
+
UNION: "UNION";
|
|
7
|
+
INTERFACE: "INTERFACE";
|
|
8
|
+
SCALAR: "SCALAR";
|
|
9
|
+
}>;
|
|
10
|
+
export declare const SchemaTypeSummarySchema: z.ZodObject<{
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
kind: z.ZodEnum<{
|
|
13
|
+
OBJECT: "OBJECT";
|
|
14
|
+
INPUT_OBJECT: "INPUT_OBJECT";
|
|
15
|
+
ENUM: "ENUM";
|
|
16
|
+
UNION: "UNION";
|
|
17
|
+
INTERFACE: "INTERFACE";
|
|
18
|
+
SCALAR: "SCALAR";
|
|
19
|
+
}>;
|
|
20
|
+
description: z.ZodNullable<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export declare const ListSchemaTypesResponseSchema: z.ZodObject<{
|
|
23
|
+
types: z.ZodArray<z.ZodObject<{
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
kind: z.ZodEnum<{
|
|
26
|
+
OBJECT: "OBJECT";
|
|
27
|
+
INPUT_OBJECT: "INPUT_OBJECT";
|
|
28
|
+
ENUM: "ENUM";
|
|
29
|
+
UNION: "UNION";
|
|
30
|
+
INTERFACE: "INTERFACE";
|
|
31
|
+
SCALAR: "SCALAR";
|
|
32
|
+
}>;
|
|
33
|
+
description: z.ZodNullable<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export declare const listSchemaTypesOutputSchema: {
|
|
37
|
+
count: z.ZodNumber;
|
|
38
|
+
types: z.ZodArray<z.ZodObject<{
|
|
39
|
+
name: z.ZodString;
|
|
40
|
+
kind: z.ZodEnum<{
|
|
41
|
+
OBJECT: "OBJECT";
|
|
42
|
+
INPUT_OBJECT: "INPUT_OBJECT";
|
|
43
|
+
ENUM: "ENUM";
|
|
44
|
+
UNION: "UNION";
|
|
45
|
+
INTERFACE: "INTERFACE";
|
|
46
|
+
SCALAR: "SCALAR";
|
|
47
|
+
}>;
|
|
48
|
+
description: z.ZodNullable<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>>;
|
|
50
|
+
};
|
|
51
|
+
export type SchemaTypeKindFilter = z.infer<typeof SchemaTypeKindFilterSchema>;
|
|
52
|
+
export type SchemaTypeSummary = z.infer<typeof SchemaTypeSummarySchema>;
|
|
53
|
+
export type ListSchemaTypesResponse = z.infer<typeof ListSchemaTypesResponseSchema>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const SchemaTypeKindFilterSchema = z.enum([
|
|
3
|
+
"OBJECT",
|
|
4
|
+
"INPUT_OBJECT",
|
|
5
|
+
"ENUM",
|
|
6
|
+
"UNION",
|
|
7
|
+
"INTERFACE",
|
|
8
|
+
"SCALAR"
|
|
9
|
+
]);
|
|
10
|
+
export const SchemaTypeSummarySchema = z.object({
|
|
11
|
+
name: z.string().describe("Type name"),
|
|
12
|
+
kind: SchemaTypeKindFilterSchema.describe("The kind of GraphQL type"),
|
|
13
|
+
description: z.string().nullable().describe("Type description")
|
|
14
|
+
});
|
|
15
|
+
export const ListSchemaTypesResponseSchema = z.object({
|
|
16
|
+
types: z.array(SchemaTypeSummarySchema)
|
|
17
|
+
});
|
|
18
|
+
export const listSchemaTypesOutputSchema = {
|
|
19
|
+
count: z.number().describe("Total number of types"),
|
|
20
|
+
types: z.array(SchemaTypeSummarySchema).describe("List of schema types")
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const validateDocumentTool: any;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineMcpTool } from "#imports";
|
|
3
|
+
import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
|
|
4
|
+
import {
|
|
5
|
+
validateDocumentOutputSchema
|
|
6
|
+
} from "./types.js";
|
|
7
|
+
export const validateDocumentTool = defineMcpTool({
|
|
8
|
+
name: "schema-validate-document",
|
|
9
|
+
title: "Validate Document",
|
|
10
|
+
description: "Validate a raw GraphQL document against the schema. Checks for syntax errors, unknown fields, type mismatches, and other validation issues. Use this to verify a GraphQL query, mutation, or fragment before saving it to a file.",
|
|
11
|
+
annotations: {
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
destructiveHint: false,
|
|
14
|
+
idempotentHint: true,
|
|
15
|
+
openWorldHint: false
|
|
16
|
+
},
|
|
17
|
+
inputSchema: {
|
|
18
|
+
document: z.string().describe("The raw GraphQL document source to validate")
|
|
19
|
+
},
|
|
20
|
+
outputSchema: validateDocumentOutputSchema,
|
|
21
|
+
handler: async (args) => {
|
|
22
|
+
const response = await fetchFromMcpHandler(
|
|
23
|
+
"schema-validate-document",
|
|
24
|
+
{ document: args.document }
|
|
25
|
+
);
|
|
26
|
+
return structuredResult({
|
|
27
|
+
valid: response.valid,
|
|
28
|
+
errors: response.errors
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ValidateDocumentRequestSchema: z.ZodObject<{
|
|
3
|
+
document: z.ZodString;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export declare const ValidateDocumentResponseSchema: z.ZodObject<{
|
|
6
|
+
valid: z.ZodBoolean;
|
|
7
|
+
errors: z.ZodArray<z.ZodObject<{
|
|
8
|
+
message: z.ZodString;
|
|
9
|
+
locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
10
|
+
line: z.ZodNumber;
|
|
11
|
+
column: z.ZodNumber;
|
|
12
|
+
}, z.core.$strip>>>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const validateDocumentOutputSchema: {
|
|
16
|
+
valid: z.ZodBoolean;
|
|
17
|
+
errors: z.ZodArray<z.ZodObject<{
|
|
18
|
+
message: z.ZodString;
|
|
19
|
+
locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
20
|
+
line: z.ZodNumber;
|
|
21
|
+
column: z.ZodNumber;
|
|
22
|
+
}, z.core.$strip>>>;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
};
|
|
25
|
+
export type ValidateDocumentRequest = z.infer<typeof ValidateDocumentRequestSchema>;
|
|
26
|
+
export type ValidateDocumentResponse = z.infer<typeof ValidateDocumentResponseSchema>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const ValidateDocumentRequestSchema = z.object({
|
|
3
|
+
document: z.string().describe("The raw GraphQL document source to validate")
|
|
4
|
+
});
|
|
5
|
+
const ValidationErrorSchema = z.object({
|
|
6
|
+
message: z.string().describe("The error message"),
|
|
7
|
+
locations: z.array(
|
|
8
|
+
z.object({
|
|
9
|
+
line: z.number().describe("Line number (1-indexed)"),
|
|
10
|
+
column: z.number().describe("Column number (1-indexed)")
|
|
11
|
+
})
|
|
12
|
+
).optional().describe("Source locations where the error occurred")
|
|
13
|
+
});
|
|
14
|
+
export const ValidateDocumentResponseSchema = z.object({
|
|
15
|
+
valid: z.boolean().describe("Whether the document is valid"),
|
|
16
|
+
errors: z.array(ValidationErrorSchema).describe("List of validation errors, empty if valid")
|
|
17
|
+
});
|
|
18
|
+
export const validateDocumentOutputSchema = {
|
|
19
|
+
valid: z.boolean().describe("Whether the document is valid"),
|
|
20
|
+
errors: z.array(ValidationErrorSchema).describe("List of validation errors, empty if valid")
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const vueGraphqlComposableExampleTool: 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 {
|
|
5
|
+
composableExamplesOutputSchema
|
|
6
|
+
} from "./types.js";
|
|
7
|
+
export const vueGraphqlComposableExampleTool = defineMcpTool({
|
|
8
|
+
name: "vue-graphql-composable-example",
|
|
9
|
+
title: "Vue GraphQL Composable Examples",
|
|
10
|
+
description: "Generate usage examples for Vue composables (useGraphqlQuery, useAsyncGraphqlQuery, useGraphqlMutation, etc.) for a specific GraphQL operation. Returns code examples with mock variable data.",
|
|
11
|
+
annotations: {
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
destructiveHint: false,
|
|
14
|
+
idempotentHint: true,
|
|
15
|
+
openWorldHint: false
|
|
16
|
+
},
|
|
17
|
+
inputSchema: {
|
|
18
|
+
operationName: z.string().describe(
|
|
19
|
+
'The name of the GraphQL operation to generate examples for (e.g., "getUsers", "createPost")'
|
|
20
|
+
)
|
|
21
|
+
},
|
|
22
|
+
outputSchema: composableExamplesOutputSchema,
|
|
23
|
+
handler: async ({ operationName }) => {
|
|
24
|
+
const response = await fetchFromMcpHandler(
|
|
25
|
+
"vue-graphql-composable-example",
|
|
26
|
+
{ name: operationName }
|
|
27
|
+
);
|
|
28
|
+
if (response.error) {
|
|
29
|
+
return structuredResult({ error: response.error });
|
|
30
|
+
}
|
|
31
|
+
return structuredResult({
|
|
32
|
+
examples: response.examples,
|
|
33
|
+
imports: response.imports
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Schema for a single usage example.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ComposableExampleSchema: z.ZodObject<{
|
|
6
|
+
code: z.ZodString;
|
|
7
|
+
description: z.ZodString;
|
|
8
|
+
documentationUrl: z.ZodString;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
/**
|
|
11
|
+
* Schema for an import entry.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ImportEntrySchema: z.ZodObject<{
|
|
14
|
+
typeName: z.ZodString;
|
|
15
|
+
description: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
/**
|
|
18
|
+
* Response schema for the handler.
|
|
19
|
+
*/
|
|
20
|
+
export declare const GetComposableExamplesResponseSchema: z.ZodObject<{
|
|
21
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
22
|
+
code: z.ZodString;
|
|
23
|
+
description: z.ZodString;
|
|
24
|
+
documentationUrl: z.ZodString;
|
|
25
|
+
}, z.core.$strip>>>;
|
|
26
|
+
imports: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
27
|
+
typeName: z.ZodString;
|
|
28
|
+
description: z.ZodString;
|
|
29
|
+
}, z.core.$strip>>>;
|
|
30
|
+
error: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
/**
|
|
33
|
+
* MCP output schema.
|
|
34
|
+
*/
|
|
35
|
+
export declare const composableExamplesOutputSchema: {
|
|
36
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
37
|
+
code: z.ZodString;
|
|
38
|
+
description: z.ZodString;
|
|
39
|
+
documentationUrl: z.ZodString;
|
|
40
|
+
}, z.core.$strip>>>;
|
|
41
|
+
imports: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
42
|
+
typeName: z.ZodString;
|
|
43
|
+
description: z.ZodString;
|
|
44
|
+
}, z.core.$strip>>>;
|
|
45
|
+
error: z.ZodOptional<z.ZodString>;
|
|
46
|
+
};
|
|
47
|
+
export type ComposableExample = z.infer<typeof ComposableExampleSchema>;
|
|
48
|
+
export type ImportEntry = z.infer<typeof ImportEntrySchema>;
|
|
49
|
+
export type GetComposableExamplesResponse = z.infer<typeof GetComposableExamplesResponseSchema>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const ComposableExampleSchema = z.object({
|
|
3
|
+
code: z.string().describe("The code example showing how to use the composable"),
|
|
4
|
+
description: z.string().describe("A description of what this example demonstrates"),
|
|
5
|
+
documentationUrl: z.string().describe("URL to the documentation for this composable")
|
|
6
|
+
});
|
|
7
|
+
export const ImportEntrySchema = z.object({
|
|
8
|
+
typeName: z.string().describe("The name of the type to import"),
|
|
9
|
+
description: z.string().describe(
|
|
10
|
+
'What this type is used for (e.g., "Variables type", "Response type", "Input type", "Enum type")'
|
|
11
|
+
)
|
|
12
|
+
});
|
|
13
|
+
export const GetComposableExamplesResponseSchema = z.object({
|
|
14
|
+
examples: z.array(ComposableExampleSchema).optional(),
|
|
15
|
+
imports: z.array(ImportEntrySchema).optional(),
|
|
16
|
+
error: z.string().optional()
|
|
17
|
+
});
|
|
18
|
+
export const composableExamplesOutputSchema = {
|
|
19
|
+
examples: z.array(ComposableExampleSchema).optional().describe("Array of usage examples for the operation"),
|
|
20
|
+
imports: z.array(ImportEntrySchema).optional().describe(
|
|
21
|
+
"Array of types that can be imported from #graphql-operations for this operation"
|
|
22
|
+
),
|
|
23
|
+
error: z.string().optional().describe("Error message if the operation was not found")
|
|
24
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { GraphqlServerResponse } from '../../../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Shared Zod schema for GraphQL errors.
|
|
5
|
+
*/
|
|
6
|
+
export declare const GraphqlErrorSchema: z.ZodObject<{
|
|
7
|
+
message: z.ZodString;
|
|
8
|
+
locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
9
|
+
line: z.ZodNumber;
|
|
10
|
+
column: z.ZodNumber;
|
|
11
|
+
}, z.core.$strip>>>;
|
|
12
|
+
path: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
13
|
+
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
/**
|
|
16
|
+
* Shared output schema for GraphQL execution results.
|
|
17
|
+
*/
|
|
18
|
+
export declare const graphqlExecutionOutputSchema: {
|
|
19
|
+
data: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
|
+
errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
21
|
+
message: z.ZodString;
|
|
22
|
+
locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
23
|
+
line: z.ZodNumber;
|
|
24
|
+
column: z.ZodNumber;
|
|
25
|
+
}, z.core.$strip>>>;
|
|
26
|
+
path: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
27
|
+
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
28
|
+
}, z.core.$strip>>>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Extracts GraphQL error response from a fetch error.
|
|
32
|
+
*/
|
|
33
|
+
export declare function extractErrorResponse(e: unknown): GraphqlServerResponse<any> | null;
|
|
34
|
+
/**
|
|
35
|
+
* Fetches data from the MCP dev handler using POST.
|
|
36
|
+
*/
|
|
37
|
+
export declare function fetchFromMcpHandler<T>(tool: string, params?: Record<string, unknown>): Promise<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates an MCP tool result with both content (for backwards compatibility)
|
|
40
|
+
* and structuredContent (required when outputSchema is defined).
|
|
41
|
+
*/
|
|
42
|
+
export declare function structuredResult<T extends Record<string, unknown>>(data: T): {
|
|
43
|
+
content: {
|
|
44
|
+
type: "text";
|
|
45
|
+
text: string;
|
|
46
|
+
}[];
|
|
47
|
+
structuredContent: T;
|
|
48
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { devServerUrl } from "#nuxt-graphql-middleware/mcp";
|
|
3
|
+
export const GraphqlErrorSchema = z.object({
|
|
4
|
+
message: z.string().describe("The error message"),
|
|
5
|
+
locations: z.array(
|
|
6
|
+
z.object({
|
|
7
|
+
line: z.number().describe("Line number"),
|
|
8
|
+
column: z.number().describe("Column number")
|
|
9
|
+
})
|
|
10
|
+
).optional().describe("Source locations where the error occurred"),
|
|
11
|
+
path: z.array(z.union([z.string(), z.number()])).optional().describe("Path to the field that caused the error"),
|
|
12
|
+
extensions: z.record(z.string(), z.unknown()).optional().describe("Additional error metadata")
|
|
13
|
+
});
|
|
14
|
+
export const graphqlExecutionOutputSchema = {
|
|
15
|
+
data: z.record(z.string(), z.unknown()).nullable().describe("The GraphQL response data, or null if the request failed"),
|
|
16
|
+
errors: z.array(GraphqlErrorSchema).optional().describe("GraphQL errors if any occurred")
|
|
17
|
+
};
|
|
18
|
+
export function extractErrorResponse(e) {
|
|
19
|
+
if (typeof e === "object" && e && "response" in e && e.response && typeof e.response === "object" && "_data" in e.response && typeof e.response._data === "object") {
|
|
20
|
+
return e.response._data;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
export async function fetchFromMcpHandler(tool, params) {
|
|
25
|
+
return await $fetch(`${devServerUrl}/__nuxt_graphql_middleware/mcp`, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
body: { tool, ...params }
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function structuredResult(data) {
|
|
31
|
+
return {
|
|
32
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
33
|
+
structuredContent: data
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
|
|
2
|
-
import { type GetMutationArgs, type MutationObjectArgs, type GetMutationResult } from './../../helpers/
|
|
2
|
+
import { type GetMutationArgs, type MutationObjectArgs, type GetMutationResult } from './../../helpers/shared-types.js';
|
|
3
3
|
import type { Mutation } from '#nuxt-graphql-middleware/operation-types';
|
|
4
4
|
/**
|
|
5
5
|
* Performs a GraphQL mutation.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
encodeContext
|
|
3
|
-
} from "./../../helpers/
|
|
3
|
+
} from "./../../helpers/shared-types.js";
|
|
4
4
|
import { performRequest } from "./index.js";
|
|
5
5
|
export function useGraphqlMutation(...args) {
|
|
6
6
|
const [name, body, fetchOptions = {}, clientContext = {}] = typeof args[0] === "string" ? [args[0], args[1], args[2]?.fetchOptions, args[2]?.clientContext] : [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
|
|
2
|
-
import { type GetQueryArgs, type QueryObjectArgs, type GetQueryResult } from './../../helpers/
|
|
2
|
+
import { type GetQueryArgs, type QueryObjectArgs, type GetQueryResult } from './../../helpers/shared-types.js';
|
|
3
3
|
import type { Query } from '#nuxt-graphql-middleware/operation-types';
|
|
4
4
|
/**
|
|
5
5
|
* Performs a GraphQL query.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
encodeContext
|
|
3
|
-
} from "./../../helpers/
|
|
3
|
+
} from "./../../helpers/shared-types.js";
|
|
4
4
|
import { encodeVariables } from "./../../helpers/queryEncoding.js";
|
|
5
5
|
import { performRequest } from "./index.js";
|
|
6
6
|
export function useGraphqlQuery(...args) {
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export type GraphqlMiddlewareRequestContext<C extends ContextType = ContextType>
|
|
|
90
90
|
};
|
|
91
91
|
export type GraphqlMiddlewareGraphqlEndpointMethod<C extends ContextType> = (event: H3Event, operation?: string | null, operationName?: string | null, context?: GraphqlMiddlewareRequestContext<C> | null) => string | Promise<string> | undefined;
|
|
92
92
|
export type GraphqlMiddlewareServerFetchOptionsMethod<C extends ContextType> = (event: H3Event, operation?: string | null, operationName?: string | null, context?: GraphqlMiddlewareRequestContext<C> | null) => FetchOptions | Promise<FetchOptions>;
|
|
93
|
-
export type GraphqlMiddlewareOnServerResponseMethod<ServerReponse, T, C extends ContextType> = (event: H3Event, response: FetchResponse<ServerReponse>, operation?: string | null, operationName?: string | null, context?: GraphqlMiddlewareRequestContext<C> | null) => T | Promise<T
|
|
93
|
+
export type GraphqlMiddlewareOnServerResponseMethod<ServerReponse, T, C extends ContextType> = (event: H3Event, response: FetchResponse<ServerReponse>, operation?: string | null, operationName?: string | null, context?: GraphqlMiddlewareRequestContext<C> | null) => NoInfer<T> | NoInfer<Promise<T>>;
|
|
94
94
|
export type GraphqlMiddlewareOnServerErrorMethod<C extends ContextType> = (event: H3Event, error: FetchError, operation?: string | null, operationName?: string | null, context?: GraphqlMiddlewareRequestContext<C> | null) => any | Promise<any>;
|
|
95
95
|
export type GraphqlMiddlewareDoRequestMethodContext<C extends ContextType> = {
|
|
96
96
|
/**
|