graphiti-activegraph 0.1.17 → 0.1.18

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: f9b7ea2a6b4e70a83c4d19537bc4aaceca17366977698e36478b0e965b901a3e
4
- data.tar.gz: 814010357e707ccd4c1bc7f0af3c954bbe37970aa17f842b32e421990af9e3c7
3
+ metadata.gz: fec65766ac7739c8c38a65cc8ffbd071df5ff4f30bbb8ac5373c4ae1996e33a3
4
+ data.tar.gz: de51eb41133930d20523781ce94f79545d80be3f14b5afc416aeee047133a128
5
5
  SHA512:
6
- metadata.gz: 7c5ba76168e3614a3b4ba2c31b3385f39b1a835801f0191ddc9cdbbe53335510895d0faaa5d1427727c8a1f5c15b1164f64176fd890222b5f5efdb6adb46f486
7
- data.tar.gz: 7b0187abf211beb954b6d76b915c4c5a678325c54b8a67469d2cacfb011e3c7ff4b42341c45b9b44cc40e6b79912a9a7f9121f9d3f08287b8f925c99fa6c4d94
6
+ metadata.gz: dd67df9255f946307f733c86cb40d0126b0938f922a3104a823079cb1449a6d07be828e0ecb006085aecc64e6af049bd54f8264c58b767699512e0ed790d439a
7
+ data.tar.gz: 73e67b1af55bbfa1ad3736b64c003ea966f730429ea441b075cb53d5f4b27bc0f085ffb3a59e52b1f0442380488ec6ac97454e5bdb0385d9c58b6fe6241903a7
@@ -58,8 +58,8 @@ module Graphiti::ActiveGraph
58
58
  model_instance
59
59
  end
60
60
 
61
- def resolve(scope)
62
- scope.to_a
61
+ def resolve(scope, resolve_to_rel = false)
62
+ resolve_to_rel ? scope.to_a(false, true) : scope.to_a
63
63
  end
64
64
 
65
65
  # def associate_all(parent, children, association_name, association_type)
@@ -0,0 +1,14 @@
1
+ module Graphiti::ActiveGraph
2
+ module Resource
3
+ module Interface
4
+ extend ActiveSupport::Concern
5
+ class_methods do
6
+ def build(params, base_scope = nil, opts = {})
7
+ validate!(params)
8
+ runner = ::Graphiti::Runner.new(self, params)
9
+ runner.proxy(base_scope, { single: true, raise_on_missing: true }.merge(opts) )
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -14,16 +14,11 @@ module Graphiti
14
14
  params[:filter] ||= {}
15
15
  params[:filter][:id] = id if id
16
16
 
17
- validate!(params)
18
- runner = ::Graphiti::Runner.new(self, params)
19
- runner.proxy(nil, single: true, raise_on_missing: false, preloaded: obj, bypass_required_filters: true)
17
+ build(params, nil, raise_on_missing: false, preloaded: obj, bypass_required_filters: true)
20
18
  end
21
19
 
22
20
  def all_with_preloaded(obj_arr, params)
23
- validate!(params)
24
-
25
- runner = ::Graphiti::Runner.new(self, params)
26
- runner.proxy(nil, raise_on_missing: false, preloaded: obj_arr)
21
+ build(params, nil, single: false, raise_on_missing: false, preloaded: obj_arr)
27
22
  end
28
23
 
29
24
  def guard_nil_id!(params)
@@ -39,6 +34,10 @@ module Graphiti
39
34
  query.sideloads.keys.map(&:to_sym)
40
35
  end
41
36
 
37
+ def resolve(scope)
38
+ adapter.resolve(scope, relation_resource?)
39
+ end
40
+
42
41
  def typecast(name, value, flag)
43
42
  att = get_attr!(name, flag, request: true)
44
43
 
@@ -22,8 +22,8 @@ module Graphiti::ActiveGraph
22
22
  :parent,
23
23
  :params,
24
24
  :preloaded).merge(unpaginated_query: params[:unpaginated_query])
25
- scope = jsonapi_scope(base, scope_opts) unless jsonapi_resource.relation_resource?
26
- preloaded = opts[:preloaded] || (jsonapi_resource.relation_resource? && jsonapi_resource.base_scope)
25
+ scope = jsonapi_scope(base, scope_opts)
26
+ preloaded = opts[:preloaded]
27
27
  options = { payload: deserialized_payload,
28
28
  single: opts[:single],
29
29
  raise_on_missing: opts[:raise_on_missing],
@@ -1,5 +1,5 @@
1
1
  module Graphiti
2
2
  module ActiveGraph
3
- VERSION = '0.1.17'
3
+ VERSION = '0.1.18'
4
4
  end
5
5
  end
@@ -10,6 +10,7 @@ module Graphiti
10
10
  end
11
11
  require 'graphiti/scoping/filterable'
12
12
  require 'graphiti/resource/persistence'
13
+ require 'graphiti/resource/interface'
13
14
  # End workaround for jruby prepend issue
14
15
 
15
16
  loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
@@ -19,6 +20,7 @@ loader.setup
19
20
 
20
21
  Graphiti::Scoping::Filterable.prepend Graphiti::ActiveGraph::Scoping::Filterable
21
22
  Graphiti::Resource::Persistence.prepend Graphiti::ActiveGraph::Resource::Persistence
23
+ Graphiti::Resource::Interface::ClassMethods.prepend Graphiti::ActiveGraph::Resource::Interface::ClassMethods
22
24
  require 'graphiti'
23
25
  Graphiti::Scoping::Filter.prepend Graphiti::ActiveGraph::Scoping::Filter
24
26
  Graphiti::Util::SerializerRelationship.prepend Graphiti::ActiveGraph::Util::SerializerRelationship
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti-activegraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hardik Joshi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-23 00:00:00.000000000 Z
11
+ date: 2022-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphiti
@@ -174,6 +174,7 @@ files:
174
174
  - lib/graphiti/active_graph/jsonapi_ext/serializable/resource_ext.rb
175
175
  - lib/graphiti/active_graph/query.rb
176
176
  - lib/graphiti/active_graph/resource.rb
177
+ - lib/graphiti/active_graph/resource/interface.rb
177
178
  - lib/graphiti/active_graph/resource/persistence.rb
178
179
  - lib/graphiti/active_graph/resource_proxy.rb
179
180
  - lib/graphiti/active_graph/runner.rb