Skip to content

3.6 Brought sub-graph — parent and children in one fetch

MATCH (p:Person {name:'Ada Lovelace'})-[:HAS_HUBSPOT_CONTACT]->(c:HubSpotContact)-[:HAS_COMMENT]->(note:HubSpotComment)
RETURN c.company, note.text

Means: “Ada’s HubSpot contact and the notes on it.”

How it executes:

  • Probe + fetch Ada’s contact as in §3.1 — but the contact record already embeds its comments ({ email, company, comments: [ {id, text}, … ] }).
  • Materialize the brought sub-graph. The engine extracts the embedded comments[*], makes a transient (:HubSpotComment:Virtual) per comment, and links (c)-[:HAS_COMMENT]->(note) — all from the single fetch. No second call.
  • Run / roll back.

Declared: a brings: entry on the contact join naming the child type, edge, the JSONPath to the embedded list ($.comments[*]), and the child’s identity property.

Why brings not a second join. When the source already returns the children inline (an expand/include/sideload param), declaring them as brings: fetches the whole sub-graph in one call. A separate join would re-probe and re-fetch — slower, and it would need the children’s own anchor key. Pair brings with the endpoint’s sideload params so the children arrive together.