2026-03-04 18:07:18 +01:00
|
|
|
import SchemaBuilder from "@pothos/core";
|
|
|
|
|
import ErrorsPlugin from "@pothos/plugin-errors";
|
2026-03-04 18:42:58 +01:00
|
|
|
import type { DB } from "../db/connection";
|
|
|
|
|
import type { SessionUser } from "../lib/auth";
|
2026-03-04 18:07:18 +01:00
|
|
|
import type Redis from "ioredis";
|
|
|
|
|
import { GraphQLDateTime, GraphQLJSON } from "graphql-scalars";
|
|
|
|
|
|
|
|
|
|
export type Context = {
|
|
|
|
|
db: DB;
|
|
|
|
|
redis: InstanceType<typeof Redis>;
|
|
|
|
|
currentUser: SessionUser | null;
|
|
|
|
|
request: Request;
|
|
|
|
|
reply: unknown;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const builder = new SchemaBuilder<{
|
|
|
|
|
Context: Context;
|
|
|
|
|
Scalars: {
|
|
|
|
|
DateTime: { Input: Date; Output: Date };
|
|
|
|
|
JSON: { Input: unknown; Output: unknown };
|
|
|
|
|
};
|
|
|
|
|
}>({
|
|
|
|
|
plugins: [ErrorsPlugin],
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
builder.addScalarType("DateTime", GraphQLDateTime, {});
|
|
|
|
|
builder.addScalarType("JSON", GraphQLJSON, {});
|
|
|
|
|
|
|
|
|
|
builder.queryType({});
|
|
|
|
|
builder.mutationType({});
|