Skip to main content

Introduction

Graph Query Language (GQL) standard was published in 2024. The standard formalizes pattern matching which the workhorse of graph query languages. This pattern matching is represented as ASCII-art like syntax. At a high level, when evaluating a query, GQL keeps track of three things:
  1. the working graph, which is the property graph we are using to match our patterns currently;
  2. the working table, that stores the information computed thus far; and
  3. the working record, which contains the tuple of the result we are currently using.
GQL is developed as a query language for graphs and recursion is typical when working with Graphs. The typical GQL MATCH pattern (a)-[:links_to]->{m,n}(b) selects all nodes b that are reachable from a by following one or more edges in the graph, traversing the graph using the :links_to relation. Recursive queries compute the transitive closure of the graph, and return the nodes in the graph that can be reached starting from a given one.

Property Graph

Graph Databases typically store data as property graphs where both nodes and edges carry arbitrary key-value attributes. Graph Query Language (GQL) enables expressive pattern matching that we exploit for structural retrieval. GQL provides a declarative, SQL-like syntax for pattern matching, filtering, and aggregation. Native graph database that implements the labeled-property graph model store data as labeled nodes connected by typed, directed relationships, where both nodes and relationships may carry properties. This design allows relationships to be queried and traversed directly, without relying on joins or intermediary structures. These databases use GQL, a declarative graph query language designed to express graph patterns intuitively and concisely, making it easier to formulate queries that reflect the underlying graph structure.