Method: Graphiti::Adapters::GraphitiAPI#resolve

Defined in:
lib/graphiti/adapters/graphiti_api.rb

#resolve(scope) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/graphiti/adapters/graphiti_api.rb', line 8

def resolve(scope)
  url = build_url(scope)
  response = resource.make_request(url)
  json = JSON.parse(response.body)

  if json["errors"]
    handle_remote_error(url, json)
  else
    models = json["data"].map { |d| build_entity(json, d) }
    Util::RemoteSerializer.for(resource.class.serializer, models)
    models
  end
end