<aside> ⚠️ Treat this as a first draft that will evolve based on your feedback, not a final version to rubber stamp. Please let us know your thoughts as comments!

</aside>

Problem


ComposeDB currently supports loading lists of documents by their model type, their controlling account, or their related documents. However, ComposeDB lacks the ability to filter and/or order the returned documents by their fields. This has been a heavily requested feature by the community on this forum and in direct conversations.

Solution


This RFC introduces a possible solution to add simple filtering and ordering primitives to GraphQL queries as arguments on GraphQL connections, in addition to the existing pagination arguments. As a requirement for filtering and ordering, this proposal also defines how users specify the fields they want indexed.

Approach


This RFC is written with the following in mind:

Example Composite


For discussion in this RFC, we will be using the following composite:

enum PublicationStatus {
  DRAFT
  PUBLISHED
  ARCHIVED
}

type Image {
  src: URI!
  alt: String
}

type Post @createModel(...) {
  text: String!
  status: PublicationStatus!
  publishedAt: Date
  image: Image!
  tags: [String!]
}

Indexing