@ executor-js/ plugin-graphql (英语)
透视一个 GraphQL 端点,并将它的查询和变异作为执行器上的可诉工具来曝光.
安装
bun add @executor-js/sdk @executor-js/plugin-graphql
# or
npm install @executor-js/sdk @executor-js/plugin-graphql
使用量
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.addIntegration({
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",
});
秘密支持的认证
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.addIntegration({
scope,
endpoint: "https://api.github.com/graphql",
namespace: "github",
headers: {
Authorization: { secretId: "github-token", prefix: "Bearer " },
},
});
有效使用
如果你在继续发展 @executor-js/sdk/core (原始效果项),从它的插件导入此插件 /core 子路径转而返回效果形状的插件 Effect.Effect<...>- 返回方法,而不是混合包装:
import { graphqlPlugin } from "@executor-js/plugin-graphql/core";
状态
预1.0. API在β释放之间仍然可能改变. 部分 执行器单曲。 。 。 .
许可证
麻省理工学院