Class: Graphiti::Adapters::GraphitiAPI

Inherits:
Null show all
Defined in:
lib/graphiti/adapters/graphiti_api.rb

Instance Attribute Summary

Attributes inherited from Abstract

#resource

Instance Method Summary collapse

Methods inherited from Null

#average, #count, #filter_boolean_eq, #filter_date_eq, #filter_date_gt, #filter_date_gte, #filter_date_lt, #filter_date_lte, #filter_date_not_eq, #filter_datetime_eq, #filter_datetime_gt, #filter_datetime_gte, #filter_datetime_lt, #filter_datetime_lte, #filter_datetime_not_eq, #filter_decimal_eq, #filter_decimal_gt, #filter_decimal_gte, #filter_decimal_lt, #filter_decimal_lte, #filter_decimal_not_eq, #filter_float_eq, #filter_float_gt, #filter_float_gte, #filter_float_lt, #filter_float_lte, #filter_float_not_eq, #filter_integer_eq, #filter_integer_gt, #filter_integer_gte, #filter_integer_lt, #filter_integer_lte, #filter_integer_not_eq, #filter_string_eq, #filter_string_eql, #filter_string_match_eq, #filter_string_not_eq, #filter_string_not_eql, #filter_string_not_match_eq, #filter_string_not_prefix_eq, #filter_string_not_suffix_eq, #filter_string_prefix_eq, #filter_string_suffix_eq, #maximum, #minimum, #order, #paginate, #save, #sum, #transaction

Methods inherited from Abstract

#assign_attributes, #associate, #associate_all, #average, #belongs_to_many_filter, #build, #can_group?, #close, #count, default_operators, #destroy, #disassociate, #filter_big_decimal_eq, #filter_big_decimal_gt, #filter_big_decimal_gte, #filter_big_decimal_lt, #filter_big_decimal_lte, #filter_big_decimal_not_eq, #filter_boolean_eq, #filter_date_eq, #filter_date_gt, #filter_date_gte, #filter_date_lt, #filter_date_lte, #filter_date_not_eq, #filter_datetime_eq, #filter_datetime_gt, #filter_datetime_gte, #filter_datetime_lt, #filter_datetime_lte, #filter_datetime_not_eq, #filter_float_eq, #filter_float_gt, #filter_float_gte, #filter_float_lt, #filter_float_lte, #filter_float_not_eq, #filter_integer_eq, #filter_integer_gt, #filter_integer_gte, #filter_integer_lt, #filter_integer_lte, #filter_integer_not_eq, #filter_string_eq, #filter_string_eql, #filter_string_match, #filter_string_not_eq, #filter_string_not_eql, #filter_string_not_match, #filter_string_not_prefix, #filter_string_not_suffix, #filter_string_prefix, #filter_string_suffix, #filter_uuid_eq, #filter_uuid_not_eq, #initialize, #maximum, #minimum, numerical_operators, #order, #paginate, #persistence_attributes, #save, sideloading_classes, #sum, #transaction

Methods included from Persistence::Associations

#process_belongs_to, #process_has_many, #update_foreign_key, #update_foreign_key_for_parents, #update_foreign_type

Constructor Details

This class inherits a constructor from Graphiti::Adapters::Abstract

Instance Method Details

#base_scope(model) ⇒ Object



4
5
6
# File 'lib/graphiti/adapters/graphiti_api.rb', line 4

def base_scope(model)
  {}
end

#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