Apoc.do.when as the inner statement of apoc.periodic.iterate

I have the following code that raises an error if multiple lines are returned in the outer statement:

CALL apoc.periodic.iterate(
"MATCH (cl:GraphProperty_GECluster) <-[:in_GECluster]- (a:alias) 
WITH cl, a
OPTIONAL MATCH path = (a) -[co_authored]- (b:alias) <-[:aka]-(pb:Person) WHERE a.`authors.LastName` = b.`authors.LastName` AND a.`authors.ForeName` = b.`authors.ForeName` AND pb.component = cl.GraphProperty_component 
RETURN count(path) > 0  AS bool, a, cl",
"
WITH bool, a, cl
CALL apoc.do.when(
		bool ,
		'MERGE (p:Person:GECluster {`authors.ForeName` : a.`authors.ForeName`, `authors.LastName`: a.`authors.LastName`, component: cl.GraphProperty_component}) CREATE (p)-[:aka]-> (a)',
		'CREATE (p:Person:GECluster {`authors.ForeName` : a.`authors.ForeName`, `authors.LastName`: a.`authors.LastName`, component: cl.GraphProperty_component}) CREATE (p)-[:aka]-> (a)',
	{bool : bool, a: a, cl: cl}) 
YIELD value
RETURN value" , {batchSize:5000, iterateList:true})           
YIELD batches, total, errorMessages
RETURN batches, total, errorMessages

raises the error

Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke procedure `apoc.periodic.iterate`: Caused by: org.neo4j.cypher.internal.v3_5.util.InternalException: Expected 
RegularPlannerQuery(QueryGraph {Nodes: ['  a@55', '  cl@7'], Rels: ['(  cl@7)-<-[  UNNAMED36:in_GECluster]--(  a@55)'], Predicates: ['`  a@55`:alias', '`  cl@7`:GraphProperty_GECluster'], Optional Matches: : ['QueryGraph {Nodes: ['  a@55', 'b', 'pb'], Rels: ['(  a@55)--[co_authored]--(b)', '(b)-<-[  UNNAMED129:aka]--(pb)'], Arguments: ['  a@55', '  cl@7'], Predicates: ['not `  UNNAMED129` = co_authored', '`  a@55`.`authors.ForeName` = b.`authors.ForeName`', 'b:alias', 'pb:Person', '`  a@55`.`authors.LastName` = b.`authors.LastName`', 'pb.component = `  cl@7`.GraphProperty_component']}']},InterestingOrder(List(),List()),AggregatingQueryProjection(Map(  AGGREGATION327 -> Variable(  a@55),   AGGREGATION330 -> Variable(  cl@7)),Map(  AGGREGATION301 -> FunctionInvocation(Namespace(List()),FunctionName(count),false,Vector(PathExpression(NodePathStep(Variable(  a@55),SingleRelationshipPathStep(Variable(co_authored),BOTH,SingleRelationshipPathStep(Variable(  UNNAMED129),INCOMING,NilPathStep))))),false)),QueryShuffle(List(),None,None),Selections(Set())),Some(RegularPlannerQuery(QueryGraph {Arguments: ['  AGGREGATION301', '  AGGREGATION327', '  AGGREGATION330']},InterestingOrder(List(),List()),RegularQueryProjection(Map(bool -> GreaterThan(Variable(  AGGREGATION301),Parameter(  AUTOINT0,Integer)), a -> Variable(  AGGREGATION327), cl -> Variable(  AGGREGATION330)),QueryShuffle(List(),None,None),Selections(Set())),None))) 


Instead, got: 
RegularPlannerQuery(QueryGraph {Nodes: ['  a@55', '  cl@7'], Rels: ['(  cl@7)-<-[  UNNAMED36:in_GECluster]--(  a@55)'], Predicates: ['`  cl@7`:GraphProperty_GECluster', '`  a@55`:alias'], Optional Matches: : ['QueryGraph {Nodes: ['  a@55', 'b', 'pb'], Rels: ['(  a@55)--[co_authored]--(b)', '(b)-<-[  UNNAMED129:aka]--(pb)'], Arguments: ['  a@55'], Predicates: ['not `  UNNAMED129` = co_authored', '`  a@55`.`authors.ForeName` = b.`authors.ForeName`', 'b:alias', 'pb:Person', '`  a@55`.`authors.LastName` = b.`authors.LastName`']}']},InterestingOrder(List(),List()),AggregatingQueryProjection(Map(  AGGREGATION327 -> Variable(  a@55),   AGGREGATION330 -> Variable(  cl@7)),Map(  AGGREGATION301 -> FunctionInvocation(Namespace(List()),FunctionName(count),false,Vector(PathExpression(NodePathStep(Variable(  a@55),SingleRelationshipPathStep(Variable(co_authored),BOTH,SingleRelationshipPathStep(Variable(  UNNAMED129),INCOMING,NilPathStep))))),false)),QueryShuffle(List(),None,None),Selections(Set())),Some(RegularPlannerQuery(QueryGraph {Arguments: ['  AGGREGATION301', '  AGGREGATION327', '  AGGREGATION330']},InterestingOrder(List(),List()),RegularQueryProjection(Map(bool -> GreaterThan(Variable(  AGGREGATION301),Parameter(  AUTOINT0,Integer)), a -> Variable(  AGGREGATION327), cl -> Variable(  AGGREGATION330)),QueryShuffle(List(),None,None),Selections(Set())),None)))
Plan: Projection(Map(bool -> GreaterThan(Variable(  AGGREGATION301),Parameter(  AUTOINT0,Integer)), a -> Variable(  AGGREGATION327), cl -> Variable(  AGGREGATION330))) {
  LHS -> Apply() {
    LHS -> Aggregation(Map(  AGGREGATION327 -> Variable(  a@55),   AGGREGATION330 -> Variable(  cl@7)), Map(  AGGREGATION301 -> FunctionInvocation(Namespace(List()),FunctionName(count),false,Vector(PathExpression(NodePathStep(Variable(  a@55),SingleRelationshipPathStep(Variable(co_authored),BOTH,SingleRelationshipPathStep(Variable(  UNNAMED129),INCOMING,NilPathStep))))),false))) {
      LHS -> RightOuterHashJoin(Set(  a@55)) {
        LHS -> Selection(Ands(Set(Not(Equals(Variable(  UNNAMED129),Variable(co_authored))), Equals(Property(Variable(  a@55),PropertyKeyName(authors.ForeName)),Property(Variable(b),PropertyKeyName(authors.ForeName))), Equals(Property(Variable(  a@55),PropertyKeyName(authors.LastName)),Property(Variable(b),PropertyKeyName(authors.LastName)))))) {
          LHS -> Expand(b, BOTH, List(),   a@55, co_authored, ExpandAll) {
            LHS -> Selection(Ands(Set(HasLabels(Variable(b),List(LabelName(alias)))))) {
              LHS -> Expand(pb, OUTGOING, List(RelTypeName(aka)), b,   UNNAMED129, ExpandAll) {
                LHS -> NodeByLabelScan(pb, LabelName(Person), Set()) {}
              }
            }
          }
        }
        RHS -> Selection(Ands(Set(HasLabels(Variable(  a@55),List(LabelName(alias)))))) {
          LHS -> Expand(  cl@7, INCOMING, List(RelTypeName(in_GECluster)),   a@55,   UNNAMED36, ExpandAll) {
            LHS -> NodeByLabelScan(  cl@7, LabelName(GraphProperty_GECluster), Set()) {}
          }
        }
      }
    }
    RHS -> Argument(Set(  AGGREGATION327,   AGGREGATION330,   AGGREGATION301)) {}
  }
}

On the other hand,

CALL apoc.periodic.iterate(
"MATCH (cl:GraphProperty_GECluster) <-[:in_GECluster]- (a:alias) WHERE id(a) = 9963
WITH cl, a
OPTIONAL MATCH path = (a) -[co_authored]- (b:alias) <-[:aka]-(pb:Person) WHERE a.`authors.LastName` = b.`authors.LastName` AND a.`authors.ForeName` = b.`authors.ForeName` AND pb.component = cl.GraphProperty_component 
RETURN count(path) > 0  AS bool, a, cl",
"
WITH bool, a, cl
CALL apoc.do.when(
		bool ,
		'MERGE (p:Person:GECluster {`authors.ForeName` : a.`authors.ForeName`, `authors.LastName`: a.`authors.LastName`, component: cl.GraphProperty_component}) CREATE (p)-[:aka]-> (a)',
		'CREATE (p:Person:GECluster {`authors.ForeName` : a.`authors.ForeName`, `authors.LastName`: a.`authors.LastName`, component: cl.GraphProperty_component}) CREATE (p)-[:aka]-> (a)',
	{bool : bool, a: a, cl: cl}) 
YIELD value
RETURN value" , {batchSize:5000, iterateList:true})           
YIELD batches, total, errorMessages
RETURN batches, total, errorMessages

runs without erroring. What am I missing?

Thanks,
Lavanya

Why would you even want to do this?

CALL apoc.do.when(
		bool ,
		'MERGE (p:Person:GECluster {`authors.ForeName` : a.`authors.ForeName`, `authors.LastName`: a.`authors.LastName`, component: cl.GraphProperty_component}) CREATE (p)-[:aka]-> (a)',
		'CREATE (p:Person:GECluster {`authors.ForeName` : a.`authors.ForeName`, `authors.LastName`: a.`authors.LastName`, component: cl.GraphProperty_component}) CREATE (p)-[:aka]-> (a)',
	{bool : bool, a: a, cl: cl})

Makes no sense? Just use MERGE in both cases?

I want to create a new node if bool is false.