Update to TypeScript 3.1

This commit is contained in:
Martijn Walraven 2018-10-05 17:18:13 +02:00
parent 0ebf8900a0
commit 5d03ae1650
4 changed files with 11 additions and 8 deletions

6
package-lock.json generated
View file

@ -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": {

View file

@ -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"
},

View file

@ -313,7 +313,7 @@ export async function runHttpQuery(
context = {} as Record<string, any>;
} 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.',
);

View file

@ -20,7 +20,7 @@ export type EndHandler = (...errors: Array<Error>) => void;
// arguments.
type StartHandlerInvoker<TContext = any> = (
ext: GraphQLExtension<TContext>,
) => void;
) => EndHandler | void;
// Copied from runQuery in apollo-server-core.
// XXX Will this work properly if it's an identical interface of the