AWS neptune documentation change
Summary
Updated AWS SDK imports to @smithy packages and refactored Node.js code examples to use async/await with proper error handling
Security assessment
Changes involve SDK version updates and code quality improvements without explicit security context or vulnerability fixes
Diff
diff --git a/neptune/latest/userguide/access-graph-opencypher-bolt.md b/neptune/latest/userguide/access-graph-opencypher-bolt.md index 9f586231c..a9c9eebf9 100644 --- a//neptune/latest/userguide/access-graph-opencypher-bolt.md +++ b//neptune/latest/userguide/access-graph-opencypher-bolt.md @@ -366 +366 @@ The Node.js code below uses the AWS SDK for JavaScript version 3 and ES6 syntax - import { HttpRequest } from "@aws-sdk/protocol-http"; + import { HttpRequest } from "@smithy/protocol-http"; @@ -368 +368 @@ The Node.js code below uses the AWS SDK for JavaScript version 3 and ES6 syntax - import { SignatureV4 } from "@aws-sdk/signature-v4"; + import { SignatureV4 } from "@smithy/signature-v4"; @@ -428 +428 @@ The Node.js code below uses the AWS SDK for JavaScript version 3 and ES6 syntax - function unmanagedTxn(driver) { + async function unmanagedTxn(driver) { @@ -431,8 +431,4 @@ The Node.js code below uses the AWS SDK for JavaScript version 3 and ES6 syntax - tx.run(createQuery) - .then((res) => { - const id = res.records[0].get(0); - return tx.run(readQuery, { id: id }); - }) - .then((res) => { - // All good, the transaction will be committed - const msg = res.records[0].get("n.message"); + try { + const created = await tx.run(createQuery); + const matched = await tx.run(readQuery, { id: created.records[0].get(0) }); + const msg = matched.records[0].get("n.message"); @@ -440,2 +436,2 @@ The Node.js code below uses the AWS SDK for JavaScript version 3 and ES6 syntax - }) - .catch(err => { + await tx.commit(); + } catch (err) { @@ -444,2 +440,3 @@ The Node.js code below uses the AWS SDK for JavaScript version 3 and ES6 syntax - }) - .then(() => session.close()); + } finally { + await session.close(); + } @@ -448,6 +445,4 @@ The Node.js code below uses the AWS SDK for JavaScript version 3 and ES6 syntax - createDriver() - .then((driver) => { - unmanagedTxn(driver); - driver.close(); - }) - .catch((err) => { + const driver = await createDriver(); + try { + await unmanagedTxn(driver); + } catch (err) { @@ -455 +450,3 @@ The Node.js code below uses the AWS SDK for JavaScript version 3 and ES6 syntax - }); + } finally { + await driver.close(); + }