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-2.1.11 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.0.28 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.13.21 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.2.5 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.2.4 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.2.3 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.1.10 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.2.2 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.1.9 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.2.1 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.2.0 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.1.8 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.1.7 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.1.6 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.1.5 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.1.4 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-1.13.20 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.1.3 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.1.2 lib/graphql/static_validation/rules/input_object_names_are_unique.rb
graphql-2.1.1 lib/graphql/static_validation/rules/input_object_names_are_unique.rb