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.



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

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.



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

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.



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

def errors
  @errors
end

#extensionsObject (readonly)

Public: Hash of server specific extension metadata.



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

def extensions
  @extensions
end

#original_hashObject (readonly) Also known as: to_h

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