@executor-js/plugin-graphql
v1.5.14
Published
Introspect a GraphQL endpoint and expose its queries and mutations as invokable tools on an executor.
Downloads
3,214
Readme
@executor-js/plugin-graphql
Introspect a GraphQL endpoint and expose its queries and mutations as invokable tools on an executor.
Install
bun add @executor-js/sdk @executor-js/plugin-graphql
# or
npm install @executor-js/sdk @executor-js/plugin-graphqlUsage
import { createExecutor } from "@executor-js/sdk";
import { graphqlPlugin } from "@executor-js/plugin-graphql";
const executor = await createExecutor({
onElicitation: "accept-all",
plugins: [graphqlPlugin()] as const,
});
// Public endpoint — no auth
await executor.graphql.addSource({
scope: executor.scopes[0]!.id,
endpoint: "https://graphql.anilist.co",
namespace: "anilist",
});
const tools = await executor.tools.list();
const result = await executor.tools.invoke("anilist.Media", {
search: "Frieren",
});Secret-backed auth
import { createExecutor } from "@executor-js/sdk";
import { graphqlPlugin } from "@executor-js/plugin-graphql";
import { fileSecretsPlugin } from "@executor-js/plugin-file-secrets";
const executor = await createExecutor({
onElicitation: "accept-all",
plugins: [fileSecretsPlugin(), graphqlPlugin()] as const,
});
const scope = executor.scopes[0]!.id;
await executor.secrets.set({
id: "github-token",
name: "GitHub Token",
value: "ghp_...",
scope,
});
await executor.graphql.addSource({
scope,
endpoint: "https://api.github.com/graphql",
namespace: "github",
headers: {
Authorization: { secretId: "github-token", prefix: "Bearer " },
},
});Using with Effect
If you're building on @executor-js/sdk/core (the raw Effect entry), import this plugin from its /core subpath instead — it returns the Effect-shaped plugin with Effect.Effect<...>-returning methods rather than promisified wrappers:
import { graphqlPlugin } from "@executor-js/plugin-graphql/core";Status
Pre-1.0. APIs may still change between beta releases. Part of the executor monorepo.
License
MIT
