Class: GraphQL::Extras::Test::Response

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

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Response

Returns a new instance of Response.



8
9
10
11
12
13
# File 'lib/graphql/extras/test/response.rb', line 8

def initialize(payload)
  @data = payload["data"]
  @errors = payload.fetch("errors", []).map do |error|
    Error.new(error)
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/graphql/extras/test/response.rb', line 5

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/graphql/extras/test/response.rb', line 6

def errors
  @errors
end

Instance Method Details

#successful?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/graphql/extras/test/response.rb', line 15

def successful?
  errors.empty?
end