Michael Aubry
07/23/2020, 9:49 PMMichael Aubry
07/23/2020, 9:53 PMBen Schwartz
07/23/2020, 9:54 PMBen Schwartz
07/23/2020, 9:55 PMMichael Aubry
07/23/2020, 9:56 PMt.list.field("user", {
type: "user",
resolve: (_: any, args: any, ctx: any) => {
const userID = getUser(ctx.req);
return ctx.prisma.query.user({ where: { id: userID } });
}
});Michael Aubry
07/23/2020, 9:58 PMMichael Aubry
07/23/2020, 10:46 PMMichael Aubry
07/23/2020, 11:03 PMexport function createContext(req: any): Context {
return { req, prisma };
}Michael Aubry
07/23/2020, 11:20 PMt.field("user", {
type: "user",
resolve: (_: any, args: any, ctx: any) => {
const userID = getUser(ctx.req.req.headers);
return [
ctx.prisma.user.findOne({
where: { id: userID }
})
];
}
});