Last active
December 26, 2017 15:53
-
-
Save thiago-sydow/2fd3f111ee211b544bed0ef0ecdc6543 to your computer and use it in GitHub Desktop.
Files used in the Medium post about Field Instrumentation Raw
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
def authorization_proc(field) | |
permission = field.metadata[:scoped_collection] | |
original_resolve_proc = field.resolve_proc | |
->(obj, args, ctx) { | |
initial_scope = original_resolve_proc.call(obj, args, ctx) | |
scope = permission[:policy_class]::Scope.new(ctx[:current_user], initial_scope) | |
resolved = scope.resolve | |
resolved | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment