Class: GraphQL::Client::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql_client/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_body) ⇒ Response

Returns a new instance of Response.

Raises:



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

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/graphql_client/response.rb', line 6

def body
  @body
end

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/graphql_client/response.rb', line 6

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/graphql_client/response.rb', line 6

def errors
  @errors
end

#extensionsObject (readonly)

Returns the value of attribute extensions.



6
7
8
# File 'lib/graphql_client/response.rb', line 6

def extensions
  @extensions
end