Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma Client "User" Type conflict with TypeGraphQL "User" Type #223

Closed
Artimal opened this issue Jan 6, 2019 · 2 comments
Closed

Prisma Client "User" Type conflict with TypeGraphQL "User" Type #223

Artimal opened this issue Jan 6, 2019 · 2 comments
Labels
Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved

Comments

@Artimal
Copy link

Artimal commented Jan 6, 2019

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<Box> {
  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.

@MichalLytek
Copy link
Owner

Property ‘owner’ is missing in type ‘Box’.

I don't get it 😕
@Artimal Please create a repository with a minimal reproducible code example. I haven't used Prisma, #217 will probably use the new datamodel api.

@Artimal
Copy link
Author

Artimal commented Jan 10, 2019

Prisma Client was incongruent with Prisma Server. After adding manually owner: WhereUserInput; it started to work. I already leaved Prisma and got TypeORM instead, it is going to fit much better with TypeGraphQL.

@MichalLytek MichalLytek added Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved labels Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved
Projects
None yet
Development

No branches or pull requests

2 participants