How do I query for an empty string?

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!

1 Like

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

1 Like

Created this issue on github.

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