Sha256: ae9fcaaf417629972f1c241791b5f7798268a85f45496985c2bcfec2f85058bf

Contents?: true

Size: 812 Bytes

Versions: 2

Compression:

Stored size: 812 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module Yogurt
  class UnexpectedObjectType < StandardError
    extend T::Sig

    sig {returns(Symbol)}
    attr_reader :field

    sig {returns(String)}
    attr_reader :observed_type

    sig {returns(T::Array[String])}
    attr_reader :expected_types

    sig {params(field: Symbol, observed_type: String, expected_types: T::Array[String]).void}
    def initialize(field:, observed_type:, expected_types:)
      @field = T.let(field, Symbol)
      @observed_type = T.let(observed_type, String)
      @expected_types = T.let(expected_types, T::Array[String])

      super <<~STRING
        Unexpected type returned in GraphQL response for #{field}. 
        Received: #{observed_type}
        Expected: #{expected_types.join(', ')}
      STRING
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yogurt-0.2.0 lib/yogurt/unexpected_object_type.rb
yogurt-0.1.1 lib/yogurt/unexpected_object_type.rb