endNode

Generic Description

Inspects graph identity, labels, relationship type, direction, or endpoint information. It is documented separately because graph identity and topology helpers affect how rows refer back to stored nodes, relationships, and labels.

Simple example:

MATCH (a)-[r]->(b) RETURN id(a), labels(a), type(r), startNode(r), endNode(r)

Consumer-Level Explanation

Use it when graph structure itself is part of the answer rather than only a path to property values. Prefer this function when the returned graph metadata is part of the answer or a later join key, not just debug output.

More Detailed Explanation

endNode should be understood by the value shape it expects and the row shape it returns. It composes with MATCH, WHERE, WITH, RETURN, and procedure output, so planner-facing documentation should describe both the immediate value transformation and why it belongs in the database query.

Advanced Example

This example uses endNode inside a named row pipeline so the value shape is clear to both the planner and reviewers.

MATCH (u:User)-[e:VIEWED]->(d:Document)
TIME e.ts BETWEEN datetime('2025-01-01T00:00:00Z') AND datetime('2025-02-01T00:00:00Z')
WITH u, e, d,
     unpivot(properties(d.metadata)) AS metadata_rows,
     date_trunc('day', e.ts) AS day_bucket,
     endNode(d) AS focused_value
RETURN u.user_id, d.title, day_bucket, metadata_rows, focused_value
LIMIT 10

Real Use Cases

Real Limitations And Tradeoffs