Migrating Knowledge Graph Cypher queries
Use gcx kg graph query for new Cypher workflows. It preserves the query’s
projected columns and rows, including scalars, aggregates, nodes, relationships,
and paths.
gcx kg entities query is deprecated but remains supported through v1.x. Its
endpoint, flags, defaults, and entities/edges response stay unchanged.
Deprecation warnings appear on stderr at -v or higher verbosity; default output
stays quiet. Stdout remains usable by existing JSON
parsers. Removal will not happen before the next major release; this change
does not set a removal date or retire the backend search API.
Choose the contract
These are separate contracts, not interchangeable aliases. There is no automatic fallback from the new endpoint to the old one when a request fails.
Migrate a caller
- Add a literal
LIMITand an upper bound of at most 5 hops to any variable-length path. The server applies its language allowlist and query budgets. Inspect the returnedCYPHER_*code if it refuses a query. - Use
kg graph queryand update the output parser together. Remove--pageand--insights-only; neither flag exists on the new command. - Compare results for the same explicit
--from/--towindow before switching a script or agent workflow. The legacy command remains available during this transition.
For example, a legacy caller retrieves whole entities and reads their names:
gcx kg entities query 'MATCH (s:Service) RETURN s LIMIT 10' --since 1h -o json \
| jq '.entities[].name'The new caller can project names directly:
gcx kg graph query 'MATCH (s:Service) RETURN s.name AS name LIMIT 10' --since 1h -o json \
| jq '.rows[][0]'A synthetic response to the new query is:
{
"columns": ["name"],
"rows": [["checkout"], ["database"]],
"stats": {"columnCount": 1, "rowCount": 2, "elapsedMs": 3}
}Scalar projections avoid reconstructing entities just to read a property. When
returning whole nodes, read their labels and properties; the legacy entity’s
type, name, scope, and insights fields are not the new node schema.
Relationship cells expose type, startRef, endRef, and properties.
Node and relationship refs are local to one response. Use identity properties
to correlate results across requests, and keep rows positional because column
names can repeat.
Bounds and time windows
stats.rowCount describes returned rows, not the total number of matching
entities. LIMIT bounds the query result; there is no lastPage signal or
automatic pagination. Use literal SKIP/LIMIT and a deterministic ORDER BY
when selecting successive result windows, but do not treat separate requests
as a consistent snapshot of a changing graph.
The new command accepts a positive --since duration, or both --from and
--to. Explicitly empty time flags are rejected, and the start must precede the
end. Every matched node and relationship must overlap the requested window;
this does not require an entire path to coexist at one instant.
Keep kg entities list for basic entity lookup and kg entities inspect for
root-cause analysis with health evidence. Graph queries answer topology and
projection questions and do not return the legacy insight enrichment.


