From 1d4da663c91c800fe70ae6aff41d919414d40e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loren=20=F0=9F=A4=93?= Date: Mon, 30 Dec 2019 16:22:41 -0500 Subject: [PATCH 1/3] Deprecate this.db in favor of this.knex, fixes #43 --- CHANGELOG.md | 4 ++++ README.md | 8 ++++---- index.js | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14a0881..3b3540b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.1.0 - 12-30-2019 + +- Deprecate this.db in favor of this.knex + ## v1.0.2 - 10-07-2019 - Fix issue with repeated constructor calls diff --git a/README.md b/README.md index fdb9572..3b8e632 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This package combines the power of [Knex] with the ease of use of [Apollo DataSo In v1.0.0 this lib has a new fluid interface that plays nicely with Knex and stays more true to the spirit of Apollo DataSources. ```js -const query = this.db.select("*").from("fruit").where({ id: 1 }).cache(); +const query = this.knex.select("*").from("fruit").where({ id: 1 }).cache(); query.then(data => /* ... */ ); ``` @@ -33,7 +33,7 @@ const MINUTE = 60; class MyDatabase extends SQLDataSource { getFruits() { - return this.db + return this.knex .select("*") .from("fruit") .where({ id: 1 }) @@ -95,9 +95,9 @@ If no cache is provided in your Apollo server configuration, SQLDataSource falls The context from your Apollo server is available as `this.context`. -### db +### knex -The instance of knex you reference in the constructor is made available as `this.db`. +The knex instance is made available as `this.knex`. ## Debug mode diff --git a/index.js b/index.js index ec6314f..9f0ac74 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,7 @@ class SQLDataSource extends DataSource { this.context; this.cache; this.db = Knex(knexConfig); + this.knex = this.db; const _this = this; if (!this.db.cache) { From 0f4d5c9798dd4ec393c7e112e15edd39bae82f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loren=20=F0=9F=A4=93?= Date: Mon, 30 Dec 2019 17:41:21 -0500 Subject: [PATCH 2/3] Un-deprecate this.db --- CHANGELOG.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b3540b..ce6c559 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## v1.1.0 - 12-30-2019 -- Deprecate this.db in favor of this.knex +- Allow knex instance to be referenced by `this.knex` in addition to `this.db` ## v1.0.2 - 10-07-2019 diff --git a/README.md b/README.md index 3b8e632..37866ae 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ The context from your Apollo server is available as `this.context`. ### knex -The knex instance is made available as `this.knex`. +The knex instance is made available as `this.knex` or `this.db`. ## Debug mode From 05c449faa583758feec566caf1057731c8a7e386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loren=20=F0=9F=A4=93?= Date: Tue, 31 Dec 2019 01:02:49 -0500 Subject: [PATCH 3/3] Update package version to 1.1.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1574b4b..fa0c167 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "datasource-sql", - "version": "1.0.2", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9a0bce6..cd72616 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasource-sql", - "version": "1.0.2", + "version": "1.1.0", "description": "SQL DataSource for Apollo GraphQL projects", "main": "index.js", "scripts": {