lib/rails/graphql.rb
# Returns a set instance with uniq directives from the given list.
# If the same directive class is given twice, it will raise an exception,
# since they must be uniq within a list of directives.
#
# Use the others argument to provide a list of already defined directives
# so the check can be performed using a +inherited_collection+.
#
# If a +source+ is provided, then an +:attach+ event will be triggered
# for each directive on the givem source element.
Returns a set instance with uniq directives from the given list.
If the same directive class is given twice, it will raise an exception,
since they must be uniq within a list of directives.

Use the others argument to provide a list of already defined directives
so the check can be performed using a +inherited_collection+.

If a +source+ is provided, then an +:attach+ event will be triggered
for each directive on the givem source element.
Returns a set instance with uniq directives from the given list . If the same directive class is given twice it will raise an exception since they must be uniq within a list of directives . Use the others argument to provide a list of already defined directives so the check can be performed using a + inherited_collection + . If a + source + is provided then an + : attach + event will be triggered for each directive on the givem source element .
def directives_to_set(list, others = [], event = nil, **xargs)
        others = others.dup
        if (source = xargs.delete(:source)).present?
          location = xargs.delete(:location) || source.try(:directive_location)
          event ||= GraphQL::Event.new(:attach, source, phase: :definition, **xargs)
        end
        Array.wrap(list).each_with_object(Set.new) do |item, result|
          raise ArgumentError, <<~MSG.squish unless item.kind_of?(GraphQL::Directive)
            The "#{item.class}" is not a valid directive.
          MSG
          invalid = others.present? && (others.any? { |k| k.class.eql?(item.class) })
          raise DuplicatedError, <<~MSG.squish if invalid
            A @#{item.gql_name} directive have already been provided.
          MSG
          invalid_location = location.present? && !item.locations.include?(location)
          raise ArgumentError, <<~MSG.squish if invalid_location
            You cannot use @#{item.gql_name} directive due to location restriction.
          MSG
          unless event.nil?
            begin
              item.assing_owner!(event.source)
              event.trigger_object(item)
            rescue => error
              raise StandardError, <<~MSG.squish
                Unable to #{event.name} the @#{item.gql_name} directive: #{error.message}
              MSG
            end
          end
          others << item
          result << item
        end
      end
def directives_to_set ( list , others = [ ] , event = nil , ** xargs ) others = others . dup if ( source = xargs . delete ( :source ) ) . present? location = xargs . delete ( :location ) || source . try ( :directive_location ) event ||= GraphQL :: Event . new ( :attach , source , phase : :definition , ** xargs ) end Array . wrap ( list ) . each_with_object ( Set . new ) do | item , result | raise ArgumentError , <<~MSG . squish unless item . kind_of? ( GraphQL :: Directive ) 
            The " #{ item . class } " is not a valid directive.
           MSG invalid = others . present? && ( others . any? { | k | k . class . eql? ( item . class ) } ) raise DuplicatedError , <<~MSG . squish if invalid 
            A @ #{ item . gql_name }  directive have already been provided.
           MSG invalid_location = location . present? && ! item . locations . include? ( location ) raise ArgumentError , <<~MSG . squish if invalid_location 
            You cannot use @ #{ item . gql_name }  directive due to location restriction.
           MSG unless event . nil? begin item . assing_owner! ( event . source ) event . trigger_object ( item ) rescue => error raise StandardError , <<~MSG . squish 
                Unable to  #{ event . name }  the @ #{ item . gql_name }  directive:  #{ error . message } MSG end end others << item result << item end end
Returns a set instance with uniq directives from the given list.
Returns a set instance with uniq directives from the given list .
list
others
event
xargs