Sha256: 8bf7131212fa4795b7b90ed8611fc6971a553b3549db23fc17e0de7c1d692db9

Contents?: true

Size: 501 Bytes

Versions: 1

Compression:

Stored size: 501 Bytes

Contents

# frozen_string_literal: true

module GraphQL
  module Client
    class Response
      attr_reader :body, :data, :errors, :extensions

      def initialize(response_body)
        response = JSON.parse(response_body)
        data, errors, extensions = response.values_at('data', 'errors', 'extensions')

        raise ResponseError, errors if !data && errors

        @body = response
        @data = data
        @errors = errors.to_a
        @extensions = extensions.to_a
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql_client-0.3.3 lib/graphql_client/response.rb