Class: SimpleGraphqlClient::Response
- Inherits:
-
Object
- Object
- SimpleGraphqlClient::Response
- Defined in:
- lib/simple_graphql_client/response.rb
Instance Attribute Summary collapse
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
Instance Method Summary collapse
- #body ⇒ Object
- #errors ⇒ Object
-
#initialize(raw_response) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(raw_response) ⇒ Response
Returns a new instance of Response.
10 11 12 |
# File 'lib/simple_graphql_client/response.rb', line 10 def initialize(raw_response) @raw_response = raw_response end |
Instance Attribute Details
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
8 9 10 |
# File 'lib/simple_graphql_client/response.rb', line 8 def raw_response @raw_response end |
Instance Method Details
#body ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/simple_graphql_client/response.rb', line 14 def body parsed_body = Hashie::Mash.new(JSON.parse(raw_response.body)) raise SimpleGraphqlClient::Errors::QueryError, parsed_body.errors if parsed_body.errors parsed_body.data rescue JSON::ParserError => e raise SimpleGraphqlClient::Errors::ParserError.new(e, raw_response) end |
#errors ⇒ Object
23 24 25 |
# File 'lib/simple_graphql_client/response.rb', line 23 def errors response_body end |