Skip to content

Commit 2be71bd

Browse files
committed
v0.1.4 - fix duplicate logggers
1 parent 1fbdfc7 commit 2be71bd

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.1.4 - 28-11-2018
4+
5+
- Fix multiple onQuery logging events [#5]
6+
37
## v0.1.3 - 20-11-2018
48

59
- Add support for multiple node and npm versions [#3]

SQLDataSource.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ const SQLCache = require("./SQLCache");
44

55
const { DEBUG } = process.env;
66

7+
let hasLogger = false;
8+
79
class SQLDataSource extends DataSource {
810
initialize(config) {
9-
if (DEBUG) knexTinyLogger(this.knex); // Add a logging utility for debugging
1011
this.context = config.context;
1112
this.db = this.knex;
13+
14+
if (DEBUG && !hasLogger) {
15+
hasLogger = true; // Prevent duplicate loggers
16+
knexTinyLogger(this.db); // Add a logging utility for debugging
17+
}
18+
1219
this.sqlCache = new SQLCache(config.cache, this.knex);
1320
this.getBatched = query => this.sqlCache.getBatched(query);
1421
this.getCached = (query, ttl) => this.sqlCache.getCached(query, ttl);

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "datasource-sql",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "SQL DataSource for Apollo GraphQL projects",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)