3

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?

Marco Daniel
  • 5,467
  • 5
  • 28
  • 36
Kumar Abhirup
  • 197
  • 4
  • 16

1 Answers1

1

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

Errorname
  • 2,228
  • 13
  • 23