Skip to content

Commit

Permalink
Merge pull request #339 from dmoree/bugfix/create-relationship-update…
Browse files Browse the repository at this point in the history
…-create

Fix cypher params for update.create
  • Loading branch information
darrellwarde authored Jul 21, 2021
2 parents 8e041c7 + 3776db7 commit b7708ec
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/graphql/src/translate/translate-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function translateUpdate({ node, context }: { node: Node; context: Context }): [
operation: "CREATE",
});
createStrs.push(setA[0]);
cypherParams = { ...cypherParams, ...createAndParams[1] };
cypherParams = { ...cypherParams, ...setA[1] };
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ describe("Relationship properties - read", () => {
await session.close();
}
});

test("Create relationship node through update field on end node in a nested update (update -> update)", async () => {
const session = driver.session();

Expand Down Expand Up @@ -295,4 +295,80 @@ describe("Relationship properties - read", () => {
await session.close();
}
});

test("Create a relationship node with relationship properties on end node in a nested update (update -> create)", async () => {
const session = driver.session();

const neoSchema = new Neo4jGraphQL({ typeDefs, driver });

const mutation = `
mutation {
updateMovies(
where: { title: "${movieTitle}" }
create: {
actors: [
{
node: { name: "${actor3}" }
relationship: { screenTime: 60 }
}
]
}
) {
movies {
title
actorsConnection {
edges {
screenTime
node {
name
}
}
}
}
}
}
`;

try {
await neoSchema.checkNeo4jCompat();

const result = await graphql({
schema: neoSchema.schema,
source: mutation,
contextValue: { driver },
});

expect(result.errors).toBeFalsy();

expect(result?.data?.updateMovies?.movies).toEqual([
{
title: movieTitle,
actorsConnection: {
edges: [
{
screenTime: 60,
node: {
name: actor3,
},
},
{
screenTime: 105,
node: {
name: actor2,
},
},
{
screenTime: 105,
node: {
name: actor1,
},
},
],
},
},
]);
} finally {
await session.close();
}
});
});

0 comments on commit b7708ec

Please sign in to comment.