Method: GraphQL::Client::Errors#details

Defined in:
lib/graphql/client/errors.rb

#detailsObject

Public: Access Hash of error objects.

data.errors.details["node"]
data.errors.details[:node]

Returns HashWithIndifferentAccess.

[View source]

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/graphql/client/errors.rb', line 95

def details
  return @details if defined? @details

  details = {}

  @raw_errors.each do |error|
    path = error.fetch("normalizedPath", [])
    matched_path = @all ? path[0, @ast_path.length] : path[0...-1]
    next unless @ast_path == matched_path

    field = path[@ast_path.length]
    next unless field

    details[field] ||= []
    details[field] << error
  end

  @details = HashWithIndifferentAccess.new(details)
end