exAspArk / graphql-guard

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

Using guard in base/parent class always takes priority #51

Open chrise86 opened 2 years ago

chrise86 commented 2 years ago

If using guard ->(obj, args, ctx) { some_method } inside a base type class, and then inheriting from that class you cannot specify overrides per sub class or even per field. It will always use the guard from the parent class.

class ParentType < BaseType
  guard ->(obj, args, ctx) { false }
end

class ChildType < ParentType
  guard ->(obj, args, ctx) { true } # will not work

  field :id, ID, required: true, guard ->(obj, args, ctx) { true } # also will not work
end
nick-benoit14 commented 2 years ago

Yeah i'm also confused by this. It would be nice to be able to have a guard like

  guard ->(obj, args, ctx) { false } 

In my base type so that I can verify everything has a guard.