SHARE
TWEET

Untitled

a guest Jul 15th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const authenticationMiddleware = Intermediary.createMiddleware(
  2.   (ctx, next, parent, queryArgs, gqlContext) => {
  3.     if(!gqlContext.userId){
  4.       throw new Error('NOT_ALLOWED');
  5.     }
  6.     return next(parent, queryArgs, gqlContext)
  7.   }
  8. )
  9.  
  10. const authenticator = new Intermediary([authenticationMiddleware]);
  11.  
  12. const loginResolver = (parent, queryArgs, gqlContext) => {
  13.   // Unprotected resolver
  14. }
  15.  
  16. const createProductResolver = authenticator.involve((parent, queryArgs, gqlContext) => {
  17.   // Protected resolver
  18.   // Only a logged in person can access
  19. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top