graphiti 1.2.37 → 1.2.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/graphiti/adapters/active_record.rb +2 -1
- data/lib/graphiti/query.rb +2 -0
- data/lib/graphiti/request_validators/validator.rb +10 -5
- data/lib/graphiti/sideload.rb +6 -1
- data/lib/graphiti/util/serializer_attributes.rb +12 -6
- data/lib/graphiti/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a282326a13780606dc7c66a393aecb4815e8230d166c21e522e4f64566fb7abe
|
|
4
|
+
data.tar.gz: efc784934b7091bba5839fe20c5052a5ee00198bc9a008f1330ab373ff26e965
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 396020335f1edb7b9a733cceaebecd3213e065567d83ca9c1380198967622a64927e3e9564715f4d3d76619a631005c87535fce7d094600a1d9d1b5cfd0cf42f
|
|
7
|
+
data.tar.gz: 64058843e61f8b50f5dfa44ed9835f73012ef6bb5c2c29b2c668d20b213571b59503c790c5ba62044f2300b8f0c3f49fd7159618e0ddc9280b12aee5236bf113
|
|
@@ -240,7 +240,8 @@ module Graphiti
|
|
|
240
240
|
children.each do |child|
|
|
241
241
|
if association_type == :many_to_many &&
|
|
242
242
|
[:create, :update].include?(Graphiti.context[:namespace]) &&
|
|
243
|
-
!parent.send(association_name).exists?(child.id)
|
|
243
|
+
!parent.send(association_name).exists?(child.id) &&
|
|
244
|
+
child.errors.blank?
|
|
244
245
|
parent.send(association_name) << child
|
|
245
246
|
else
|
|
246
247
|
target = association.instance_variable_get(:@target)
|
data/lib/graphiti/query.rb
CHANGED
|
@@ -25,7 +25,7 @@ module Graphiti
|
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
typecast_attributes(resource, deserialized_payload.attributes, deserialized_payload.meta[:payload_path])
|
|
28
|
+
typecast_attributes(resource, deserialized_payload.attributes, @action, deserialized_payload.meta[:payload_path])
|
|
29
29
|
process_relationships(resource, deserialized_payload.relationships, deserialized_payload.meta[:payload_path])
|
|
30
30
|
else
|
|
31
31
|
errors.add(:"data.type", :missing)
|
|
@@ -65,15 +65,20 @@ module Graphiti
|
|
|
65
65
|
next
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
resource = x[:resource]
|
|
69
|
+
attributes = x[:attributes]
|
|
70
|
+
relationships = x[:relationships]
|
|
71
|
+
payload_path = x[:meta][:payload_path]
|
|
72
|
+
action = x[:meta][:method]
|
|
73
|
+
typecast_attributes(resource, attributes, action, payload_path)
|
|
74
|
+
process_relationships(resource, relationships, payload_path)
|
|
70
75
|
end
|
|
71
76
|
end
|
|
72
77
|
|
|
73
|
-
def typecast_attributes(resource, attributes, payload_path)
|
|
78
|
+
def typecast_attributes(resource, attributes, action, payload_path)
|
|
74
79
|
attributes.each_pair do |key, value|
|
|
75
80
|
# Only validate id if create action, otherwise it's only used for lookup
|
|
76
|
-
next if
|
|
81
|
+
next if action != :create &&
|
|
77
82
|
key == :id &&
|
|
78
83
|
resource.class.config[:attributes][:id][:writable] == false
|
|
79
84
|
|
data/lib/graphiti/sideload.rb
CHANGED
|
@@ -137,11 +137,16 @@ module Graphiti
|
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
def link_extra_fields
|
|
140
|
+
return unless context&.respond_to?(:params)
|
|
141
|
+
|
|
140
142
|
extra_fields_name = [association_name, resource.type].find { |param|
|
|
141
143
|
context.params.dig(:extra_fields, param)
|
|
142
144
|
}
|
|
143
145
|
|
|
144
|
-
|
|
146
|
+
if extra_fields_name
|
|
147
|
+
extra_fields = context.params.dig(:extra_fields, extra_fields_name)
|
|
148
|
+
{resource.type => extra_fields}
|
|
149
|
+
end
|
|
145
150
|
end
|
|
146
151
|
|
|
147
152
|
# The parent resource is a remote,
|
|
@@ -16,13 +16,11 @@ module Graphiti
|
|
|
16
16
|
|
|
17
17
|
if @name == :id
|
|
18
18
|
@serializer.id(&proc)
|
|
19
|
-
elsif @attr[:proc]
|
|
19
|
+
elsif @attr[:proc] ||
|
|
20
|
+
!previously_applied? ||
|
|
21
|
+
previously_applied_via_resource?
|
|
20
22
|
@serializer.send(_method, @name, serializer_options, &proc)
|
|
21
|
-
|
|
22
|
-
@serializer.send(_method, @name, serializer_options, &proc)
|
|
23
|
-
elsif @serializer.send(applied_method).include?(@name)
|
|
24
|
-
@serializer.field_condition_blocks[@name] = guard if guard?
|
|
25
|
-
else
|
|
23
|
+
else # Previously applied via explicit serializer, so wrap it
|
|
26
24
|
inner = @serializer.attribute_blocks.delete(@name)
|
|
27
25
|
wrapped = wrap_proc(inner)
|
|
28
26
|
@serializer.send(_method, @name, serializer_options, &wrapped)
|
|
@@ -34,6 +32,14 @@ module Graphiti
|
|
|
34
32
|
|
|
35
33
|
private
|
|
36
34
|
|
|
35
|
+
def previously_applied?
|
|
36
|
+
@serializer.attribute_blocks[@name].present?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def previously_applied_via_resource?
|
|
40
|
+
@serializer.send(applied_method).include?(@name)
|
|
41
|
+
end
|
|
42
|
+
|
|
37
43
|
def previously_guarded?
|
|
38
44
|
@serializer.field_condition_blocks[@name]
|
|
39
45
|
end
|
data/lib/graphiti/version.rb
CHANGED
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.2.
|
|
4
|
+
version: 1.2.42
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lee Richmond
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-05-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jsonapi-serializable
|
|
@@ -361,7 +361,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
361
361
|
- !ruby/object:Gem::Version
|
|
362
362
|
version: '0'
|
|
363
363
|
requirements: []
|
|
364
|
-
rubygems_version: 3.0.
|
|
364
|
+
rubygems_version: 3.0.3
|
|
365
365
|
signing_key:
|
|
366
366
|
specification_version: 4
|
|
367
367
|
summary: Easily build jsonapi.org-compatible APIs
|