UNPKG

apollo-flash

Version:

A smart and efficient toolkit to quickly bootstrap an apollo-server project.

54 lines (53 loc) 1.49 kB
import { IResolvers } from "apollo-server-express"; import { Request, Response } from "express"; import withAuth from "graphql-auth"; import { ApolloFlashConfig, ApolloFlashContext } from "./typings"; /** * Helper orchestrator to load you resolver / types definition. * * Also handle authentication using a jwt cookie / header. * * For typescript users : * - AuthScopeEnum is a string enumeration for authentication scope with graphql-auth * - User is your user class / interface. * * @export * @class ApolloFlash * @template AuthScopeEnum * @template User */ export default class ApolloFlash<AuthScopeEnum, User> { private config; private autoImporter; private contextBuilder; constructor(config: ApolloFlashConfig<AuthScopeEnum, User>); /** * Generate type definition from the graphQL server. * * @returns * @memberof ApolloFlash */ generateTypeDefs(): any; /** * Generate * * @returns * @memberof ApolloFlash */ generateRootResolver(): IResolvers; /** * Build apollo-flash required context. * You should merge it with your context. * * Conflict keys are ['auth', 'response'] * * @returns {ApolloFlashContextBuilder<AuthScopeEnum, User>} * @memberof ApolloFlash */ buildContext(params: { req: Request; res: Response; }): Promise<ApolloFlashContext<AuthScopeEnum, User>>; } export * from "./typings"; export { withAuth };