Strapi v4: graphQL query filters for notEmpty items

Answer:

query getCategoriesWithPosts {
  categories(filters: {posts: {id: {null: false}}}) {
    data {
      id 
      attributes {
        title
        slug
        posts(sort: "publishedAt:desc") {
          data {
            id
            attributes {
              title
            }
          }
        }
      }
    }
  }
}