GQL Essentials / GQL vs Cypher: Shared Syntax and Compatibility
PDF ↗

GQL learning guide · Dominik Tomaszuk

GQL vs Cypher: Shared Syntax and Compatibility

GQL is an ISO database language standard. Cypher is a graph query language used by Neo4j and other implementations. Their familiar pattern notation makes many simple queries look alike, but similar syntax does not establish complete compatibility.

A familiar query shape

GQL
MATCH (l:Loan)-[:INCLUDES]->(b:Book)
WHERE l.loanid = 'L-2025-0001'
RETURN b.title AS title

This pattern binds loans to books along outgoing INCLUDES edges. It uses the MATCH, WHERE and RETURN structure familiar from Cypher. It assumes an appropriate graph context and the library data from Chapter 4.

What should you check before migration?

Start with the target database and version. Consult its conformance documentation for the features the query uses. Then inspect graph selection, property types, path restrictions, aggregation and data modification. A graph type definition requires a separate check from a simple read query.

Neo4j's GQL conformance documentation distinguishes supported features, unsupported mandatory features, optional features with Cypher equivalents and additional Cypher features. Use that documentation for version-specific compatibility.

Syntax is only part of the comparison

Two accepted queries can still differ in edge cases. Test empty inputs, missing properties, duplicate matches and repeated paths. Compare the result values and multiplicities, and use explicit ordering when the output order matters. The book's chapters on expressions and NULL and path semantics explain why those cases matter.

Learning GQL with Cypher experience

Begin with read queries, then examine types and schemas and data modification. Treat vendor extensions as explicit dependencies when portability is a requirement. The standard guide explains the scope of ISO/IEC 39075 and how to use the book alongside it.

Learn GQL

Start with a short guide, then follow links to the relevant chapters.

Search chapters, definitions and examples.