graphiti 1.7.6 → 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/.github/workflows/ci.yml +4 -4
- data/CHANGELOG.md +16 -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 +11 -4
- 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 +7 -6
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/.github/workflows/ci.yml
CHANGED
@@ -2,7 +2,7 @@ name: CI
|
|
2
2
|
|
3
3
|
on:
|
4
4
|
push:
|
5
|
-
branches: [
|
5
|
+
branches: [master]
|
6
6
|
pull_request: {}
|
7
7
|
|
8
8
|
concurrency:
|
@@ -14,7 +14,7 @@ jobs:
|
|
14
14
|
name: Lint
|
15
15
|
runs-on: ubuntu-latest
|
16
16
|
steps:
|
17
|
-
- uses: actions/checkout@
|
17
|
+
- uses: actions/checkout@v3
|
18
18
|
- uses: ruby/setup-ruby@v1
|
19
19
|
with:
|
20
20
|
ruby-version: "3.0"
|
@@ -94,7 +94,7 @@ jobs:
|
|
94
94
|
- name: Set up Appraisal
|
95
95
|
if: matrix.appraisal
|
96
96
|
run: echo "APPRAISAL_INITIALIZED=true" >> $GITHUB_ENV
|
97
|
-
- uses: actions/checkout@
|
97
|
+
- uses: actions/checkout@v3
|
98
98
|
- uses: ruby/setup-ruby@v1
|
99
99
|
with:
|
100
100
|
ruby-version: ${{ matrix.ruby }}
|
@@ -111,4 +111,4 @@ jobs:
|
|
111
111
|
uses: benc-uk/workflow-dispatch@v1
|
112
112
|
with:
|
113
113
|
workflow: Generate New Release
|
114
|
-
token: ${{ secrets.GITHUB_TOKEN }}
|
114
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
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
|
+
|
12
|
+
## [1.7.7](https://github.com/graphiti-api/graphiti/compare/v1.7.6...v1.7.7) (2025-03-15)
|
13
|
+
|
14
|
+
|
15
|
+
### Bug Fixes
|
16
|
+
|
17
|
+
* change class attribute behavior on endpoint method to work in ruby 3.2+ ([#493](https://github.com/graphiti-api/graphiti/issues/493)) ([04f1f3c](https://github.com/graphiti-api/graphiti/commit/04f1f3c783bfe18e6568cc21924d417a82234135))
|
18
|
+
|
3
19
|
## [1.7.6](https://github.com/graphiti-api/graphiti/compare/v1.7.5...v1.7.6) (2024-11-06)
|
4
20
|
|
5
21
|
|
@@ -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`"
|
@@ -8,10 +8,17 @@ module Graphiti
|
|
8
8
|
def endpoint
|
9
9
|
if (endpoint = super)
|
10
10
|
endpoint
|
11
|
-
|
11
|
+
elsif !@__skip_inference
|
12
12
|
self.endpoint = infer_endpoint
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
def endpoint=(value)
|
17
|
+
# changes introduced in Ruby 3.2 and above require some extra hoops
|
18
|
+
# to allow .endpoint = nil to work properly
|
19
|
+
@__skip_inference = value.blank?
|
20
|
+
super
|
21
|
+
end
|
15
22
|
end
|
16
23
|
|
17
24
|
included do
|
@@ -74,12 +81,12 @@ module Graphiti
|
|
74
81
|
endpoints.any? do |e|
|
75
82
|
has_id = params[:id] || params[:data].try(:[], :id)
|
76
83
|
path = request_path
|
77
|
-
if [:update, :show, :destroy].include?(
|
84
|
+
if [:update, :show, :destroy].include?(action) && has_id
|
78
85
|
path = request_path.split("/")
|
79
|
-
path.pop if path.last == has_id.to_s
|
86
|
+
path.pop if Graphiti::Util::UriDecoder.decode_uri(path.last) == has_id.to_s
|
80
87
|
path = path.join("/")
|
81
88
|
end
|
82
|
-
e[:full_path].to_s == path && e[:actions].include?(
|
89
|
+
e[:full_path].to_s == path && e[:actions].include?(action)
|
83
90
|
end
|
84
91
|
end
|
85
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
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializable
|
@@ -204,7 +204,7 @@ dependencies:
|
|
204
204
|
- - '='
|
205
205
|
- !ruby/object:Gem::Version
|
206
206
|
version: 1.0.beta.4
|
207
|
-
description:
|
207
|
+
description:
|
208
208
|
email:
|
209
209
|
- richmolj@gmail.com
|
210
210
|
executables:
|
@@ -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
|
@@ -346,7 +347,7 @@ homepage: https://github.com/graphiti-api/graphiti
|
|
346
347
|
licenses:
|
347
348
|
- MIT
|
348
349
|
metadata: {}
|
349
|
-
post_install_message:
|
350
|
+
post_install_message:
|
350
351
|
rdoc_options: []
|
351
352
|
require_paths:
|
352
353
|
- lib
|
@@ -362,7 +363,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
362
363
|
version: '0'
|
363
364
|
requirements: []
|
364
365
|
rubygems_version: 3.3.27
|
365
|
-
signing_key:
|
366
|
+
signing_key:
|
366
367
|
specification_version: 4
|
367
368
|
summary: Easily build jsonapi.org-compatible APIs
|
368
369
|
test_files: []
|