fix: resolve GraphQL request hang in Fastify integration
- Pass FastifyRequest/FastifyReply directly to yoga.handleNodeRequestAndResponse per the official graphql-yoga Fastify integration docs. Yoga v5 uses req.body (already parsed by Fastify) when available, avoiding the dead raw stream issue. - Add proper TypeScript generics for server context including db and redis - Wrap sendVerification/sendPasswordReset in try/catch so missing SMTP does not crash register/requestPasswordReset mutations - Fix migrate.ts path resolution to work with both tsx (src/) and compiled (dist/) - Expose postgres:5432 and redis:6379 ports in compose.yml for local dev Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
import type { YogaInitialContext } from "graphql-yoga";
|
||||
import type { FastifyRequest, FastifyReply } from "fastify";
|
||||
import type { Context } from "./builder";
|
||||
import { getSession } from "../lib/auth";
|
||||
import { db } from "../db/connection";
|
||||
import { redis } from "../lib/auth";
|
||||
|
||||
export async function buildContext(ctx: YogaInitialContext & { request: Request; reply: unknown; db: typeof db; redis: typeof redis }): Promise<Context> {
|
||||
type ServerContext = {
|
||||
req: FastifyRequest;
|
||||
reply: FastifyReply;
|
||||
db: typeof db;
|
||||
redis: typeof redis;
|
||||
};
|
||||
|
||||
export async function buildContext(ctx: YogaInitialContext & ServerContext): Promise<Context> {
|
||||
const request = ctx.request;
|
||||
const cookieHeader = request.headers.get("cookie") || "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user