diff --git a/CHANGELOG.md b/CHANGELOG.md index fe50cc5..e5a6d13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.5.0 - 08-09-2021 + +- Add types for `this.db` and `this.context` ( Thanks @astorije ) + ## v1.4.1 - 04-09-2021 - Support GraphQL versions >= v14 diff --git a/index.d.ts b/index.d.ts index c361cfa..19b1e35 100644 --- a/index.d.ts +++ b/index.d.ts @@ -7,7 +7,9 @@ declare module "knex" { } } -export class SQLDataSource extends DataSource { +export class SQLDataSource extends DataSource { + protected context: TContext; protected knex: Knex; + protected db: Knex; constructor(config: Knex.Config | Knex); } diff --git a/index.test-d.ts b/index.test-d.ts index 23b13b4..5424263 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -2,12 +2,24 @@ import { expectError, expectType } from "tsd"; import Knex from "knex"; import { SQLDataSource } from "./index"; +interface MyTestContext { + foo: string; +} + type MyRow = { id: string; value: number }; -class MyTestDataSource extends SQLDataSource { +class MyTestDataSource extends SQLDataSource { public testKnexExists() { expectType(this.knex); } + public testDbExists() { + expectType(this.db); + } + + public testContextExists() { + expectType(this.context); + } + public async testCacheFunctionPassesResult() { expectType( await this.knex("mytable") diff --git a/package-lock.json b/package-lock.json index 6b49277..d7f8bc6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "datasource-sql", - "version": "1.4.1", + "version": "1.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "datasource-sql", - "version": "1.4.0", + "version": "1.5.0", "license": "MIT", "dependencies": { "apollo-datasource": "^0.6.3", diff --git a/package.json b/package.json index 1f9de11..2ce9994 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "datasource-sql", - "version": "1.4.1", + "version": "1.5.0", "description": "SQL DataSource for Apollo GraphQL projects", "main": "index.js", - "typings": "index.d.ts", + "types": "index.d.ts", "scripts": { "lint": "prettier '**/*.js' && eslint '**/*.js'", "lint:fix": "prettier --write '**/*.{js,ts}' && eslint --fix '**/*.js'",