If I create a nullable relation alongside the main...
# prisma-client
b
If I create a nullable relation alongside the main entity, is there a way for it to be marked as non-null when returning it? e.g.
Copy code
model Author {
  name String
}

model Book {
  author Author?
}
Copy code
const book = await this.prismaService.book.create({
  include: {
    author: true,
  },
  data: {
    author: {
      create: {
        name: 'Bob',
      },
    },
  },
})
In the above example,
book.author
is nullable, yet that the fact that that function succeeded and is returning data means that that field will never be null Is there an existing way to get
book.author
back as a non-nullable value, or should I create a feature request on GitHub for this?
r
@Ben Ezard 👋 You can create a request here but I don’t think that it’s possible to change the types at runtime via TypeScript. as the author
create
that you’re providing is optional.
👍 1