class Graphlient::Errors::GraphQLError

def create_detail(detail)

and if none exist, it fallbacks to just return error message
then checks for error root level `path` and tries to generate error from that
It first tries `problem` attribute of the error response
Generates human readable error explanation from a GraphQL error message
#
def create_detail(detail)
  if detail.key?('problems')
    [detail['message'], create_problems(detail['problems']).compact.join("\n  ")].join("\n  ")
  elsif detail.key?('path')
    [detail['path'].compact.join(' '), detail['message']].join(': ')
  else
    detail['message']
  end
end

def create_details(details)

def create_details(details)
  details.map { |detail| create_detail(detail) }
end

def create_problem(problem)

def create_problem(problem)
  paths = problem.key?('path') && !problem['path'].empty? ? "#{problem['path'].join(', ')}: " : ''
  [paths, problem['explanation']].compact.join
end

def create_problems(problems)

def create_problems(problems)
  problems.map { |problem| create_problem(problem) }
end

def errors

def errors
  @response.errors
end

def initialize(response)

def initialize(response)
  super('the server responded with a GraphQL error')
  @response = response
end

def to_s

def to_s
  errors.details.map do |key, details|
    details = create_details(details).join("\n")
    [key == 'data' ? nil : key, details].compact.join(': ')
  end.join("\n")
end