class GraphQL::Schema::Directive::Flagged
This is similar to {Directive::Feature}, except it's prescribed by the server, not the client.
In this case, the server hides types and fields entirely, unless the current context has certain `:flags` present.
Public Class Methods
new(target, **options)
click to toggle source
Calls superclass method
GraphQL::Schema::Directive::new
# File lib/graphql/schema/directive/flagged.rb, line 9 def initialize(target, **options) if target.is_a?(Module) && !target.ancestors.include?(VisibleByFlag) # This is type class of some kind, `include` will put this module # in between the type class itself and its super class, so `super` will work fine target.include(VisibleByFlag) elsif !target.is_a?(VisibleByFlag) # This is an instance of a base class. `include` won't put this in front of the # base class implementation, so we need to `.prepend`. # `#visible?` could probably be moved to a module and then this could use `include` instead. target.class.prepend(VisibleByFlag) end super end