ProvenPin Install

Pothos GraphQL schema served by GraphQL Yoga: working versions (tested 2026-10-15)

Build a typed GraphQL schema with Pothos (queries and mutations over an in-memory store) and execute it offline through GraphQL Yoga's fetch handler.

passed1 passed · 0 failed2026-10-15 14:59 UTC
Status
passed
Last passed
2026-10-15 14:59 UTC
Tests
1 / 1
Language
TypeScript
Runtime
node v22.23.3
pinned versions5
@pothos/core@4.15.1graphql@17.0.2graphql-yoga@5.24.5@types/node@26.6.5tsx@4.23.15
run it
npm install --no-audit --no-fund --ignore-scripts=false
npm test
test environment
node v22.23.3
linux 6.17.0-1022-azure
x64
runner: github-actions 38755782594

The code

Exactly the files that passed. Your agent can pull them with get_recipe("graphql-pothos-yoga-schema") (install), or see them on GitHub.

package.json
{
  "name": "graphql-pothos-yoga-schema",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {
    "@pothos/core": "4.15.1",
    "graphql": "17.0.2",
    "graphql-yoga": "5.24.5"
  },
  "devDependencies": {
    "@types/node": "26.6.5",
    "tsx": "4.23.15"
  }
}
src/schema.ts
import SchemaBuilder from "@pothos/core";
import { createYoga } from "graphql-yoga";

type Post = { id: number; title: string; published: boolean };
const posts: Post[] = [];

const builder = new SchemaBuilder<{}>({});

const PostRef = builder.objectRef<Post>("Post");
PostRef.implement({
  fields: (t) => ({
    id: t.exposeInt("id"),
    title: t.exposeString("title"),
    published: t.exposeBoolean("published"),
  }),
});

builder.queryType({
  fields: (t) => ({
    posts: t.field({
      type: [PostRef],
      resolve: () => posts,
    }),
    post: t.field({
      type: PostRef,
      nullable: true,
      args: { id: t.arg.int({ required: true }) },
      resolve: (_r, { id }) => posts.find((p) => p.id === id) ?? null,
    }),
  }),
});

builder.mutationType({
  fields: (t) => ({
    createPost: t.field({
      type: PostRef,
      args: {
        title: t.arg.string({ required: true }),
        published: t.arg.boolean({ required: true }),
      },
      resolve: (_r, args) => {
        const post = { id: posts.length + 1, title: args.title, published: args.published };
        posts.push(post);
        return post;
      },
    }),
  }),
});

export const schema = builder.toSchema();
export const yoga = createYoga({ schema, graphqlEndpoint: "/graphql" });
export function reset() { posts.length = 0; }
test/schema.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { reset, yoga } from "../src/schema.ts";

async function gql(query: string, variables?: Record<string, unknown>) {
  const res = await yoga.fetch("http://local/graphql", {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify({ query, variables }),
  });
  return { status: res.status, body: await res.json() };
}

test("create and query posts", async () => {
  reset();
  const created = await gql(
    `mutation($title: String!, $published: Boolean!) { createPost(title: $title, published: $published) { id title published } }`,
    { title: "Hello", published: true },
  );
  assert.equal(created.status, 200);
  assert.equal(created.body.data.createPost.title, "Hello");
  const listed = await gql(`{ posts { id title } }`);
  assert.equal(listed.body.data.posts.length, 1);
  const one = await gql(`query($id: Int!) { post(id: $id) { title } }`, { id: 1 });
  assert.equal(one.body.data.post.title, "Hello");
});

Connect to ProvenPin

Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.

terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.