title: How to programmatically add constraints to Neo4J Cypher queries
body: <p>I am writing a sever plugin for Neo4J. The plugin receives a cypher query, and executes it. Currently, my implementation uses a <code>CypherExecutor</code>. </p>
  
  <p>I now need to further constrain the results. (For example, imagine that the results need to be filtered by ACLs.)</p>
  
  <p>One approach is to filter the results after executing the query. I'd rather not do this, for performance reasons as well as other limitations (for example, any aggregate results would be wrong.)</p>
  
  <p>I considered adding the constraints to the query itself. I've looked at the <code>command.AbstractQuery</code> subclasses produced using the <code>CypherParser</code>. That object model is immutable. </p>
  
  <p>I am wondering whether I will need to resort to cloning Neo4J's ExecutionEngine and CypherCompiler, just to extend the ExecutionPlanBuilder... I would like to avoid this option if at all possible.</p>
  
  <p>Any recommendations about how this can be done?</p>
  
  <p>In my case, I am simply trying to simulate multiple isolated graphs. I am OK with how this might be modeled -- whether I add a 'tenantId' to each node, or maintain a tenant node and add <code>(:Tenant)&lt;-[:scopedTo]-(n)</code> relationships to every node.</p>