Skip to main content

Get first element of a list with FIRST  

Get the first element from a traversal result.
Note this does not return the first/oldest node in the graph, but the first node that the traversal returns.
FIRST returns a single element (object) rather than a collection (array). If the traversal has no results, the binding will be empty.

Example 1: Getting the first node returned by a traversal

Example 2: Getting the first node returned by an edge traversal


Count elements with COUNT  

Count the number of elements in a traversal.
When using the SDKs or curling the endpoint, the query name must match what is defined in the queries.hx file exactly.

Example 1: Basic element counting

Here’s how to run the query using the SDKs or curl

Scope results with RANGE  

Get a specific range of elements from a traversal.
RANGE is inclusive of the start but exclusive of the end. For example, RANGE(0, 10) returns elements 0 through 9 (10 total elements). Both start and end and required and must be positive integers.
When using the SDKs or curling the endpoint, the query name must match what is defined in the queries.hx file exactly.

Example 1: Basic pagination

Here’s how to run the query using the SDKs or curl

Sort results with ORDER  

Sort the results of a traversal by a property in ascending or descending order.
Use Asc for ascending order and Desc for descending order.
When using the SDKs or curling the endpoint, the query name must match what is defined in the queries.hx file exactly.

Example 1: Sorting by age (oldest first)

Here’s how to run the query using the SDKs or curl

Example 2: Sorting by age (youngest first)

Here’s how to run the query using the SDKs or curl