Prisma Client User Type conflict with TypeScript User Type (type-graphql)

prisma

#1

Hi, I create simple app with GraphQL Yoga, Prisma and TypeGraphQL.
Context TS interface with Prisma type:
export interface Context {
user?: AuthUser;
prisma: Prisma;
}
Box TS type:
@ObjectType()
export class Box {
@Field(type => ID)
id: string

@Field({ nullable: true })
name?: string

@Field(type => Int, { nullable: true })
items?: number
    
@Field(type => User)
 owner: User
 }

Prisma datamodel Box:
type Box {
id: ID! @id
name: String @default(value: “”)
items: Int @default(value: 0)
owner: User
}
In Box resolver:
@Authorized()
@Mutation(returns => Box)
async deleteBox(@Args() args: DeleteBoxArgs, @Ctx() context: Context): Promise {
return context.prisma.deleteBox({ id: args.id });
}

PROBLEM:

[ts]
Type ‘Box’ is not assignable to type ‘Box’. Two different types with this name exist, but they are unrelated.
Property ‘owner’ is missing in type ‘Box’.

How to avoid this kind of type conflicts? Please for help.


#2

I believed this has been already resolved in slack.


#3

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.