Class: GraphQL::Client::Response

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

Overview

Public: Abstract base class for GraphQL responses.

https://facebook.github.io/graphql/#sec-Response-Format

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, data: nil, errors: Errors.new, extensions: {}, full_response: nil) ⇒ Response

Internal: Initialize base class.



40
41
42
43
44
45
46
# File 'lib/graphql/client/response.rb', line 40

def initialize(hash, data: nil, errors: Errors.new, extensions: {}, full_response: nil)
  @original_hash = hash
  @data = data
  @errors = errors
  @extensions = extensions
  @full_response = full_response
end

Instance Attribute Details

#dataObject (readonly)

Public: Wrapped ObjectType of data returned from the server.

https://facebook.github.io/graphql/#sec-Data

Returns instance of ObjectType subclass.



22
23
24
# File 'lib/graphql/client/response.rb', line 22

def data
  @data
end

#errorsObject (readonly)

Public: Get partial failures from response.

https://facebook.github.io/graphql/#sec-Errors

Returns Errors collection object with zero or more errors.



29
30
31
# File 'lib/graphql/client/response.rb', line 29

def errors
  @errors
end

#extensionsObject (readonly)

Public: Hash of server specific extension metadata.



32
33
34
# File 'lib/graphql/client/response.rb', line 32

def extensions
  @extensions
end

#full_responseObject (readonly)

Public: Complete response hash returned from server.

Returns Hash



37
38
39
# File 'lib/graphql/client/response.rb', line 37

def full_response
  @full_response
end

#original_hashObject (readonly) Also known as: to_h, to_hash

Public: Original JSON response hash returned from server.

Returns Hash.



13
14
15
# File 'lib/graphql/client/response.rb', line 13

def original_hash
  @original_hash
end