neo4j / neo4j-javascript-driver

Neo4j Bolt driver for JavaScript
https://neo4j.com/docs/javascript-manual/current/
Apache License 2.0
839 stars 148 forks source link

Introduce `auth` config to `Driver.executeQuery` #1177

Closed bigmontz closed 4 months ago

bigmontz commented 5 months ago

The AuthToken will be used for executing the query.

By default, the query executor will use connections authenticated with the AuthToken configured on driver creation. This new configuration allows switching user and/or authorization information for the underlying transaction's lifetime.

Example:

const { records } = await driver.executeQuery('RETURN $abc', { abc: 'dfe' }, {
   database: 'neo4j',
   auth: neo4j.auth.basic('otheruser', 'sup3rDup3rS3cret')
})

[!NOTE] This option is only available when the driver is connected to Neo4j Database servers which supports Bolt 5.1 or newer.