exAspArk / graphql-guard

Simple authorization gem for GraphQL :lock:
MIT License
471 stars 36 forks source link

Use on resolver #38

Closed imcvampire closed 4 years ago

imcvampire commented 4 years ago

Hi,

Can you add guard to Resolver

Thanks for your open source contributions!

exAspArk commented 4 years ago

Hi @imcvampire,

Can you add guard to Resolver

I'm sorry, what do you mean? Can you provide more information and examples?

P.S. You can find some code examples in the readme file

imcvampire commented 4 years ago

Here is what I do for now

field :my_field, resolver: Resolvers::MyFieldResolver do 
  guard -> (_, _, ctx) { ctx[:current_user] }
end
class MyFieldResolver < GraphQL::Schema::Resolver
  type :id, ID, null: false
end

What I want to do

field :my_field, resolver: Resolvers::MyFieldResolver
class MyFieldResolver < GraphQL::Schema::Resolver
  type :id, ID, null: false
  guard -> (_, _, ctx) { ctx[:current_user] }
end
imcvampire commented 4 years ago

And, I don't see any example about using with Resolver

ghost commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

imcvampire commented 4 years ago

Hi @exAspArk!

ghost commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

tinynumbers commented 3 years ago

@imcvampire @exAspArk any answer / solution to this? I have the same question.