import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; import type { WrnexusPlugin } from "@wrnexus/plugin"; import { createGraphqlHandler, type GraphqlOptions } from "./index.ts"; export function graphqlPlugin(options: GraphqlOptions & { path?: string }): WrnexusPlugin { return { name: "@wrnexus/graphql", version: "0.8.0", setup() { (globalThis as any).__wrnexusGraphqlHandler = createGraphqlHandler(options); }, routeEntries: [ { kind: "api", path: options.path ?? "/api/graphql", entry: join(dirname(fileURLToPath(import.meta.url)), "route.ts"), }, ], documentation: ["packages/graphql/README.md"], typeDefinitions: ["packages/graphql/src/index.ts"], }; } export default graphqlPlugin;