Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
Use driver transaction functions
Browse files Browse the repository at this point in the history
  • Loading branch information
johnymontana committed Jan 21, 2019
1 parent d790e52 commit 1fbc747
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ export async function neo4jgraphql(
let result;

try {
result = await session.run(query, cypherParams);
//console.log("result: "+JSON.stringify(result, null, 2));
if (isMutation(resolveInfo)) {
result = await session.writeTransaction(tx => {
return tx.run(query, cypherParams);
});
} else {
result = await session.readTransaction(tx => {
return tx.run(query, cypherParams);
});
}
} finally {
session.close();
}
Expand Down

0 comments on commit 1fbc747

Please sign in to comment.