Created
February 5, 2019 20:53
-
-
Save benawad/a090982440cf7fbac55ca4d07e909e40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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