diff --git a/index.ts b/index.ts index 5039c36..127cc2b 100644 --- a/index.ts +++ b/index.ts @@ -43,7 +43,7 @@ export class DataLoaderInterceptor implements NestInterceptor { const graphqlExecutionContext = GqlExecutionContext.create(context); const ctx = graphqlExecutionContext.getContext(); - if (ctx[NEST_LOADER_CONTEXT_KEY] === undefined) { + if (ctx && ctx[NEST_LOADER_CONTEXT_KEY] === undefined) { ctx[NEST_LOADER_CONTEXT_KEY] = { contextId: ContextIdFactory.create(), getLoader: (type: string) : Promise> => {