Sha256: 201b2b9ce25f1e916c6eee1b8f6d8b4c3ebfb1be1e0f2c488c9dc7798f98078b

Contents?: true

Size: 821 Bytes

Versions: 140

Compression:

Stored size: 821 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module StaticValidation
    module InputObjectNamesAreUnique
      def on_input_object(node, parent)
        validate_input_fields(node)
        super
      end

      private

      def validate_input_fields(node)
        input_field_defns = node.arguments
        input_fields_by_name = Hash.new { |h, k| h[k] = [] }
        input_field_defns.each { |a| input_fields_by_name[a.name] << a }

        input_fields_by_name.each do |name, defns|
          if defns.size > 1
            error = GraphQL::StaticValidation::InputObjectNamesAreUniqueError.new(
              "There can be only one input field named \"#{name}\"",
              nodes: defns,
              name: name
            )
            add_error(error)
          end
        end
      end
    end
  end
end

Version data entries

140 entries across 140 versions & 2 rubygems

Version Path
graphql-1.12.17 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.16 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.15 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.14 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.13 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.12 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.11 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.10 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.9 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.8 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.7 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.6 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.5 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.11.8 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.4 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.3 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.2 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.1 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.12.0 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.11.7 lib/graphql/static_validation/rules/input_object_names_are_unique.rb