# Cypher dynamic node based on unwind list value

**URL:** <https://community.neo4j.com/t/cypher-dynamic-node-based-on-unwind-list-value/34339>\
**Category:** Cypher\
**Tags:** cypher\
**Created:** [February 25, 2021, 3:02pm UTC](https://community.neo4j.com/t/cypher-dynamic-node-based-on-unwind-list-value/34339 "2021-02-25T15:02:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alili.arif](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/alili.arif/32/16011_2.png) [@alili.arif](https://community.neo4j.com/u/alili.arif)\
**Post date:** [February 25, 2021, 3:02pm UTC](https://community.neo4j.com/t/cypher-dynamic-node-based-on-unwind-list-value/34339/1 "2021-02-25T15:02:03Z")

</div>

Hi all,

I am writing cypher query that inserts values based on JSON values passed with UNWIND. Values are working as expected, but I want to make node name dynamic, based on "class" value on JSON.

Here's working example

```auto
UNWIND [{id: "199" , container_id: "203", acl_id: "1047", class: "Usergroup" }] as event 
MATCH (u:User {id: event.id}) // I am trying to make User node dynamic in this line
MATCH (ug:Usergroup {id: event.container_id}) 
OPTIONAL MATCH (u)-[r:CHILD_OF]->(:Usergroup) 
DELETE r 
SET u.acl_id = event.acl_id ;
CREATE (u)-[rel:CHILD_OF]->(ug);

```

When I try to change this row

```auto
MATCH (u:User {id: event.id}) 

```

to

```auto
MATCH (u:event.class {id: event.id}) 

```

I see this error "Neo.ClientError.Statement.SyntaxError: Invalid input '.': expected ")", "{" or "$" "

What am I doing wrong here?

---

<div class="post-metadata">

**Author:** ![dana\_canzano](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dana_canzano/32/27392_2.png) [@dana\_canzano](https://community.neo4j.com/u/dana_canzano)\
**Post date:** [February 25, 2021, 5:14pm UTC](https://community.neo4j.com/t/cypher-dynamic-node-based-on-unwind-list-value/34339/2 "2021-02-25T17:14:38Z")

</div>

not so much that you are doing anything wrong other than labels can not be dynamically set, primarily because the query planner might not know what value `event.class` represents. In your case its clear event.class only has 1 value but thats specific to your case. If the `UNWIND` as a list of 10 items and each item had a different class value, i.e. `UserGroup`, `Group`, `User`, etc.. then the planner is simply not able to determine how it should run said match when it is for a variety of different labels

This would be no different than in a RDBMS world if one ran

```auto
select * from $Table ;

```

and where $Table could for example be one of 10 different values

Now as to how to overcome this you might want to consider using apoc.cypher.run. See [apoc.cypher.run - APOC Extended Documentation](https://neo4j.com/labs/apoc/4.1/overview/apoc.cypher/apoc.cypher.run/#usage-apoc.cypher.run)
