Skip to content

Instantly share code, notes, and snippets.

@nabiltntn
Created December 28, 2018 13:33
Show Gist options
  • Select an option

  • Save nabiltntn/017a8321d5cc61572c69ab98682eb341 to your computer and use it in GitHub Desktop.

Select an option

Save nabiltntn/017a8321d5cc61572c69ab98682eb341 to your computer and use it in GitHub Desktop.
// For resolvers that require authenticated users with SUPER_ADMIN role
export const isSuperAdminResolver = (resolver, trackDetails) =>
isAuthenticated.createResolver((root, args, context) => {
if (context.user.role !== Constants.UsersRolesToIds.SUPER_ADMIN) {
throw new Errors.ForbiddenError();
}
return executeWithTracking(resolver, root, args, context, trackDetails);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment