# tests/cypher/corpus/guard.jsonl, method get_catalog_graph_in_use
query: "CYPHER 25 MATCH (cm:CatalogModel WHERE (cm.tenant_id IS NULL OR cm.tenant_id IN $__scope_tenants)) WHERE (EXISTS { MATCH (md:ModelDecision WHERE md.tenant_id IN $__scope_tenants)-[:MATCHED_MODEL]->(cm WHERE (cm.tenant_id IN $__scope_tenants OR (cm.tenant_id IS NULL AND cm:`CatalogModel`|`EntityLabel`|`ModelField`|`Theme`))) } OR EXISTS { MATCH (md:ModelDecision WHERE md.tenant_id IN $__scope_tenants)-[:HAS_COMPLEMENTARY_MATCH]->(__scope_n0 :ComplementaryMatch WHERE __scope_n0.tenant_id IN $__scope_tenants)-[:REFERS_TO_MODEL]->(cm WHERE (cm.tenant_id IN $__scope_tenants OR (cm.tenant_id IS NULL AND cm:`CatalogModel`|`EntityLabel`|`ModelField`|`Theme`))) }) OPTIONAL MATCH (cm WHERE (cm.tenant_id IN $__scope_tenants OR (cm.tenant_id IS NULL AND cm:`CatalogModel`|`EntityLabel`|`ModelField`|`Theme`)))-[hf:HAS_FIELD]->(f:ModelField WHERE (f.tenant_id IS NULL OR f.tenant_id IN $__scope_tenants)) OPTIONAL MATCH (cm WHERE (cm.tenant_id IN $__scope_tenants OR (cm.tenant_id IS NULL AND cm:`CatalogModel`|`EntityLabel`|`ModelField`|`Theme`)))-[:BELONGS_TO_THEME]->(t:Theme WHERE (t.tenant_id IS NULL OR t.tenant_id IN $__scope_tenants)) RETURN cm, collect(DISTINCT {name: f.name, type: f.type, entity_label: f.entity_label, is_instance_key: f.is_instance_key, required: hf.required, description: hf.description}) AS fields, collect(DISTINCT t.name) AS themes ORDER BY cm.name"
---
Match optional=False
  Path var=None selector=None
    Node var=cm labels=(CatalogModel) props={} where=(OR (IS NULL (Prop (Var cm) tenant_id)) (IN (Prop (Var cm) tenant_id) (Param __scope_tenants)))
  where=(OR (Exists #0) (Exists #1))
    #0 Exists
      Match optional=False
        Path var=None selector=None
          Node var=md labels=(ModelDecision) props={} where=(IN (Prop (Var md) tenant_id) (Param __scope_tenants))
          Rel var=__r0 types=(MATCHED_MODEL) dir=out props={} where=None
          Node var=cm labels=* props={} where=(OR (IN (Prop (Var cm) tenant_id) (Param __scope_tenants)) (AND (IS NULL (Prop (Var cm) tenant_id)) (LabelTest (Var cm) (CatalogModel|EntityLabel|ModelField|Theme))))
        where=None
    #1 Exists
      Match optional=False
        Path var=None selector=None
          Node var=md labels=(ModelDecision) props={} where=(IN (Prop (Var md) tenant_id) (Param __scope_tenants))
          Rel var=__r1 types=(HAS_COMPLEMENTARY_MATCH) dir=out props={} where=None
          Node var=__scope_n0 labels=(ComplementaryMatch) props={} where=(IN (Prop (Var __scope_n0) tenant_id) (Param __scope_tenants))
          Rel var=__r2 types=(REFERS_TO_MODEL) dir=out props={} where=None
          Node var=cm labels=* props={} where=(OR (IN (Prop (Var cm) tenant_id) (Param __scope_tenants)) (AND (IS NULL (Prop (Var cm) tenant_id)) (LabelTest (Var cm) (CatalogModel|EntityLabel|ModelField|Theme))))
        where=None
Match optional=True
  Path var=None selector=None
    Node var=cm labels=* props={} where=(OR (IN (Prop (Var cm) tenant_id) (Param __scope_tenants)) (AND (IS NULL (Prop (Var cm) tenant_id)) (LabelTest (Var cm) (CatalogModel|EntityLabel|ModelField|Theme))))
    Rel var=hf types=(HAS_FIELD) dir=out props={} where=None
    Node var=f labels=(ModelField) props={} where=(OR (IS NULL (Prop (Var f) tenant_id)) (IN (Prop (Var f) tenant_id) (Param __scope_tenants)))
  where=None
Match optional=True
  Path var=None selector=None
    Node var=cm labels=* props={} where=(OR (IN (Prop (Var cm) tenant_id) (Param __scope_tenants)) (AND (IS NULL (Prop (Var cm) tenant_id)) (LabelTest (Var cm) (CatalogModel|EntityLabel|ModelField|Theme))))
    Rel var=__r3 types=(BELONGS_TO_THEME) dir=out props={} where=None
    Node var=t labels=(Theme) props={} where=(OR (IS NULL (Prop (Var t) tenant_id)) (IN (Prop (Var t) tenant_id) (Param __scope_tenants)))
  where=None
Return distinct=False order=((Prop (Var cm) name) ASC) skip=None limit=None
  cm = (Var cm)
  fields = (Func collect DISTINCT (Map (name (Prop (Var f) name)) (type (Prop (Var f) type)) (entity_label (Prop (Var f) entity_label)) (is_instance_key (Prop (Var f) is_instance_key)) (required (Prop (Var hf) required)) (description (Prop (Var hf) description))))
  themes = (Func collect DISTINCT (Prop (Var t) name))
