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: t.exposeID('id'),
name: t.exposeString('name', { nullable: true }),
email: t.exposeString('email', { nullable: true }),
password: t.exposeString('password', { nullable: true }),
image: t.exposeString('image', { nullable: true }),
createdAt: t.expose('created_at', { type: 'Date' }),
emailVerified: t.expose('emailVerified', { type: 'Date', nullable: true }),
movies: t.relation('movies'),
shows: t.relation('shows'),
}),
});
export class RegisteredUserRes {
constructor(
public error: string,
public createdUser: PrismaTypes['User']['Shape'],
public ok: boolean,
public statusCode: number
) {}
builder.objectType(RegisteredUserRes, {
name: 'RegisteredUserRes',
fields: t => ({
error: t.exposeString('error'),
createdUser: t.expose('createdUser', { type: 'User' }), // type User not found
ok: t.exposeBoolean('ok'),
statusCode: t.exposeInt('statusCode'),
}),
});
|