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: {}) ⇒ Response

Internal: Initialize base class.



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

def initialize(hash, data: nil, errors: Errors.new, extensions: {})
  @original_hash = hash
  @data = data
  @errors = errors
  @extensions = extensions
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

#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