class GraphQL::StaticValidation::FieldsWillMerge::FieldDefinitionComparison

Compare two field definitions, add errors to the list if there are any

def initialize(name, defs)

def initialize(name, defs)
  errors = []
  names = defs.map(&:name).uniq
  if names.length != 1
    errors << message("Field '#{name}' has a field conflict: #{names.join(" or ")}?", defs.first)
  end
  args = defs.map { |defn| reduce_list(defn.arguments)}.uniq
  if args.length != 1
    errors << message("Field '#{name}' has an argument conflict: #{args.map {|a| JSON.dump(a) }.join(" or ")}?", defs.first)
  end
  directive_names = defs.map { |defn| defn.directives.map(&:name) }.uniq
  if directive_names.length != 1
    errors << message("Field '#{name}' has a directive conflict: #{directive_names.map {|names| "[#{names.join(", ")}]"}.join(" or ")}?", defs.first)
  end
  directive_args = defs.map {|defn| defn.directives.map {|d| reduce_list(d.arguments) } }.uniq
  if directive_args.length != 1
    errors << message("Field '#{name}' has a directive argument conflict: #{directive_args.map {|args| JSON.dump(args)}.join(" or ")}?", defs.first)
  end
  @errors = errors
end

def reduce_list(args)

can't look up args, the names just have to match
Turn AST tree into a hash
def reduce_list(args)
  args.reduce({}) do |memo, a|
    memo[a.name] = NAMED_VALUES.include?(a.value.class) ? a.value.name : a.value
    memo
  end
end