From 3d531b63625886aca6147b1bde180170e8356c41 Mon Sep 17 00:00:00 2001 From: Benedict Hobart Date: Mon, 11 Dec 2017 09:12:27 +1100 Subject: [PATCH] fix: add cloning of context prototype for batch queries --- packages/apollo-server-core/src/runHttpQuery.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/apollo-server-core/src/runHttpQuery.ts b/packages/apollo-server-core/src/runHttpQuery.ts index 7bc490cd087..6c3d6563d4f 100644 --- a/packages/apollo-server-core/src/runHttpQuery.ts +++ b/packages/apollo-server-core/src/runHttpQuery.ts @@ -27,7 +27,7 @@ function isQueryOperation(query: DocumentNode, operationName: string) { return operationAST.operation === 'query'; } -export function isFunction(arg: any): arg is Function { +function isFunction(arg: any): arg is Function { return typeof arg === 'function'; } @@ -101,11 +101,11 @@ export async function runHttpQuery(handlerArguments: Array, request: HttpQu } } - let context = optionsObject.context; + let context = optionsObject.context || {}; if (isFunction(context)) { context = context(); } else if (isBatch) { - context = Object.assign({}, context || {}); + context = Object.assign({}, Object.getPrototypeOf(context), context); } let params = {