Nicolò
05/05/2020, 11:40 AMtype User {
id: ID! @id
name: String!
posts: [Post!]!
}
type Post {
id: ID! @id
title: String!
published: Boolean! @default(value: false)
author: User @relation(link: INLINE, "PostAuthor")
}
If I query the post I would like to have the id of user so I can then use it directly from a second level resolver.
const posts = await db.posts()
Its a 1:n relation so the key is stored on the Post entity. With SQL it would be a simple select *
And yes we will migrate away from prisma1 but for now we have to fix current not working stuff.Dan Hollick
05/05/2020, 12:25 PMposts[0].author.id
?Dan Hollick
05/05/2020, 12:31 PMconst posts = await db.posts(
{
where: { ... },
},
`{
author {
id
}`
)
Nicolò
05/05/2020, 12:54 PMPost: {
author: {
fragment: `fragment Author on Post { author {id} }`,
resolve: async ({id, author}, args, {redis, userLoader}) => {
...
}
I'm starting to think that I'm doing something really wrong.Dan Hollick
05/05/2020, 12:57 PMNicolò
05/05/2020, 1:00 PMNicolò
05/05/2020, 2:07 PMDan Hollick
05/05/2020, 2:08 PMNicolò
05/05/2020, 2:14 PM// This works
`const posts = await db.$graphql(query ($where: PostWhereInput!){
posts(where: $where) {
id
name
author {
id
}
headingImage {
id
}
}
}
, {where: where});`
//This does not work
`const posts = await db.posts({where: where}, {author { id } headingImage { id }
});`