Hi! Short noob question regarding a GraphCool quer...
# prisma-whats-new
p
Hi! Short noob question regarding a GraphCool query. If I have a simple schema like:
Copy code
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
. Thanks
k
Someone smarter than me can probably give a better answer, but I would look into creating a custom query resolver that checks for the author ID. https://www.graph.cool/docs/reference/graphql-api/query-api-nia9nushae/#custom-queries
p
thanks! was hoping that this could be done directly with one of the many filter options as it seems to be a pretty common type of filter criteria...
👍 1
m
Hey @Peter Albert, try this!
Copy code
query PostsWithAuthor {
  allPosts(filter: { author: null }) {
    id
    author {
      id
    }
  }
}
👌 1
p
👍
Could have sworn that I tried this, but apparently not!
@matic - if you want to earn some StackOverflow points, just copy your answer here: https://stackoverflow.com/questions/49463986/query-elements-where-relationship-is-null
🙏 1