Cauen / prisma-generator-pothos-codegen

The fastest way to create a fully customizable CRUD Graphql API from Prisma Schema.
https://www.npmjs.com/package/prisma-generator-pothos-codegen
95 stars 16 forks source link

Non-nullable type is allowed with one-to-one relation #52

Closed tictaqqn closed 1 year ago

tictaqqn commented 1 year ago

There is a bug when 1 to 1 relation is used in Prisma schema.

Example schema file:

model Post {
  id         String         @id @default(cuid())
  postDetail PostDetail?
}

model PostDetail {
  id     String  @id @default(cuid())
  postId String  
  post   Post    @relation(fields: [postId], references: [id]) @unique
}

Example output:

builder.prismaObject('Post', {
  fields: (t) => ({
    id: t.exposeID('id'),
    postDetail: t.relation('postDetail', { nullable: false }) // Only `nullable: true` should be allowed!!
  })
})

is allowed but nullable: false should not allowed here because the prisma client could return null for the relation postDetail.

tictaqqn commented 1 year ago

This is a bug of https://github.com/hayes/pothos