From 5d03ae1650f7eb71ef220def57713167c39d7ee2 Mon Sep 17 00:00:00 2001 From: Martijn Walraven Date: Fri, 5 Oct 2018 17:18:13 +0200 Subject: [PATCH] Update to TypeScript 3.1 --- package-lock.json | 6 +++--- package.json | 2 +- packages/apollo-server-core/src/runHttpQuery.ts | 9 ++++++--- packages/graphql-extensions/src/index.ts | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index f74410e0..768b34d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12470,9 +12470,9 @@ "dev": true }, "typescript": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.3.tgz", - "integrity": "sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.1.tgz", + "integrity": "sha512-Veu0w4dTc/9wlWNf2jeRInNodKlcdLgemvPsrNpfu5Pq39sgfFjvIIgTsvUHCoLBnMhPoUA+tFxsXjU6VexVRQ==", "dev": true }, "uglify-js": { diff --git a/package.json b/package.json index 9f5d46ba..40b9b3b2 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "test-listen": "1.1.0", "ts-jest": "23.1.4", "tslint": "5.11.0", - "typescript": "3.0.3", + "typescript": "3.1.1", "ws": "6.0.0", "yup": "0.26.5" }, diff --git a/packages/apollo-server-core/src/runHttpQuery.ts b/packages/apollo-server-core/src/runHttpQuery.ts index e49d1a7b..158f5d43 100644 --- a/packages/apollo-server-core/src/runHttpQuery.ts +++ b/packages/apollo-server-core/src/runHttpQuery.ts @@ -313,7 +313,7 @@ export async function runHttpQuery( context = {} as Record; } else if (typeof context === 'function') { try { - context = await context(); + context = await (context as Function)(); } catch (e) { e.message = `Context creation failed: ${e.message}`; // For errors that are not internal, such as authentication, we @@ -342,11 +342,14 @@ export async function runHttpQuery( for (const dataSource of Object.values(dataSources)) { if (dataSource.initialize) { - dataSource.initialize({ context, cache: optionsObject.cache! }); + dataSource.initialize({ + context: context!, + cache: optionsObject.cache!, + }); } } - if ('dataSources' in context) { + if ('dataSources' in context!) { throw new Error( 'Please use the dataSources config option instead of putting dataSources on the context yourself.', ); diff --git a/packages/graphql-extensions/src/index.ts b/packages/graphql-extensions/src/index.ts index b4455109..1c4ed015 100644 --- a/packages/graphql-extensions/src/index.ts +++ b/packages/graphql-extensions/src/index.ts @@ -20,7 +20,7 @@ export type EndHandler = (...errors: Array) => void; // arguments. type StartHandlerInvoker = ( ext: GraphQLExtension, -) => void; +) => EndHandler | void; // Copied from runQuery in apollo-server-core. // XXX Will this work properly if it's an identical interface of the