intentkit-graphql
v1.2.0
Published
GraphQL bridge for IntentKit functions
Maintainers
Readme
intentkit-graphql
GraphQL bridge for IntentKit. Exposes IntentKit functions as GraphQL mutations with auto-generated schema from Zod definitions.
Install
npm install intentkit-graphql intentkitUsage
import { IntentRegistry, createContext } from 'intentkit';
import { startGraphQLBridge } from 'intentkit-graphql';
const registry = new IntentRegistry().register(/* your functions */);
const context = await createContext({ dbPath: './data.db' });
const handle = await startGraphQLBridge({
registry,
context,
roles: { admin: ['*'] },
defaultRole: 'admin',
port: 3300,
});
console.log(`GraphQL at ${handle.url}`);Schema
Each IntentKit function becomes a GraphQL mutation. Zod types map to GraphQL types:
| Zod | GraphQL |
|-----|---------|
| z.string() | String |
| z.number() | Float |
| z.boolean() | Boolean |
| z.enum() | Enum |
| z.array() | List |
| z.object() | InputObject |
Results are returned as JSON strings (since function outputs are dynamic).
A catalog query is available for listing all registered functions.
Role Resolution
Role is read from the X-IntentKit-Role HTTP header.
License
MIT
