Skip to main content

Pothos

From https://pothos-graphql.dev/

import { createYoga } from "graphql-yoga";
import { createServer } from "node:http";
import SchemaBuilder from "@pothos/core";

const builder = new SchemaBuilder({});

builder.queryType({
fields: (t) => ({
hello: t.string({
args: {
name: t.arg.string(),
},
resolve: (parent, { name }) => `hello, ${name || "World"}`,
}),
}),
});

const yoga = createYoga({
schema: builder.toSchema(),
});

const server = createServer(yoga);

server.listen(3000, () => {
console.log("Visit http://localhost:3000/graphql");
});

Grats

import { createYoga } from "graphql-yoga";
import { createServer } from "node:http";
import { getSchema } from "./schema"; // Generated by Grats

/** @gqlType */
type Query = unknown;

/** @gqlField */
export function hello(_: Query, args: { name?: string | null }): string {
return `hello, ${args.name || "World"}`;
}

const yoga = createYoga({
schema: getSchema(),
});

const server = createServer(yoga);

server.listen(3000, () => {
console.log("Visit http://localhost:3000/graphql");
});
Playground