From 1fbc747ec090e538f61f192f77749eb7f1aa878a Mon Sep 17 00:00:00 2001 From: johnymontana Date: Mon, 21 Jan 2019 16:58:00 -0700 Subject: [PATCH] Use driver transaction functions --- src/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 4c342125..77340f41 100644 --- a/src/index.js +++ b/src/index.js @@ -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(); }