diff --git a/lib/graphql/client/response.rb b/lib/graphql/client/response.rb index cc8dc62..f262418 100644 --- a/lib/graphql/client/response.rb +++ b/lib/graphql/client/response.rb @@ -12,6 +12,7 @@ class Response # Returns Hash. attr_reader :original_hash alias_method :to_h, :original_hash + alias_method :to_hash, :original_hash # Public: Wrapped ObjectType of data returned from the server. # diff --git a/lib/graphql/client/schema/object_type.rb b/lib/graphql/client/schema/object_type.rb index e1cccf3..4233f19 100644 --- a/lib/graphql/client/schema/object_type.rb +++ b/lib/graphql/client/schema/object_type.rb @@ -192,6 +192,7 @@ def initialize(data = {}, errors = Errors.new, definer = nil) def to_h @data end + alias :to_hash :to_h def _definer @definer diff --git a/test/test_query_result.rb b/test/test_query_result.rb index ffc6fa3..ed6cd83 100644 --- a/test/test_query_result.rb +++ b/test/test_query_result.rb @@ -272,6 +272,7 @@ def test_snakecase_field_aliases person = Temp::Person.new(@client.query(Temp::Query).data.me) raw_result = {"firstName"=>"Joshua", "lastName"=>"Peek"} assert_equal raw_result, person.to_h + assert_equal raw_result, person.to_hash assert_equal "Joshua", person.first_name assert_equal "Peek", person.last_name