Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 767 Bytes

resolver_role_permissions.md

File metadata and controls

27 lines (22 loc) · 767 Bytes

Resolver Role Permissions

You can make use of REQUIRE_ROLES wrapper function to validate the Roles' of logged in User.

from frappe_graphql import REQUIRE_ROLES

@REQUIRE_ROLES(role="Guest")
def ping_resolver(obj, info, **kwargs):
    return "pong
  • You can pass in multiple roles:
    from frappe_graphql import REQUIRE_ROLES
    
    @REQUIRE_ROLES(role=["Accounts User", "Accounts Manager"])
    def ping_resolver(obj, info, **kwargs):
        return "pong
  • You can control the exception raised. frappe.PermissionError is raised by default
    from frappe_graphql import REQUIRE_ROLES
    
    @REQUIRE_ROLES(role="Accounts User", exc=MyCustomException)
    def ping_resolver(obj, info, **kwargs):
        return "pong