How to search null data in a field using ArcQL

In the previous post, we have seen how to search non-null data in a field using EXIST query.

Now we will check how to search null data in a field using the arcql NOT EXIST query

  • NOT EXIST query returns records that have null data in a given field.
  • Frame a query like this.
NOT EXIST a

We will work with the same schema used earlier.

type arcqlObject {
    str: String
    int: Int
}

We have inserted the following data in the arcqlObject. Notice that the third object has null data in the int field.

mutation {
  upsert(
    values: {
      arcqlObject: [
        { str: "hypi", int: 1 }
        { str: "low code", int: 2 }
        { str: "easy to use backend" }
      ]
    }
  ) {
    id
  }
}
#result
{
  "data": {
    "upsert": [
      {
        "id": "01FJGS5P4C2V0AZ9BGPV6BXGEG"
      },
      {
        "id": "01FJGS5P4DBC3HVS5EESRD63ZY"
      },
      {
        "id": "01FJGS5P4ECE8BSG10FVJ1865V"
      }
    ]
  }
}

Let’s retrieve records that have null data in the int field of the arcqlObject.

{
  find(type: arcqlObject, arcql: "NOT EXIST int") {
    edges {
      node {
        ... on arcqlObject {
          str
          int
          hypi {
            id
          }
        }
      }
      cursor
    }
  }
}
#result
{
  "data": {
    "find": {
      "edges": [
        {
          "node": {
            "str": "easy to use backend",
            "int": null,
            "hypi": {
              "id": "01FJGS5P4ECE8BSG10FVJ1865V"
            }
          },
          "cursor": "01FJGS5P4ECE8BSG10FVJ1865V"
        }
      ]
    }
  }
}

We got the records with the null data in the int field. The third record with the null data in the int field was retrieved.

Check the POSTMAN collection for the not exist query in different programming languages! Click</> and choose the programming language of your choice.
Don’t forget to insert your own Authorization key and Hypi Domain under Headers to test the results!

Run in Postman