basic setup with yoga + pothos and pino logger
This commit is contained in:
parent
f8a16a9fce
commit
6312b344cd
7 changed files with 52 additions and 10 deletions
19
src/index.ts
19
src/index.ts
|
|
@ -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
8
src/yoga/index.ts
Normal 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,
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue