graphiti-activegraph 0.1.19 → 0.1.20

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: 46a16074941e4ee029f645c51e1205ad85c47f2d5f68e28263cf8f6bb2d4dc1f
4
- data.tar.gz: b769fe9d7c723b6388de46ea98d2d81b04784a00e43012141fe494ced7172171
3
+ metadata.gz: 79f25c472d8becc7f194ffe8a43395e95c3419d9aa545d5cb6f6fc0f0266e1a2
4
+ data.tar.gz: 9e39773e46342901adb5b47426ebfc7f28af3e50ef25966df09531a934e2dabb
5
5
  SHA512:
6
- metadata.gz: f08617d64f77129f273e42e26ad173858440e957427268155c6c470aff22131b8fdde701bb2d22e1c72e3cb6dce98f6c627397dae181416ed2a88ccd43382905
7
- data.tar.gz: 312ed3bd2df8a475d3c35e1298498d4717f38ce4c6ca5312ecef80318e4d9ae9da2613f5b982057c1b6299db50a6656530214bbca6da9603a8d4e8038a3962e4
6
+ metadata.gz: b67f798771e0908d933b9dcd90ef68842e0447b16ac085e1e612b8f0b139b63b43554e73e4e5a943dcdde17aa5f23d77ebc33de6a08f75a715b426abf7eb847c
7
+ data.tar.gz: a96c79383cd517a5012fcb5a4b91dce14f5555cfbcc6fcf7ff5f77ba2c390482185852b2270aab4a8ada23b73ce88583209da8594c7e0d86df506556d63b9dd2
@@ -18,7 +18,7 @@ jobs:
18
18
  strategy:
19
19
  fail-fast: false
20
20
  matrix:
21
- ruby-version: [ jruby, ruby ]
21
+ ruby-version: [ jruby-9.3.9.0, ruby ]
22
22
 
23
23
  steps:
24
24
  - uses: actions/checkout@v3
data/CHANGELOG.md CHANGED
@@ -26,6 +26,12 @@ Features:
26
26
 
27
27
  - Relationships mentioned in sparse field param (and not in include), will now be returned in relationship block of response
28
28
 
29
+ ## 0.1.20
30
+
31
+ Features:
32
+
33
+ - With graphiti config variable "allow_sidepost" you can allow/disallow sideposting, by default it is allowed.
34
+
29
35
  <!-- ### [version (DD-MM-YYYY)] -->
30
36
  <!-- Breaking changes:-->
31
37
  <!-- Features:-->
@@ -147,9 +147,7 @@ module Graphiti::ActiveGraph
147
147
  end
148
148
 
149
149
  def process_relationship_attrs(x, rel_attrs, assign_multiple)
150
- x[:object] = x[:resource]
151
- .persist_with_relationships(x[:meta], x[:attributes], x[:relationships], self, x[:foreign_key])
152
-
150
+ x[:object] = find_record(x)
153
151
  resource = @persistence.instance_variable_get(:@resource)
154
152
  meta = @persistence.instance_variable_get(:@meta)
155
153
  # Relationship start/end nodes cannot be changed once persisted
@@ -170,6 +168,16 @@ module Graphiti::ActiveGraph
170
168
  rel_map[:object]
171
169
  end
172
170
  end
171
+
172
+ def find_record(x)
173
+ if Graphiti.config.allow_sidepost
174
+ x[:object] = x[:resource]
175
+ .persist_with_relationships(x[:meta], x[:attributes], x[:relationships], self, x[:foreign_key])
176
+ else
177
+ id = x.dig(:attributes, :id)
178
+ x[:resource].model.find(id) if id
179
+ end
180
+ end
173
181
  end
174
182
  end
175
183
  end
@@ -1,5 +1,5 @@
1
1
  module Graphiti
2
2
  module ActiveGraph
3
- VERSION = '0.1.19'
3
+ VERSION = '0.1.20'
4
4
  end
5
5
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Graphiti
4
+ module SidepostConfiguration
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ attr_accessor :allow_sidepost
8
+ end
9
+ end
10
+ end
@@ -33,6 +33,7 @@ Graphiti::Resource.extend Graphiti::ActiveGraph::Resource
33
33
  Graphiti::ResourceProxy.prepend Graphiti::ActiveGraph::ResourceProxy
34
34
  Graphiti::Runner.prepend Graphiti::ActiveGraph::Runner
35
35
  Graphiti::Scope.prepend Graphiti::ActiveGraph::SideloadResolve
36
+ Graphiti::Configuration.include Graphiti::SidepostConfiguration
36
37
 
37
38
  # JSONAPI extensions
38
39
  JSONAPI::Serializable::Resource.prepend Graphiti::ActiveGraph::JsonapiExt::Serializable::ResourceExt
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.19
4
+ version: 0.1.20
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-11-24 00:00:00.000000000 Z
11
+ date: 2022-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphiti
@@ -185,6 +185,7 @@ files:
185
185
  - lib/graphiti/active_graph/util/serializer_attribute.rb
186
186
  - lib/graphiti/active_graph/util/serializer_relationship.rb
187
187
  - lib/graphiti/active_graph/version.rb
188
+ - lib/graphiti/sidepost_configuration.rb
188
189
  homepage: https://github.com/mrhardikjoshi/graphiti-activegraph
189
190
  licenses:
190
191
  - MIT