You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
one has a where query that returns two or more nodes (in the connect statement), this leads to the equal number of nodes being created by the create statement. Expected behavior would be to create only one instance.
Type definitions
type A {
ID: ID! @id
name: String!
rel_b: [B] @relationship(type: "REL_B", direction: OUT)
rel_c: [C] @relationship(type: "REL_C", direction: OUT)
}
type B {
ID: ID! @id
name: String!
}
type C {
ID: ID! @id
name: String!
}
Cypher:
CALL {
CREATE (this0:A)
SET this0.ID = randomUUID()
SET this0.name = $this0_name
WITH this0
OPTIONAL MATCH (this0_rel_b_connect0:B)
WHERE this0_rel_b_connect0.name IN $this0_rel_b_connect0_name_IN
FOREACH(_ IN CASE this0_rel_b_connect0 WHEN NULL THEN [] ELSE [1] END |
MERGE (this0)-[:REL_B]->(this0_rel_b_connect0)
)
WITH this0
CREATE (this0_rel_c0:C)
SET this0_rel_c0.ID = randomUUID()
SET this0_rel_c0.name = $this0_rel_c0_name
MERGE (this0)-[:REL_C]->(this0_rel_c0)
RETURN this0
}
RETURN
this0 { .name, rel_b: [ (this0)-[:REL_B]->(this0_rel_b:B) | this0_rel_b { .name } ], rel_c: [ (this0)-[:REL_C]->(this0_rel_c:C) | this0_rel_c { .name } ] } AS this0
Params:
{
"this0_name": "test_A",
"this0_rel_b_connect0_name_IN": [
"test_B1",
"test_B2"
],
"this0_rel_c0_name": "onlyOneShouldBeCreated"
}
I noticed, that adding in a DISTINCT after the WITH fixes the problem.
This can be achieved by changing line 47 of @neo4j/graphql/dist/translate/create-create-and-params.js. (@neo4j/graphql:1.0.0)
The text was updated successfully, but these errors were encountered:
Thanks, @JDFischbach for submitting this issue, with your instructions I can replicate it. I'll add this to our working board and we will look into a fix soon.
Describe the bug
When during a create call:
one has a where query that returns two or more nodes (in the connect statement), this leads to the equal number of nodes being created by the create statement. Expected behavior would be to create only one instance.
Type definitions
To Reproduce
Steps to reproduce the behavior:
and
{as{name, rel_b{name}, rel_c{name, ID}}}
multiple nodes of type C have been created.
Expected behavior
Only a single instance is created
System (please complete the following information):
Possible Fix
The created Cypher looks as follows:
I noticed, that adding in a
DISTINCT
after theWITH
fixes the problem.This can be achieved by changing line 47 of @neo4j/graphql/dist/translate/create-create-and-params.js. (@neo4j/graphql:1.0.0)
The text was updated successfully, but these errors were encountered: