Skip to content

Commit

Permalink
fix: add cloning of context prototype for batch queries
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyhobart committed Dec 11, 2017
1 parent fac797e commit b459b2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/apollo-server-core/src/runHttpQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down Expand Up @@ -101,11 +101,11 @@ export async function runHttpQuery(handlerArguments: Array<any>, 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 = {
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-server-integration-testsuite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,9 @@ export default (createApp: CreateAppFunc, destroyApp?: DestroyAppFunc) => {
});
});

it('executes batch context if it is a function', () => {
it('executes batch context if it is a function', async () => {
let callCount = 0;
app = createApp({graphqlOptions: {
app = await createApp({graphqlOptions: {
schema,
context: () => {
callCount++;
Expand Down

0 comments on commit b459b2f

Please sign in to comment.