Skip to content

Instantly share code, notes, and snippets.

@benawad
Created February 5, 2019 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benawad/a090982440cf7fbac55ca4d07e909e40 to your computer and use it in GitHub Desktop.
Save benawad/a090982440cf7fbac55ca4d07e909e40 to your computer and use it in GitHub Desktop.
const someFunc = ({ context }: ResolverData) => {
(context as any).value2 = "another value";
};
const addToContext: MiddlewareFn = (data, next) => {
(data.context as any).value = "new value";
someFunc(data);
return next();
};
@Query(() => String)
@UseMiddleware(addToContext)
async hello(@Ctx() ctx: any) {
return ctx.value + ctx.value2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment