Sha256: 3d2cca3f4205dd28cec84dede1ecadf45f6b770a8713e15cd62e15646a4559b4

Contents?: true

Size: 1.37 KB

Versions: 129

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true
module GraphQL
  module StaticValidation
    class ArgumentLiteralsAreCompatibleError < StaticValidation::Error
      attr_reader :type_name
      attr_reader :argument_name
      attr_reader :argument
      attr_reader :value

      def initialize(message, path: nil, nodes: [], type:, argument_name: nil, extensions: nil, coerce_extensions: nil, argument: nil, value: nil)
        super(message, path: path, nodes: nodes)
        @type_name = type
        @argument_name = argument_name
        @extensions = extensions
        @coerce_extensions = coerce_extensions
        @argument = argument
        @value = value
      end

      # A hash representation of this Message
      def to_h
        if @coerce_extensions
          extensions = @coerce_extensions
          # This is for legacy compat -- but this key is supposed to be a GraphQL type name :confounded:
          extensions["typeName"] = "CoercionError"
        else
          extensions = {
            "code" => code,
            "typeName" => type_name
          }

          if argument_name
            extensions["argumentName"] = argument_name
          end
        end

        extensions.merge!(@extensions) unless @extensions.nil?
        super.merge({
          "extensions" => extensions
        })
      end

      def code
        "argumentLiteralsIncompatible"
      end
    end
  end
end

Version data entries

129 entries across 129 versions & 2 rubygems

Version Path
graphql-2.1.0 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.27 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.26 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.25 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.24 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.23 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.22 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.21 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.20 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.17.2 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.17.1 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.19 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.18 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.17 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.13.19 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.13.18 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.16 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.13.17 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.15 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-2.0.14 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb