Exception: Yogurt::UnexpectedObjectType

Inherits:
StandardError
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/yogurt/unexpected_object_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field:, observed_type:, expected_types:) ⇒ UnexpectedObjectType

Returns a new instance of UnexpectedObjectType.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/yogurt/unexpected_object_type.rb', line 18

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

Instance Attribute Details

#expected_typesObject (readonly)

Returns the value of attribute expected_types.



15
16
17
# File 'lib/yogurt/unexpected_object_type.rb', line 15

def expected_types
  @expected_types
end

#fieldObject (readonly)

Returns the value of attribute field.



9
10
11
# File 'lib/yogurt/unexpected_object_type.rb', line 9

def field
  @field
end

#observed_typeObject (readonly)

Returns the value of attribute observed_type.



12
13
14
# File 'lib/yogurt/unexpected_object_type.rb', line 12

def observed_type
  @observed_type
end