graphiti 1.8.2 → 1.10.0
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 +14 -0
- data/CHANGELOG.md +14 -0
- data/gemfiles/rails_8_1_graphiti_rails.gemfile +19 -0
- data/lib/graphiti/configuration.rb +1 -1
- data/lib/graphiti/resource/interface.rb +3 -2
- data/lib/graphiti/resource_proxy.rb +29 -5
- data/lib/graphiti/runner.rb +10 -3
- data/lib/graphiti/util/cache_debug.rb +3 -1
- data/lib/graphiti/version.rb +1 -1
- 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: ad1f5708fdf6d0ce3e322a050c23440765c7d965be7020e1c1fa1a4a8205ee85
|
|
4
|
+
data.tar.gz: b80f90e0cc2421b89ef4ccbb142bb8ee67ccb5490eb55ace716ca22e154cc578
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f2a223141a825552d578c2b3720a2157337e48ff7a4c3bb55b09eb3dac0093f65903c20b048893b8ab61ea47cc21c61c41a25ae59aa2163efe08c721e5dd5b8
|
|
7
|
+
data.tar.gz: 4bb15d52b3749de416d8c90cf6e9964614412346ed25e9504135da48b187d5212aa6c79931e8c4ff1691cc83bea439f12d3d2813736c23bc80afbb9c8082ee6c
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -45,6 +45,7 @@ jobs:
|
|
|
45
45
|
- gemfiles/rails_7_1_graphiti_rails.gemfile
|
|
46
46
|
- gemfiles/rails_7_2_graphiti_rails.gemfile
|
|
47
47
|
- gemfiles/rails_8_0_graphiti_rails.gemfile
|
|
48
|
+
- gemfiles/rails_8_1_graphiti_rails.gemfile
|
|
48
49
|
appraisal:
|
|
49
50
|
- true
|
|
50
51
|
- false
|
|
@@ -58,6 +59,9 @@ jobs:
|
|
|
58
59
|
- ruby: ruby-head
|
|
59
60
|
gemfile: gemfiles/rails_8_0_graphiti_rails.gemfile
|
|
60
61
|
appraisal: true
|
|
62
|
+
- ruby: ruby-head
|
|
63
|
+
gemfile: gemfiles/rails_8_1_graphiti_rails.gemfile
|
|
64
|
+
appraisal: true
|
|
61
65
|
- ruby: ruby-head
|
|
62
66
|
gemfile: Gemfile
|
|
63
67
|
appraisal: false
|
|
@@ -83,6 +87,16 @@ jobs:
|
|
|
83
87
|
appraisal: false
|
|
84
88
|
- gemfile: gemfiles/rails_8_0_graphiti_rails.gemfile
|
|
85
89
|
appraisal: false
|
|
90
|
+
- gemfile: gemfiles/rails_8_1_graphiti_rails.gemfile
|
|
91
|
+
appraisal: false
|
|
92
|
+
|
|
93
|
+
# Rails 8.1 needs ruby 3.2 +
|
|
94
|
+
- gemfile: gemfiles/rails_8_1_graphiti_rails.gemfile
|
|
95
|
+
ruby: 2.7
|
|
96
|
+
- gemfile: gemfiles/rails_8_1_graphiti_rails.gemfile
|
|
97
|
+
ruby: 3.0
|
|
98
|
+
- gemfile: gemfiles/rails_8_1_graphiti_rails.gemfile
|
|
99
|
+
ruby: 3.1
|
|
86
100
|
|
|
87
101
|
# Rails 8 needs ruby 3.2 +
|
|
88
102
|
- gemfile: gemfiles/rails_8_0_graphiti_rails.gemfile
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
graphiti changelog
|
|
2
2
|
|
|
3
|
+
# [1.10.0](https://github.com/graphiti-api/graphiti/compare/v1.9.0...v1.10.0) (2026-01-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add cache tag support to allow context-aware caching ([#498](https://github.com/graphiti-api/graphiti/issues/498)) ([e8c2bad](https://github.com/graphiti-api/graphiti/commit/e8c2bad478cb3dd8dbd1a5e993b10f84046a0fa8))
|
|
9
|
+
|
|
10
|
+
# [1.9.0](https://github.com/graphiti-api/graphiti/compare/v1.8.2...v1.9.0) (2026-01-03)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* Support rails 8.1 ([#500](https://github.com/graphiti-api/graphiti/issues/500)) ([34d0cf0](https://github.com/graphiti-api/graphiti/commit/34d0cf03b6b4d887d10d660f0ae08bfa6833345f))
|
|
16
|
+
|
|
3
17
|
## [1.8.2](https://github.com/graphiti-api/graphiti/compare/v1.8.1...v1.8.2) (2025-05-20)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "rails", "~> 8.1"
|
|
6
|
+
gem "rspec-rails"
|
|
7
|
+
gem "sqlite3", "~> 2.1"
|
|
8
|
+
gem "database_cleaner"
|
|
9
|
+
gem "graphiti-rails", "~> 0.4.0"
|
|
10
|
+
|
|
11
|
+
group :test do
|
|
12
|
+
gem "pry"
|
|
13
|
+
gem "pry-byebug", platform: [:mri]
|
|
14
|
+
gem "appraisal"
|
|
15
|
+
gem "guard"
|
|
16
|
+
gem "guard-rspec"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
gemspec path: "../"
|
|
@@ -115,7 +115,7 @@ module Graphiti
|
|
|
115
115
|
private
|
|
116
116
|
|
|
117
117
|
def infer_uri_decoder
|
|
118
|
-
if defined?(::ActionDispatch::Journey::Router::Utils)
|
|
118
|
+
if defined?(::ActionDispatch::Journey::Router::Utils) && ::ActionDispatch::Journey::Router::Utils.respond_to?(:unescape_uri)
|
|
119
119
|
# available in all supported versions of Rails.
|
|
120
120
|
# This method should be preferred for comparing URI path segments
|
|
121
121
|
# to params, as it is the exact decoder used in the Rails router.
|
|
@@ -4,9 +4,10 @@ module Graphiti
|
|
|
4
4
|
extend ActiveSupport::Concern
|
|
5
5
|
|
|
6
6
|
class_methods do
|
|
7
|
-
def cache_resource(expires_in: false)
|
|
7
|
+
def cache_resource(expires_in: false, tag: nil)
|
|
8
8
|
@cache_resource = true
|
|
9
9
|
@cache_expires_in = expires_in
|
|
10
|
+
@cache_tag = tag
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def all(params = {}, base_scope = nil)
|
|
@@ -55,7 +56,7 @@ module Graphiti
|
|
|
55
56
|
private
|
|
56
57
|
|
|
57
58
|
def caching_options
|
|
58
|
-
{cache: @cache_resource, cache_expires_in: @cache_expires_in}
|
|
59
|
+
{cache: @cache_resource, cache_expires_in: @cache_expires_in, cache_tag: @cache_tag}
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
def validate_request!(params)
|
|
@@ -2,14 +2,19 @@ module Graphiti
|
|
|
2
2
|
class ResourceProxy
|
|
3
3
|
include Enumerable
|
|
4
4
|
|
|
5
|
-
attr_reader :resource, :query, :scope, :payload, :cache_expires_in, :cache
|
|
5
|
+
attr_reader :resource, :query, :scope, :payload, :cache_expires_in, :cache, :cache_tag
|
|
6
6
|
|
|
7
|
-
def initialize(
|
|
7
|
+
def initialize(
|
|
8
|
+
resource,
|
|
9
|
+
scope,
|
|
10
|
+
query,
|
|
8
11
|
payload: nil,
|
|
9
12
|
single: false,
|
|
10
13
|
raise_on_missing: false,
|
|
11
14
|
cache: nil,
|
|
12
|
-
cache_expires_in: nil
|
|
15
|
+
cache_expires_in: nil,
|
|
16
|
+
cache_tag: nil
|
|
17
|
+
)
|
|
13
18
|
|
|
14
19
|
@resource = resource
|
|
15
20
|
@scope = scope
|
|
@@ -19,6 +24,7 @@ module Graphiti
|
|
|
19
24
|
@raise_on_missing = raise_on_missing
|
|
20
25
|
@cache = cache
|
|
21
26
|
@cache_expires_in = cache_expires_in
|
|
27
|
+
@cache_tag = cache_tag
|
|
22
28
|
end
|
|
23
29
|
|
|
24
30
|
def cache?
|
|
@@ -207,12 +213,30 @@ module Graphiti
|
|
|
207
213
|
"W/#{ActiveSupport::Digest.hexdigest(cache_key_with_version.to_s)}"
|
|
208
214
|
end
|
|
209
215
|
|
|
216
|
+
def resource_cache_tag
|
|
217
|
+
return unless @cache_tag.present? && @resource.respond_to?(@cache_tag)
|
|
218
|
+
|
|
219
|
+
@resource.try(@cache_tag)
|
|
220
|
+
end
|
|
221
|
+
|
|
210
222
|
def cache_key
|
|
211
|
-
ActiveSupport::Cache.expand_cache_key(
|
|
223
|
+
ActiveSupport::Cache.expand_cache_key(
|
|
224
|
+
[
|
|
225
|
+
@scope.cache_key,
|
|
226
|
+
@query.cache_key,
|
|
227
|
+
resource_cache_tag
|
|
228
|
+
].compact_blank
|
|
229
|
+
)
|
|
212
230
|
end
|
|
213
231
|
|
|
214
232
|
def cache_key_with_version
|
|
215
|
-
ActiveSupport::Cache.expand_cache_key(
|
|
233
|
+
ActiveSupport::Cache.expand_cache_key(
|
|
234
|
+
[
|
|
235
|
+
@scope.cache_key_with_version,
|
|
236
|
+
@query.cache_key,
|
|
237
|
+
resource_cache_tag
|
|
238
|
+
].compact_blank
|
|
239
|
+
)
|
|
216
240
|
end
|
|
217
241
|
|
|
218
242
|
private
|
data/lib/graphiti/runner.rb
CHANGED
|
@@ -58,22 +58,29 @@ module Graphiti
|
|
|
58
58
|
|
|
59
59
|
def proxy(base = nil, opts = {})
|
|
60
60
|
base ||= jsonapi_resource.base_scope
|
|
61
|
-
scope_opts = opts.slice
|
|
61
|
+
scope_opts = opts.slice(
|
|
62
|
+
:sideload_parent_length,
|
|
62
63
|
:default_paginate,
|
|
63
64
|
:after_resolve,
|
|
64
65
|
:sideload,
|
|
65
66
|
:parent,
|
|
66
67
|
:params,
|
|
67
68
|
:bypass_required_filters
|
|
69
|
+
)
|
|
70
|
+
|
|
68
71
|
scope = jsonapi_scope(base, scope_opts)
|
|
69
|
-
|
|
72
|
+
|
|
73
|
+
::Graphiti::ResourceProxy.new(
|
|
74
|
+
jsonapi_resource,
|
|
70
75
|
scope,
|
|
71
76
|
query,
|
|
72
77
|
payload: deserialized_payload,
|
|
73
78
|
single: opts[:single],
|
|
74
79
|
raise_on_missing: opts[:raise_on_missing],
|
|
75
80
|
cache: opts[:cache],
|
|
76
|
-
cache_expires_in: opts[:cache_expires_in]
|
|
81
|
+
cache_expires_in: opts[:cache_expires_in],
|
|
82
|
+
cache_tag: opts[:cache_tag]
|
|
83
|
+
)
|
|
77
84
|
end
|
|
78
85
|
end
|
|
79
86
|
end
|
|
@@ -12,7 +12,9 @@ module Graphiti
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def name
|
|
15
|
-
|
|
15
|
+
tag = proxy.resource_cache_tag
|
|
16
|
+
|
|
17
|
+
"#{::Graphiti.context[:object]&.request&.method} #{::Graphiti.context[:object]&.request&.url} #{tag}"
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
def key
|
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.
|
|
4
|
+
version: 1.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lee Richmond
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jsonapi-serializable
|
|
@@ -264,6 +264,7 @@ files:
|
|
|
264
264
|
- gemfiles/rails_7_2_graphiti_rails.gemfile
|
|
265
265
|
- gemfiles/rails_7_graphiti_rails.gemfile
|
|
266
266
|
- gemfiles/rails_8_0_graphiti_rails.gemfile
|
|
267
|
+
- gemfiles/rails_8_1_graphiti_rails.gemfile
|
|
267
268
|
- graphiti.gemspec
|
|
268
269
|
- lib/graphiti.rb
|
|
269
270
|
- lib/graphiti/adapters/abstract.rb
|