graphiti 1.0.alpha.23 → 1.0.alpha.24

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
  SHA1:
3
- metadata.gz: 18d9a12135650986b4f1fa94b249c189e9b81fc4
4
- data.tar.gz: 96221312f3f89efa12ab4ab467ef0faf9452770f
3
+ metadata.gz: 67b89c099870abde2d636eb3808e813b96610f82
4
+ data.tar.gz: f8324c6a127cb1fe844b3913ec08ebe8f84da57d
5
5
  SHA512:
6
- metadata.gz: 5bcabf487b785846af3d77e1402fc16aeac6ef8240c5e52bd1f5217e5ae0339db3c0c5b2a42686d1dd6964274b0d564cfb96a641f2508b697c0ff0f5093f2c1a
7
- data.tar.gz: 705dcef46324aebe05871956ab655bce5fdc4b4f38d8f140acb790165038d467ee2183e4f0e733baf0a5e85477c8ff5ace1e5560e238a97b4bb379826170b5e1
6
+ metadata.gz: 15474cfc1554159f641a0dff3eded7760cf9c4b0c56f869b2bab9f85006c2e24208206e056614991f0a047779e8ecd772e98d4182ecc4c808e41d1ef4b3e2e68
7
+ data.tar.gz: d26dcca3b5eca5158e74b6def93463420ba607552d31e48bfcc546e38dab92880abf13fe04abb6740128a4c918622e801cee5f0562262ece84815678ea36b5fb
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'dry-types', '~> 0.13'
23
23
  spec.add_dependency 'graphiti_errors', '~> 1.0.alpha.2'
24
24
  spec.add_dependency 'concurrent-ruby', '~> 1.0'
25
+ spec.add_dependency 'activesupport', ['>= 4.1', '< 6']
25
26
 
26
27
  spec.add_development_dependency "activerecord", ['>= 4.1', '< 6']
27
28
  spec.add_development_dependency "kaminari", '~> 0.17'
@@ -126,6 +126,18 @@ module Graphiti
126
126
  def self.resources
127
127
  @resources ||= []
128
128
  end
129
+
130
+ # When we add a sideload, we need to do configuration, such as
131
+ # adding the relationship to the Resource's serializer.
132
+ # However, the sideload's Resource class may not be loaded yet.
133
+ # This is not a problem with Rails autoloading, but is a problem
134
+ # outside Rails.
135
+ # In these cases, load every Resource class then call Graphiti.setup!
136
+ def self.setup!
137
+ resources.each do |r|
138
+ r.apply_sideloads_to_serializer
139
+ end
140
+ end
129
141
  end
130
142
 
131
143
  require "graphiti/runner"
@@ -17,7 +17,7 @@ module Graphiti
17
17
  parent.children[name] = sideload
18
18
  else
19
19
  config[:sideloads][name] = sideload
20
- apply_sideloads_to_serializer
20
+ apply_sideloads_to_serializer if sideload.resource_class_loaded?
21
21
  end
22
22
  sideload
23
23
  end
@@ -261,6 +261,16 @@ module Graphiti
261
261
  !self.class.assign_each_proc
262
262
  end
263
263
 
264
+ # @api private
265
+ def resource_class_loaded?
266
+ begin
267
+ resource_class
268
+ true
269
+ rescue Graphiti::Errors::ResourceNotFound
270
+ false
271
+ end
272
+ end
273
+
264
274
  private
265
275
 
266
276
  def apply_belongs_to_many_filter
@@ -39,7 +39,9 @@ module Graphiti
39
39
 
40
40
  def block
41
41
  if _link = link?
42
- validate_link! unless @sideload.link_proc
42
+ if @resource_class.validate_endpoints?
43
+ validate_link! unless @sideload.link_proc
44
+ end
43
45
  end
44
46
 
45
47
  _sl = @sideload
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.0.alpha.23"
2
+ VERSION = "1.0.alpha.24"
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.alpha.23
4
+ version: 1.0.alpha.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-10 00:00:00.000000000 Z
11
+ date: 2018-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-serializable
@@ -66,6 +66,26 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '4.1'
76
+ - - "<"
77
+ - !ruby/object:Gem::Version
78
+ version: '6'
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '4.1'
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: '6'
69
89
  - !ruby/object:Gem::Dependency
70
90
  name: activerecord
71
91
  requirement: !ruby/object:Gem::Requirement