graphiti 1.2.34 → 1.2.35
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aaea1da30c8eb6b86abc1be0df8fba47d2df8f55be42f6141f78976a2c02dea
|
4
|
+
data.tar.gz: c4611d1226bc10b04a755e29943bc131831cb9df23cb55480ab3daa3cfa8d4b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20c0ca9615484a566e528c5851702dfff7436c37e3ccf7774ef37611699397870bb74be19f633b1dfc9eca9c315642a29777412c66823550290bca8406e6a254
|
7
|
+
data.tar.gz: 1edb1ae4364f3b348fa74dffc6c8a794b0e54d39289144614e0c9e605e0dc3df6f850ea72b7117f99a72725ffc9cf536cda93a9694ee3a39a7cc21748405973b
|
@@ -26,17 +26,17 @@ module Graphiti
|
|
26
26
|
[:data, :type],
|
27
27
|
[:data, :id]
|
28
28
|
].each do |required_attr|
|
29
|
-
attribute_mismatch(required_attr) unless @
|
29
|
+
attribute_mismatch(required_attr) unless @params.dig(*required_attr)
|
30
30
|
end
|
31
31
|
errors.blank?
|
32
32
|
end
|
33
33
|
|
34
34
|
def payload_matches_endpoint?
|
35
|
-
unless @
|
35
|
+
unless @params.dig(:data, :id) == @params.dig(:filter, :id)
|
36
36
|
attribute_mismatch([:data, :id])
|
37
37
|
end
|
38
38
|
|
39
|
-
meta_type = @
|
39
|
+
meta_type = @params.dig(:data, :type)
|
40
40
|
|
41
41
|
# NOTE: calling #to_s and comparing 2 strings is slower than
|
42
42
|
# calling #to_sym and comparing 2 symbols. But pre ruby-2.2
|
@@ -5,21 +5,31 @@ module Graphiti
|
|
5
5
|
|
6
6
|
def initialize(root_resource, raw_params, action)
|
7
7
|
@root_resource = root_resource
|
8
|
-
@
|
8
|
+
@params = normalized_params(raw_params)
|
9
9
|
@errors = Graphiti::Util::SimpleErrors.new(raw_params)
|
10
10
|
@action = action
|
11
11
|
end
|
12
12
|
|
13
13
|
def validate
|
14
|
+
# Right now, all requests - even reads - go through the validator
|
15
|
+
# In the future these should have their own validation logic, but
|
16
|
+
# for now we can just bypass
|
17
|
+
return true unless @params.has_key?(:data)
|
18
|
+
|
14
19
|
resource = @root_resource
|
15
|
-
|
16
|
-
|
17
|
-
|
20
|
+
|
21
|
+
if @params[:data].has_key?(:type)
|
22
|
+
if (meta_type = deserialized_payload.meta[:type].try(:to_sym))
|
23
|
+
if @root_resource.type != meta_type && @root_resource.polymorphic?
|
24
|
+
resource = @root_resource.class.resource_for_type(meta_type).new
|
25
|
+
end
|
18
26
|
end
|
19
|
-
end
|
20
27
|
|
21
|
-
|
22
|
-
|
28
|
+
typecast_attributes(resource, deserialized_payload.attributes, deserialized_payload.meta[:payload_path])
|
29
|
+
process_relationships(resource, deserialized_payload.relationships, deserialized_payload.meta[:payload_path])
|
30
|
+
else
|
31
|
+
errors.add(:"data.type", :missing)
|
32
|
+
end
|
23
33
|
|
24
34
|
errors.blank?
|
25
35
|
end
|
@@ -33,14 +43,7 @@ module Graphiti
|
|
33
43
|
end
|
34
44
|
|
35
45
|
def deserialized_payload
|
36
|
-
@deserialized_payload ||=
|
37
|
-
payload = normalized_params
|
38
|
-
if payload[:data] && payload[:data][:type]
|
39
|
-
Graphiti::Deserializer.new(payload)
|
40
|
-
else
|
41
|
-
Graphiti::Deserializer.new({})
|
42
|
-
end
|
43
|
-
end
|
46
|
+
@deserialized_payload ||= Graphiti::Deserializer.new(@params)
|
44
47
|
end
|
45
48
|
|
46
49
|
private
|
@@ -86,8 +89,8 @@ module Graphiti
|
|
86
89
|
end
|
87
90
|
end
|
88
91
|
|
89
|
-
def normalized_params
|
90
|
-
normalized =
|
92
|
+
def normalized_params(raw_params)
|
93
|
+
normalized = raw_params
|
91
94
|
if normalized.respond_to?(:to_unsafe_h)
|
92
95
|
normalized = normalized.to_unsafe_h.deep_symbolize_keys
|
93
96
|
end
|
@@ -3,10 +3,12 @@ module Graphiti
|
|
3
3
|
include Scoping::Filterable
|
4
4
|
|
5
5
|
def apply
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
unless @opts[:bypass_required_filters]
|
7
|
+
Graphiti::Scoping::FilterGroupValidator.new(
|
8
|
+
resource,
|
9
|
+
query_hash
|
10
|
+
).raise_unless_filter_group_requirements_met!
|
11
|
+
end
|
10
12
|
|
11
13
|
if missing_required_filters.any? && !@opts[:bypass_required_filters]
|
12
14
|
raise Errors::RequiredFilter.new(resource, missing_required_filters)
|
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.35
|
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-03-
|
11
|
+
date: 2021-03-18 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.6
|
365
365
|
signing_key:
|
366
366
|
specification_version: 4
|
367
367
|
summary: Easily build jsonapi.org-compatible APIs
|