graphiti 1.7.7 → 1.7.8
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/CHANGELOG.md +9 -0
- data/lib/graphiti/adapters/active_record/many_to_many_sideload.rb +1 -2
- data/lib/graphiti/adapters/null.rb +8 -0
- data/lib/graphiti/configuration.rb +30 -0
- data/lib/graphiti/resource/links.rb +3 -3
- data/lib/graphiti/sideload.rb +3 -2
- data/lib/graphiti/util/uri_decoder.rb +9 -0
- data/lib/graphiti/version.rb +1 -1
- data/lib/graphiti.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e36dfd471013c8ead523d885a475968aeb18947a268e7b7a68e03e10dcc9fd0d
|
4
|
+
data.tar.gz: a07c6145a4528154dc2592850c434225bfd607038bd80b55ee39efbbac803cb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6cb999efba286de44b69bfb7a3a56333dbf78c2f51b3dc9359f0fff3da867a8a7bdc98cfa55cbef5f44e3146350d09a729f5d2edc43fb50dd02e264d30f1034
|
7
|
+
data.tar.gz: faebd5bf5f20ba3a6df4494c1f45aec44c630afd8841b78daad0e5e575bcd0932560e776c38fe38be77a4d6efd7dd1d59b184ae37ec449778f952b32cbd69562
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
graphiti changelog
|
2
2
|
|
3
|
+
## [1.7.8](https://github.com/graphiti-api/graphiti/compare/v1.7.7...v1.7.8) (2025-03-16)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* compare URI-decoded path params ([#482](https://github.com/graphiti-api/graphiti/issues/482)) ([20b80dd](https://github.com/graphiti-api/graphiti/commit/20b80dd35bfa4e2f677af3fb9472def6da668149))
|
9
|
+
* correct issue with many_to_many when one of the models has a prefix to the intersection model association ([#449](https://github.com/graphiti-api/graphiti/issues/449)) ([dc28a4f](https://github.com/graphiti-api/graphiti/commit/dc28a4f72fe4c577e23ced102a0b5e7063ba8026))
|
10
|
+
* lazy constantize relation resources ([#492](https://github.com/graphiti-api/graphiti/issues/492)) ([3cc2983](https://github.com/graphiti-api/graphiti/commit/3cc298399b4dc8970a2beed49b333396c76bd218))
|
11
|
+
|
3
12
|
## [1.7.7](https://github.com/graphiti-api/graphiti/compare/v1.7.6...v1.7.7) (2025-03-15)
|
4
13
|
|
5
14
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
class Graphiti::Adapters::ActiveRecord::ManyToManySideload < Graphiti::Sideload::ManyToMany
|
2
2
|
def through_table_name
|
3
|
-
@through_table_name ||=
|
4
|
-
.reflections[through.to_s].klass.table_name
|
3
|
+
@through_table_name ||= resource_class.model.reflections[through.to_s].klass.table_name
|
5
4
|
end
|
6
5
|
|
7
6
|
def through_relationship_name
|
@@ -18,6 +18,7 @@ module Graphiti
|
|
18
18
|
attr_accessor :before_sideload
|
19
19
|
|
20
20
|
attr_reader :debug, :debug_models
|
21
|
+
attr_reader :uri_decoder
|
21
22
|
|
22
23
|
attr_writer :schema_path
|
23
24
|
attr_writer :cache_rendering
|
@@ -37,6 +38,8 @@ module Graphiti
|
|
37
38
|
self.debug = ENV.fetch("GRAPHITI_DEBUG", true)
|
38
39
|
self.debug_models = ENV.fetch("GRAPHITI_DEBUG_MODELS", false)
|
39
40
|
|
41
|
+
@uri_decoder = infer_uri_decoder
|
42
|
+
|
40
43
|
# FIXME: Don't duplicate graphiti-rails efforts
|
41
44
|
if defined?(::Rails.root) && (root = ::Rails.root)
|
42
45
|
config_file = root.join(".graphiticfg.yml")
|
@@ -85,6 +88,33 @@ module Graphiti
|
|
85
88
|
ensure
|
86
89
|
send(:"#{key}=", original)
|
87
90
|
end
|
91
|
+
|
92
|
+
def uri_decoder=(decoder)
|
93
|
+
unless decoder.respond_to?(:call)
|
94
|
+
raise "uri_decoder must respond to `call`."
|
95
|
+
end
|
96
|
+
|
97
|
+
@uri_decoder = decoder
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def infer_uri_decoder
|
103
|
+
if defined?(::ActionDispatch::Journey::Router::Utils)
|
104
|
+
# available in all supported versions of Rails.
|
105
|
+
# This method should be preferred for comparing URI path segments
|
106
|
+
# to params, as it is the exact decoder used in the Rails router.
|
107
|
+
@uri_decoder = ::ActionDispatch::Journey::Router::Utils.method(:unescape_uri)
|
108
|
+
elsif URI.respond_to?(:decode_uri_component)
|
109
|
+
# available in Ruby >= 3.2
|
110
|
+
@uri_decoder = URI.method(:decode_uri_component)
|
111
|
+
end
|
112
|
+
rescue => e
|
113
|
+
Kernel.warn("Error inferring Graphiti uri_decoder: #{e}")
|
114
|
+
ensure
|
115
|
+
# fallback
|
116
|
+
@uri_decoder ||= :itself.to_proc
|
117
|
+
end
|
88
118
|
end
|
89
119
|
|
90
120
|
msg = "Use graphiti-rails's `config.graphiti.respond_to_formats`"
|
@@ -81,12 +81,12 @@ module Graphiti
|
|
81
81
|
endpoints.any? do |e|
|
82
82
|
has_id = params[:id] || params[:data].try(:[], :id)
|
83
83
|
path = request_path
|
84
|
-
if [:update, :show, :destroy].include?(
|
84
|
+
if [:update, :show, :destroy].include?(action) && has_id
|
85
85
|
path = request_path.split("/")
|
86
|
-
path.pop if path.last == has_id.to_s
|
86
|
+
path.pop if Graphiti::Util::UriDecoder.decode_uri(path.last) == has_id.to_s
|
87
87
|
path = path.join("/")
|
88
88
|
end
|
89
|
-
e[:full_path].to_s == path && e[:actions].include?(
|
89
|
+
e[:full_path].to_s == path && e[:actions].include?(action)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
data/lib/graphiti/sideload.rb
CHANGED
@@ -21,7 +21,7 @@ module Graphiti
|
|
21
21
|
@name = name
|
22
22
|
validate_options!(opts)
|
23
23
|
@parent_resource_class = opts[:parent_resource]
|
24
|
-
@
|
24
|
+
@resource_class_name = opts[:resource]
|
25
25
|
@primary_key = opts[:primary_key]
|
26
26
|
@foreign_key = opts[:foreign_key]
|
27
27
|
@type = opts[:type]
|
@@ -177,7 +177,8 @@ module Graphiti
|
|
177
177
|
end
|
178
178
|
|
179
179
|
def resource_class
|
180
|
-
@resource_class ||=
|
180
|
+
@resource_class ||= (@resource_class_name.is_a?(String) ? @resource_class_name.constantize : @resource_class_name) ||
|
181
|
+
infer_resource_class
|
181
182
|
end
|
182
183
|
|
183
184
|
def scope(parents)
|
data/lib/graphiti/version.rb
CHANGED
data/lib/graphiti.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.7.
|
4
|
+
version: 1.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializable
|
@@ -339,6 +339,7 @@ files:
|
|
339
339
|
- lib/graphiti/util/sideload.rb
|
340
340
|
- lib/graphiti/util/simple_errors.rb
|
341
341
|
- lib/graphiti/util/transaction_hooks_recorder.rb
|
342
|
+
- lib/graphiti/util/uri_decoder.rb
|
342
343
|
- lib/graphiti/util/validation_response.rb
|
343
344
|
- lib/graphiti/version.rb
|
344
345
|
- package.json
|