For each merge

Hi there guys i was asking is there a way to implement create multiple relationships at a go in grand stack lets say you have a product that you want to add to multiple categories?

You can create custom Cypher mutations and do something like unwind a list of nodes you want to create relationships with. Otherwise, you'll have to do something like map over an array of things and run a single mutation per node you want to add a relationship to.

For the Product with different categories, I would suggest using labels.
Labels are the number 1 fastest thing in Neo4j and a node can have more then one.

Depend of how you deal with your categories.

Reviving this question in the wake of @neo4j/graphql and its introduction of nested mutations.

Just in case I missed something, is there a way of generating a mutation query with an arbitrary number of nested subjects? To extend @fabish_kamz' question, I'd want to be able to specify any number of categories, including zero.

I'm pretty sure the answer is "no" and that I'd still need to run a mutation per target node, but I'd also like to be clear on whether the limitation is in this client library, the Apollo server or in GraphQL. If it's in the client library, it's something I could work around with sufficiently smart query-generating code, but if it's inherent then I can put that time to better use.

I asked this question in discord channel. Indeed there is a way to create multiple relationships from a node to multiple nodes but only works on updating. Which means that the nodes must exist before creating the relationships. There's no mechanism to do this on on Creating yet but they are working on it. If you're interested in knowing more join the neo4j discord channel.

1 Like

Thanks for confirming that answer; I see which way I need to go, now.
And yes, I really should join the Discord channel.