How do I query for an empty string?


#1

Hi,

I’m having trouble querying for data where a predicate is an empty string.

The scenario here is that I have some data where the value is an empty string and I need to find that data. For example:

{
  "data": {
    "rooms": [
      {
        "name": "room 1"
      },
      {
        "name": "room 2"
      },
      {
        "name": ""
      }
    ]
  }
}

and I want to get a count of rooms which do not have a name.

{
  rooms(func: has(room)) {
    count(room @filter(eq(room, "")))
  }
}

But that returns Empty argument received. I tried replacing the string with "_nil_" (read that somewhere), but although it doesn’t error it doesn’t return a count of rooms without a name either.

Is there a way to search for empty strings?

Thanks!


(Pawan Rawal) #2

This should be possible. Could you create a Github issue for this and we’ll make sure it works!


(Sai Boorlagadda) #3

Created this issue on github.


(system) #4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.