Skip to content

Commit 8290923

Browse files
committed
fix: apollo server expects context to always return a promise
1 parent a904e67 commit 8290923

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/apollo/lib/drivers/apollo-base.driver.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,20 @@ export abstract class ApolloBaseDriver<
238238
originalOptions: ApolloDriverConfig = { ...targetOptions },
239239
) {
240240
if (!targetOptions.context) {
241-
targetOptions.context = ({ req, request }) => ({ req: req ?? request });
241+
targetOptions.context = async ({ req, request }) => ({
242+
req: req ?? request,
243+
});
242244
} else if (isFunction(targetOptions.context)) {
243245
targetOptions.context = async (...args: unknown[]) => {
244246
const ctx = await (originalOptions.context as Function)(...args);
245247
const { req, request } = args[0] as Record<string, unknown>;
246248
return this.assignReqProperty(ctx, req ?? request);
247249
};
248250
} else {
249-
targetOptions.context = ({ req, request }: Record<string, unknown>) => {
251+
targetOptions.context = async ({
252+
req,
253+
request,
254+
}: Record<string, unknown>) => {
250255
return this.assignReqProperty(
251256
originalOptions.context as Record<string, any>,
252257
req ?? request,

0 commit comments

Comments
 (0)