fix: prisma import, rename global._prisma
This commit is contained in:
parent
66938bcaf4
commit
02cb8089a7
|
@ -3,13 +3,13 @@ import { PrismaClient } from "@prisma/client";
|
|||
declare global {
|
||||
// allow global `var` declarations
|
||||
// eslint-disable-next-line no-var
|
||||
var prisma: PrismaClient | undefined;
|
||||
var _prisma: PrismaClient | undefined;
|
||||
}
|
||||
|
||||
export const prisma =
|
||||
global.prisma ||
|
||||
global._prisma ||
|
||||
new PrismaClient({
|
||||
log: ["query"],
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== "production") global.prisma = prisma;
|
||||
if (process.env.NODE_ENV !== "production") global._prisma = prisma;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Question } from "@prisma/client";
|
||||
|
||||
import { prisma } from "./database/prisma";
|
||||
import { measureTime } from "./utils/measureTime";
|
||||
|
||||
export async function getFrontpage(): Promise<Question[]> {
|
||||
|
|
|
@ -7,12 +7,7 @@ builder.queryField("frontpage", (t) =>
|
|||
type: [QuestionObj],
|
||||
description: "Get a list of questions that are currently on the frontpage",
|
||||
resolve: async () => {
|
||||
try {
|
||||
return await getFrontpage();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
throw e;
|
||||
}
|
||||
return await getFrontpage();
|
||||
},
|
||||
})
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user