juniper icon indicating copy to clipboard operation
juniper copied to clipboard

please add functional directives

Open bionicles opened this issue 4 years ago • 1 comments

Is your feature request related to a problem? Please describe. I would like to use Juniper but unfortunately, it's critical for my use case to be able to assign functions to custom directives for fine-grained attribute-based access control

Describe the solution you'd like some way to define a directive and assign that to a function. basically, the same thing as graphql-tools.js directiveResolvers, where you pass a directive-name: function pair, and it just makes a directive for each function. Multiple directives can stack, like middleware, using some next() function

Describe alternatives you've considered I guess I could use Node.js and graphql-tools but I really want to play with rust because I admire the language. Just can't sacrifice security of these directives

Additional context an auth directive could perform some function on the user, database tuple, and return a boolean authorized/unauthorized; users could use this to quickly and cleanly secure their api

bionicles avatar Mar 06 '21 14:03 bionicles

not the same, but you can do that inside your resolvers : https://graphql-rust.github.io/types/objects/using_contexts.html

and return an Option<T> or FieldResult<T>

mathroc avatar Aug 31 '21 12:08 mathroc