run_graphql
Execute complex GraphQL queries with nested relations and custom filtering for Gadget apps when standard record queries are insufficient.
Instructions
Run an arbitrary read-only GraphQL query against the Gadget app. Use this for complex queries with nested relations or custom filtering that query_records can't express.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | GraphQL query string | |
| variables | No | GraphQL variables |
Implementation Reference
- src/tools.ts:138-149 (handler)The handler implementation for the `run_graphql` tool, which executes an arbitrary GraphQL query if it is not a mutation.
case "run_graphql": { const { query, variables } = args as { query: string; variables?: Record<string, unknown> }; const trimmed = query.trim().toLowerCase(); if (trimmed.startsWith("mutation")) { return { content: [{ type: "text", text: "Mutations are not allowed — this server is read-only." }], isError: true, }; } const data = await gql(query, variables); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } - src/tools.ts:219-230 (schema)The definition of the `run_graphql` tool, including its name, description, and input schema.
name: "run_graphql", description: "Run an arbitrary read-only GraphQL query against the Gadget app. Use this for complex queries with nested relations or custom filtering that query_records can't express.", inputSchema: { type: "object", required: ["query"], properties: { query: { type: "string", description: "GraphQL query string" }, variables: { type: "object", description: "GraphQL variables" }, }, }, },