Sha256: b9544df5207858b57ade892e301b78a8994ce1623f1495b1151510db8d0a66e0
Contents?: true
Size: 824 Bytes
Versions: 1
Compression:
Stored size: 824 Bytes
Contents
module StoryBranch module Graphql # Model to handle graphql response and make it more friendly. Detect if errors # are present in the reponse and marks the response as failed if so # gives a few accessors to data class Response def initialize(response:) @response = response end def data @data ||= @response.parsed_response['data'] end def success? errors.nil? && @response.success? end def errors return @errors if @errors @errors = if @response.success? @response.parsed_response['errors'] else [@response.response, @response.parsed_response] end end def full_error_messages errors.join("\n") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
story_branch-graphql-0.0.1 | lib/story_branch/graphql/response.rb |