Sha256: d2033d00d30f3c53686716bf47a563267640b8d3084854931f76267c56f8f83b

Contents?: true

Size: 1.23 KB

Versions: 28

Compression:

Stored size: 1.23 KB

Contents

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

      def initialize(message, path: nil, nodes: [], type:, argument: nil, extensions: nil, coerce_extensions: nil)
        super(message, path: path, nodes: nodes)
        @type_name = type
        @argument_name = argument
        @extensions = extensions
        @coerce_extensions = coerce_extensions
      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

28 entries across 28 versions & 1 rubygems

Version Path
graphql-1.11.10 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.11.9 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.12.6 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.12.5 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.11.8 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.12.4 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.12.3 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.12.2 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.12.1 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.12.0 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.11.7 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.11.6 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.11.5 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.11.4 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.11.3 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.11.2 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.10.14 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.11.1 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.10.13 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb
graphql-1.11.0 lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb