Last active
May 1, 2018 15:27
-
-
Save AndrewIngram/deb095494fc03c8d09cb643eed05ee28 to your computer and use it in GitHub Desktop.
Blah
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 authRequired = resolver => (obj, args, context, info) => { | |
if (!context.user) { | |
return new UserError('Authentication Required'); | |
} | |
return resolver(obj, args, context, info); | |
} | |
const myResolver = authRequired((obj, args, context, info) => { | |
// Normal logic | |
}); | |
const userCanModerateChannel = (channelIdArgPath) => resolver => (obj,args, context, info) => { | |
if (!context.user || !context.user.canModerateChannel(_.get(args, channelIdArgPath)) { | |
return new UserError('You don’t have permission to manage this channel'); | |
} | |
return resolver(obj, args, context, info); | |
} | |
const myResolver = userCanModerateChannel('input.id')((obj, args, context, info) => { | |
// Normal logic | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment