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

Commit

Permalink
Update driver userAgent
Browse files Browse the repository at this point in the history
To help facilitate query debugging set the driver user agent value
to identify queries generated by neo4j-graphql.js
  • Loading branch information
johnymontana committed Dec 26, 2019
1 parent d3de5a0 commit 5a2e52e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { augmentTypes, transformNeo4jTypes } from './augment/types/types';
import { buildDocument } from './augment/ast';
import { augmentDirectiveDefinitions } from './augment/directives';

const neo4jGraphQLVersion = require('../package.json').version;

const debug = Debug('neo4j-graphql-js');

export async function neo4jgraphql(
Expand All @@ -34,6 +36,12 @@ export async function neo4jgraphql(
throw new Error(checkRequestError(context));
}

if (!context.driver) {
throw new Error(
"No Neo4j JavaScript driver instance provided. Please ensure a Neo4j JavaScript driver instance is injected into the context object at the key 'driver'."
);
}

let query;
let cypherParams;

Expand All @@ -57,6 +65,8 @@ instead: \`DEBUG=neo4j-graphql-js\`.
debug('%s', query);
debug('%s', JSON.stringify(cypherParams, null, 2));

context.driver._userAgent = `neo4j-graphql-js/${neo4jGraphQLVersion}`;

// TODO: Is this a 4.0 driver instance? Check bolt path for default database name and use that when creating the session
const session = context.driver.session();
let result;
Expand Down

0 comments on commit 5a2e52e

Please sign in to comment.