Language briefs / CGQL, briefly

Follow the data.

A query language for JSON documents, their relationships and the questions that connect them.

01

Read it from top to bottom.

CGQL
FOR a IN accounts
  FILTER a.case == @case
  SORT a.handle
  LIMIT 10
  RETURN { handle: a.handle }

Start with a collection. Keep the rows you want. Sort, limit and return their shape.

@case is a value you supply separately, such as "CS-0412". Collection names stay in the query text.

Keywords are case-insensitive. Identifiers, including collection names, are case-sensitive.

02

Follow a relationship in the same query.

A second FOR follows each account’s outgoing registered_on edge. 1..1 means exactly one hop.

CGQL traversal
FOR a IN accounts
  FILTER a.case == @case
  FOR handset IN 1..1 OUTBOUND a._id registered_on
    RETURN { account: a.handle, handset: handset.label }

With the homepage’s synthetic case, rook_77 and marla.v lead to Handset 8813; dispatch-04 leads to Handset 2207.

03

Room for the next question.

CGQL also supports LET bindings, joins through multiple FOR clauses, read subqueries, grouping with COLLECT and a VECTOR_SEARCH source. Writes use a separately authorized mutation surface. Full-text and hybrid search have dedicated HTTP endpoints.