GraphQL GlideRecord_Query pageInfo

caten
Tera Contributor

Hey everyone,

 

I am working on a project to collect some data from SNOW via GraphQl. I chose to use the out of the box GlideRecord_Query request and it is currently in a working state. One of the things I am missing though is a method to see how many total records will be returned in the full set. If I had this data, I can at least figure out what my progress is like when I paginate through the records.

 

In other GraphQL endpoints I have worked with, you can simply request pageInfo, but that doesn't seem to be in this out of the box GlideRecord_Query request. Below is a quick example of what I am doing. 

 

query cmdb_ci($pageSize: Int! = 100, $offset: Int! = 0, $queryConditions: String! = "") {
  GlideRecord_Query {
    cmdb_ci(pagination: {limit: $pageSize, offset: $offset}, queryConditions: $queryConditions) {
      _results {
        sys_id {
          value
        }
      }
    }
  }
}

 

Any help would be greatly appreciated. 

 

Thanks!

1 REPLY 1

drewpowers
Tera Contributor

You can use _rowCount before _results to output the number of records that will be returned.

 

Ex.

 

query cmdb_ci($pageSize: Int! = 100, $offset: Int! = 0, $queryConditions: String! = "") {
  GlideRecord_Query {
    cmdb_ci(pagination: {limit: $pageSize, offset: $offset}, queryConditions: $queryConditions) {
      _rowCount _results {
        sys_id {
          value
        }
      }
    }
  }
}