Doing this 👇
query {
postsConnection(where: {
status: PUBLISHED
}) {
aggregate {
count
}
edges {
cursor
node {
id
slug
}
}
}
}
gives me postsConnection
of published posts.
The Post
model has an array of Category
enum in field categories
. This is the Post in datamodel
👇
enum Category {
TECH
FIN
DIGIMARK
CODING
TUTORIAL
HOWTO
WRITING
INSPIRE
SCIENCE
POLITICS
LIFESTYLE
}
type Post {
id: ID!
title: String!
editorSerializedOutput: Json!
editorCurrentContent: Json!
editorHtml: String!
updatedAt: DateTime!
createdAt: DateTime!
author: User
authorId: String!
categories: [Category!]!
thumbnail: Json!
status: PostStatus!
slug: String!
}
My question is, what Prisma Query do I need to write to get PostConnection
of posts in a specific category?
Prisma doesn't yet allow filtering with Enum (see issue on github)
You can however make a to-many
relation with a new Type Category
that you can create