-
Is it possible to use nestedSelection for the Currently i'm doing this (it's inside a posts: t.prismaConnection({
type: "Post",
cursor: "id",
resolve: async (query, parent, args, ctx) => {
return ctx.db.post.findMany({
...query,
where: { collections: { some: { post: { id: parent.id } } } },
});
},
}), Maybe there could be a more efficient way to do this with something like: posts: t.relatedConnection("posts", {
cursor: "id",
select: (args, ctx, nestedSelection) => ({
posts: {
select: {
// This will look at what fields are queried on Media
// and automatically select uploadedBy if that relation is requested
post: nestedSelection(
// This arument is the default query for the media relation
// It could be something like: `{ select: { id: true } }` instead
true
),
},
},
}),
resolve: (collection) => collection.posts.map(({ post }) => post),
}), |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 17 replies
-
working on a solution for this in #671, sorry I didn't respond here sooner. Will follow up with how to use this once its been finished up, there is still some work to do before its ready to go |
Beta Was this translation helpful? Give feedback.
-
Added some new helpers for this. Docs are available here: https://pothos-graphql.dev/docs/plugins/prisma#indirect-relations-as-connections |
Beta Was this translation helpful? Give feedback.
Added some new helpers for this. Docs are available here: https://pothos-graphql.dev/docs/plugins/prisma#indirect-relations-as-connections