basic setup with yoga + pothos and pino logger

This commit is contained in:
Benjamin Palko 2024-12-02 11:30:52 -05:00
parent f8a16a9fce
commit 6312b344cd
7 changed files with 52 additions and 10 deletions

View file

@ -1,8 +1,15 @@
import { createYoga } from "graphql-yoga";
import { schema } from "./schema";
import { logger } from "@lib/logger";
import { yoga } from "./yoga";
const yoga = createYoga({ schema });
const server = Bun.serve({
fetch: yoga.fetch,
error: (error) => {
logger.error(error.message);
return new Response("", {
status: 500,
statusText: "You fucked the goose",
});
},
});
const server = Bun.serve({ fetch: yoga.fetch });
console.log(`Server is running on: ${server.url}${yoga.graphqlEndpoint}`);
logger.info(`Server is running on: ${server.url}${yoga.graphqlEndpoint}`);

8
src/yoga/index.ts Normal file
View file

@ -0,0 +1,8 @@
import { yogaLogger } from "@lib/logger";
import { createYoga } from "graphql-yoga";
import { schema } from "./schema";
export const yoga = createYoga({
schema,
logging: yogaLogger,
});