Tag: prisma
-
How to specify auto-generated types by Prisma for the code-first Graphql resolver on NestJS?
0 Suppose I want to execute a many-to-many mutation like below, which is cited from prisma.io: const createCategory = await prisma.post.create({ data: { title: ‘How to be Bob’, categories: { create: [ { assignedBy: ‘Bob’, assignedAt: new Date(), category: { create: { name: ‘New category’, }, }, }, ], }, }, }) To implement Graphql…
-
How to query a date/time field using pothos with prisma and postgresql
0 I’ve got my pothos set up using Prisma and postgresql. I’m trying to expose the createdAt and updatedAt fields from prisma in my builder: Prisma schema: model Course { id Int @id @unique @default(autoincrement()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt // removed fields for brevity. } My builder: builder.prismaObject(‘Course’, { fields: (t) => ({…
-
How to access request in prisma middleware
0 I am using typegraphql-prisma and all the resolver are autogenerated. I need to automatically set the createdBy and updatedBy fields in Prisma models based on the authenticated user’s ID, which retrieve from a Firebase token in Express middleware. //auth.middleware.ts import { Response, NextFunction } from "express"; import * as admin from "firebase-admin"; import {…
-
Multi database support in prisma
0 I have 3 databases in my project. Every database has different data. But they have some relation between them. For example on the transaction database in my transaction, it has a userId stored and in the Default database User table has this user. Now how to manage these multi-database and cross-relation between databases in…
-
How to reference prismaObject type for a objectType field with pothos graphql
0 I have my User object made based off of my prisma schema. I’m trying to create a RegisteredUserRes objectType where the field createdUser should be of type User from my prismaObject. How can I do that? import { builder } from ‘../builder’; import type PrismaTypes from ‘@pothos/plugin-prisma/generated’; builder.prismaObject(‘User’, { fields: t => ({ id:…
-
Nest.js + Prisma relationship constantly returning null
0 I’m using Nest.js + GraphQl + Prisma, and trying to create 3 tables: User, Post, and Viewers When getting 1 post I need to add the user as viewer. Successfully saving it to the db but when returning the relationship, viewers is constantly null Here’s my prisma schema: model User { id Int @id…