I'm trying to make to query 1:1 relation in Prisma ORM But when querying it always returns null
Here is my datamodel:
enum Role {
ADMIN
MEMBER
CONSTRIBUTOR
}
type User {
id: ID! @id
name: String! @unique
email: String! @unique
password: String!
posts: [Post!]!
role: Role @default(value: MEMBER)
}
type Post {
id: ID! @id
title: String
excerpt: String
content: Json
author: User! @relation(link: INLINE)
}
Im trying to query a Post with Author that has a User in it:
but in my resolver when I do:
getPost: async (parent, args, ctx, info) => {
if (args.id) {
console.log('GET POST by ID');
const id = args.id;
return await ctx.prisma.post({ id }).author();
}
},
It is always returning Null. Does someone know how can fix it ?