graphiti 1.0.rc.27 → 1.0.rc.28

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8657023a3ffabe32824165c3bca07a95a9cb24fd9043d75a773f464674edccf8
4
- data.tar.gz: 6fe6875932185fa63ddde8e21545b55e5aea7bca78d8079455be1d77d1e9fa0e
3
+ metadata.gz: cf2a57f7befee66912eaf308320135cee89bd971d241eada385a4934a68f0420
4
+ data.tar.gz: 149550d9f6db9dfed354cb5b2caaf5bf558e129e6cde7857555073942ec9b5f3
5
5
  SHA512:
6
- metadata.gz: 354df547792b57898e0ef53e47e89e9c0f73499371d54dcb42bddea256b481e6d460f3860f6801dcce99fdd922557225671caf4957cd7756cdaa1097312e3f44
7
- data.tar.gz: 9a2a57b65a0fce0863cdf473fb87e48452b92e3e201a1797d90f19ccf363b43e8a8fca332910e6095eb0eb7b6416aa9e92d00b3a1dc00d42b528914047608911
6
+ metadata.gz: 3676f54da17e51e333307e063e4a174e94c4d6fc0d9ea9de7579fb600f009633d61506e3f5c1cafdff001d8f60c1086427109548e73782e471cdbc05fccdac64
7
+ data.tar.gz: b15028c261c408f958a6a6725a8eb221e0d6836898afbcf9fa36a694ae2a199d96819b8e2889317962004f18118230f6c0daf22134e63604ad6b5c73fc701e58
@@ -38,6 +38,12 @@ module Graphiti
38
38
  def remote=(val)
39
39
  super
40
40
  include ::Graphiti::Resource::Remote
41
+ self.endpoint = {
42
+ path: val,
43
+ full_path: val,
44
+ url: val,
45
+ actions: [:index, :show],
46
+ }
41
47
  end
42
48
 
43
49
  def model
@@ -18,8 +18,12 @@ module Graphiti
18
18
  end
19
19
  end
20
20
 
21
- def save(*args)
22
- raise Errors::RemoteWrite.new(self.class)
21
+ def save(model, meta)
22
+ if meta[:attributes] == {} && meta[:method] == :update
23
+ model
24
+ else
25
+ raise Errors::RemoteWrite.new(self.class)
26
+ end
23
27
  end
24
28
 
25
29
  def destroy(*args)
@@ -49,6 +49,8 @@ module Graphiti
49
49
  def generate_endpoints
50
50
  {}.tap do |endpoints|
51
51
  @resources.each do |r|
52
+ next if r.remote?
53
+
52
54
  r.endpoints.each do |e|
53
55
  actions = {}
54
56
  e[:actions].each do |a|
@@ -47,7 +47,6 @@ module Graphiti
47
47
  end
48
48
 
49
49
  if remote?
50
- @link = false
51
50
  @resource_class = create_remote_resource
52
51
  end
53
52
  end
@@ -23,8 +23,17 @@ class Graphiti::Sideload::BelongsTo < Graphiti::Sideload
23
23
  end
24
24
 
25
25
  def infer_foreign_key
26
- if polymorphic_child?
27
- parent.foreign_key
26
+ return parent.foreign_key if polymorphic_child?
27
+
28
+ if resource.remote?
29
+ namespace = namespace_for(resource.class)
30
+ resource_name = resource.class.name
31
+ .gsub("#{namespace}::", "")
32
+ .gsub("Resource", "")
33
+ if resource_name.include?(".remote")
34
+ resource_name = resource_name.split(".remote")[0].split(".")[1]
35
+ end
36
+ :"#{resource_name.singularize.underscore}_id"
28
37
  else
29
38
  model = resource.model
30
39
  namespace = namespace_for(model)
@@ -109,6 +109,8 @@ module Graphiti
109
109
  end
110
110
 
111
111
  def validate_link_for_sideload!(sideload)
112
+ return if sideload.resource.remote?
113
+
112
114
  action = sideload.type == :belongs_to ? :show : :index
113
115
  cache_key = :"#{@sideload.object_id}-#{action}"
114
116
  return if self.class.validated_link_cache.include?(cache_key)
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.0.rc.27"
2
+ VERSION = "1.0.rc.28"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.rc.27
4
+ version: 1.0.rc.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-27 00:00:00.000000000 Z
11
+ date: 2019-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-serializable
@@ -334,7 +334,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
334
334
  version: 1.3.1
335
335
  requirements: []
336
336
  rubyforge_project:
337
- rubygems_version: 2.7.9
337
+ rubygems_version: 2.7.6
338
338
  signing_key:
339
339
  specification_version: 4
340
340
  summary: Easily build jsonapi.org-compatible APIs