🚨 Announcement: A New Chapter for Vendure read more

RequestContextService

RequestContextService

Creates new RequestContext instances.

Signature

class RequestContextService {
  async create(config: {
        req?: Request;
        apiType: ApiType;
        channelOrToken?: Channel | string;
        languageCode?: LanguageCode;
        user?: User;
        activeOrderId?: ID;
    }) => Promise<RequestContext>;
  async fromRequest(req: Request, info?: GraphQLResolveInfo, requiredPermissions?: Permission[], session?: CachedSession) => Promise<RequestContext>;
}

Members

create

async method
v1.5.0
type:
(config: { req?: Request; apiType: ApiType; channelOrToken?: Channel | string; languageCode?: LanguageCode; user?: User; activeOrderId?: ID; }) => Promise<RequestContext>
Creates a RequestContext based on the config provided. This can be useful when interacting with services outside the request-response cycle, for example in stand-alone scripts or in worker jobs.

fromRequest

async method
type:
(req: Request, info?: GraphQLResolveInfo, requiredPermissions?: Permission[], session?: CachedSession) => Promise<RequestContext>
Creates a new RequestContext based on an Express request object. This is used internally in the API layer by the AuthGuard, and creates the RequestContext which is then passed to all resolvers & controllers.