Class: GraphQL::Client::Response
- Inherits:
-
Object
- Object
- GraphQL::Client::Response
- Defined in:
- lib/graphql_client/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
Instance Method Summary collapse
-
#initialize(response_body) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(response_body) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/graphql_client/response.rb', line 8 def initialize(response_body) response = JSON.parse(response_body) data, errors, extensions = response.values_at('data', 'errors', 'extensions') raise ResponseError, errors if !data && errors @body = response @data = data @errors = errors.to_a @extensions = extensions end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/graphql_client/response.rb', line 6 def body @body end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/graphql_client/response.rb', line 6 def data @data end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/graphql_client/response.rb', line 6 def errors @errors end |
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
6 7 8 |
# File 'lib/graphql_client/response.rb', line 6 def extensions @extensions end |