graphqlgraphcool

Query elements where relationship is null


If I have a simple schema like:

type Author @model { 
  id: ID! @isUnique 
  posts: [Post!]!  @relation(name: "AuthorOfPost")
}
type Post @model {
  id: ID! @isUnique
  author: Author @relation(name: "AuthorOfPost")
}

How can I query all Posts that do not have an author?

Unfortunately, I cannot find something in the authorFilter like id_is_null.


Solution

  • try this!

    query PostsWithAuthor {
      allPosts(filter: { author: null }) {
        id
        author {
          id
        }
      }
    }