Search code examples
graphqlweaviate

Is there a way to filter out null values for literals and references


If we have an Author with no beacons to Articles and thus WroteArticles was null and we wanted to only return Authors who had non-empty/non-null WroteArticles, how could that be done?

As an example we can use the Weaviate demo site

I've tried filter operations using where and various operators, but I must be missing something obvious. Example of a query I've tried on my own data set below, where I did have a Thing with no beacons.

{
  Get {
    Things {
      Author (where:{
        operator:Equal,
        path:["WroteArticles"]
        valueString:" "
      }){
        name
        WroteArticles {
          ... on Article {
            InPublication {
              ... on Publication {
                name
              }
            }
          }
        }
      }
    }
  }
}

Solution

  • You can now do this as follows (also in the documentation):

    {
     Get {
       Things {
         Author(
           where:{
             valueInt: 2
             operator:GreaterThanEqual
             path: ["WroteArticles"]
           }
         ) {
           name
           WroteArticles {
             ... on Article {
               title
             }
           }
         }
       }
     }
    }