Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const authenticationMiddleware = Intermediary.createMiddleware(
- (ctx, next, parent, queryArgs, gqlContext) => {
- if(!gqlContext.userId){
- throw new Error('NOT_ALLOWED');
- }
- return next(parent, queryArgs, gqlContext)
- }
- )
- const authenticator = new Intermediary([authenticationMiddleware]);
- const loginResolver = (parent, queryArgs, gqlContext) => {
- // Unprotected resolver
- }
- const createProductResolver = authenticator.involve((parent, queryArgs, gqlContext) => {
- // Protected resolver
- // Only a logged in person can access
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement