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 { | declare global { | ||||||
|   // allow global `var` declarations
 |   // allow global `var` declarations
 | ||||||
|   // eslint-disable-next-line no-var
 |   // eslint-disable-next-line no-var
 | ||||||
|   var prisma: PrismaClient | undefined; |   var _prisma: PrismaClient | undefined; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export const prisma = | export const prisma = | ||||||
|   global.prisma || |   global._prisma || | ||||||
|   new PrismaClient({ |   new PrismaClient({ | ||||||
|     log: ["query"], |     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 { Question } from "@prisma/client"; | ||||||
| 
 | 
 | ||||||
|  | import { prisma } from "./database/prisma"; | ||||||
| import { measureTime } from "./utils/measureTime"; | import { measureTime } from "./utils/measureTime"; | ||||||
| 
 | 
 | ||||||
| export async function getFrontpage(): Promise<Question[]> { | export async function getFrontpage(): Promise<Question[]> { | ||||||
|  |  | ||||||
|  | @ -7,12 +7,7 @@ builder.queryField("frontpage", (t) => | ||||||
|     type: [QuestionObj], |     type: [QuestionObj], | ||||||
|     description: "Get a list of questions that are currently on the frontpage", |     description: "Get a list of questions that are currently on the frontpage", | ||||||
|     resolve: async () => { |     resolve: async () => { | ||||||
|       try { |  | ||||||
|       return await getFrontpage(); |       return await getFrontpage(); | ||||||
|       } catch (e) { |  | ||||||
|         console.error(e); |  | ||||||
|         throw e; |  | ||||||
|       } |  | ||||||
|     }, |     }, | ||||||
|   }) |   }) | ||||||
| ); | ); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user