Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  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. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement