123456789_123456789_123456789_123456789_123456789_

Class: GraphQL::Client::Response

Relationships & Source Files
Inherits: Object
Defined in: lib/graphql/client/response.rb

Overview

Public: Abstract base class for ::GraphQL responses.

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

Class Method Summary

Instance Attribute Summary

  • #data readonly

    Public: Wrapped ObjectType of data returned from the server.

  • #errors readonly

    Public: Get partial failures from response.

  • #extensions readonly

    Public: Hash of server specific extension metadata.

  • #original_hash (also: #to_h) readonly

    Public: Original JSON response hash returned from server.

  • #to_h readonly

    Alias for #original_hash.

Constructor Details

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

Internal: Initialize base class.

[ GitHub ]

  
# 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

#data (readonly)

Public: Wrapped ObjectType of data returned from the server.

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

Returns instance of ObjectType subclass.

[ GitHub ]

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

attr_reader :data

#errors (readonly)

Public: Get partial failures from response.

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

Returns Errors collection object with zero or more errors.

[ GitHub ]

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

attr_reader :errors

#extensions (readonly)

Public: Hash of server specific extension metadata.

[ GitHub ]

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

attr_reader :extensions

#original_hash (readonly) Also known as: #to_h

Public: Original JSON response hash returned from server.

Returns Hash.

[ GitHub ]

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

attr_reader :original_hash

#to_h (readonly)

Alias for #original_hash.

[ GitHub ]

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

alias_method :to_h, :original_hash