Skip to content

v1.1.0

Compare
Choose a tag to compare
@github-actions github-actions released this 03 Jun 02:52
· 81 commits to main since this release
89b6848

Minor Changes

  • #130 c504479 Thanks @ryota-ka! - Parameterize the returned Middleware type so that this library can be used along with a context-parameterized Koa app.

    In order to utilize this feature, provide your Koa app's State and Context types as type arguments to the koaMiddleware function.

    If you use a context function (for Apollo Server), the State and Context types are positions 1 and 2 like so:

    type KoaState = { state: object };
    type KoaContext = { context: object };
    
    koaMiddleware<GraphQLContext, KoaState, KoaContext>(
      new ApolloServer<GraphQLContext>(),
      //...
      {
        context: async ({ ctx }) => ({ graphqlContext: {} }),
      },
    );

    If you don't use a context function, the State and Context types are positions 0 and 1 like so:

    type KoaState = { state: object };
    type KoaContext = { context: object };
    
    koaMiddleware<KoaState, KoaContext>(
      new ApolloServer<GraphQLContext>(),
      //...
    );