graphiti 1.3.9 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30f5b9382256603c1f3f8f4ab8c4e614804c1a2e2152617d7b19892bca6bd465
4
- data.tar.gz: 948837bfa0f8deee2f44849aba9df2bb18f2fdf532a1caaab92b16c7d9ba91fd
3
+ metadata.gz: 204d1a4f58e02729d7ce4f924845e1517a3cdd22e40399624b182bce2e41a48e
4
+ data.tar.gz: 0246a34ea30c9f27a58be2ba507cc27a41ab6d478947425967758f2c528bbd52
5
5
  SHA512:
6
- metadata.gz: 4fe6fff9c219fd463378bbdc793f648cbeffe27c61c191f11e2aab4723e952d2d8f7cc26b334255e12adca3e9d819b1bbde17697a6621f11a28151d2649d6d9c
7
- data.tar.gz: becca9eaa17f328a99669e1e855a4024862b45d1902ddf30de597f7b33e3f52e4145b0f1dba1542a0d144ba2bc1bdec280ad9d8fa599a102ead9efb5260e1ab3
6
+ metadata.gz: 80f71ce21c23066cc5d362b62e292442d8850e598a6039d77580a094028e11716d72032921af12186b792730b61e3e94069a813debce308a728c6533c69df7c2
7
+ data.tar.gz: fec525c3040ca87f939cdf879cbf469dde0d1c263845e54a3a01e29d7e79447bf2221af39026d9bc98aa6df826b0ce9068d9736d2f859313ec0b8f9b8c19f54a
@@ -0,0 +1,2 @@
1
+ enabled:
2
+ - cla
@@ -28,10 +28,11 @@ jobs:
28
28
  fail-fast: false
29
29
  matrix:
30
30
  ruby:
31
- - "2.6"
32
31
  - "2.7"
33
32
  - "3.0"
34
33
  - "3.1"
34
+ - "3.2"
35
+ - "3.3"
35
36
  gemfile:
36
37
  - Gemfile
37
38
  - gemfiles/rails_5_2.gemfile
@@ -40,12 +41,13 @@ jobs:
40
41
  - gemfiles/rails_5_2_graphiti_rails.gemfile
41
42
  - gemfiles/rails_6_graphiti_rails.gemfile
42
43
  - gemfiles/rails_7_graphiti_rails.gemfile
44
+ - gemfiles/rails_7_1_graphiti_rails.gemfile
43
45
  appraisal:
44
46
  - true
45
47
  - false
46
48
  include:
47
49
  - ruby: ruby-head
48
- gemfile: Gemfile
50
+ gemfile: gemfiles/rails_7_1.gemfile
49
51
  appraisal: true
50
52
  - ruby: ruby-head
51
53
  gemfile: Gemfile
@@ -66,7 +68,9 @@ jobs:
66
68
  appraisal: false
67
69
  - gemfile: gemfiles/rails_7_graphiti_rails.gemfile
68
70
  appraisal: false
69
- # Rails 5 can't run on Ruby 3
71
+ - gemfile: gemfiles/rails_7_1_graphiti_rails.gemfile
72
+ appraisal: false
73
+ # Rails 5 can't run on Ruby 3
70
74
  - gemfile: gemfiles/rails_5_2.gemfile
71
75
  ruby: 3.0
72
76
  - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile
@@ -75,11 +79,14 @@ jobs:
75
79
  ruby: 3.1
76
80
  - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile
77
81
  ruby: 3.1
78
- # Raise 7 can't run on 2.6
79
- - gemfile: gemfiles/rails_7.gemfile
80
- ruby: 2.6
81
- - gemfile: gemfiles/rails_7_graphiti_rails.gemfile
82
- ruby: 2.6
82
+ - gemfile: gemfiles/rails_5_2.gemfile
83
+ ruby: 3.2
84
+ - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile
85
+ ruby: 3.2
86
+ - gemfile: gemfiles/rails_5_2.gemfile
87
+ ruby: 3.3
88
+ - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile
89
+ ruby: 3.3
83
90
  continue-on-error: ${{ matrix.ruby == 'ruby-head' }}
84
91
  env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
85
92
  BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
data/Appraisals CHANGED
@@ -42,3 +42,18 @@ appraise "rails-7-graphiti-rails" do
42
42
  gem "database_cleaner"
43
43
  gem "graphiti-rails", "~> 0.4.0"
44
44
  end
45
+
46
+ appraise "rails-7-1" do
47
+ gem "rails", "~> 7.1"
48
+ gem "rspec-rails"
49
+ gem "sqlite3", "~> 1.4.0"
50
+ gem "database_cleaner"
51
+ end
52
+
53
+ appraise "rails-7-1-graphiti-rails" do
54
+ gem "rails", "~> 7.1"
55
+ gem "rspec-rails"
56
+ gem "sqlite3", "~> 1.4.0"
57
+ gem "database_cleaner"
58
+ gem "graphiti-rails", "~> 0.4.0"
59
+ end
data/CHANGELOG.md CHANGED
@@ -1,4 +1,18 @@
1
- ## Unreleased
1
+ ## 1.4.0, Sun March 17th 2024
2
+ Features:
3
+ - [461](https://github.com/graphiti-api/graphiti/pull/461), [463](https://github.com/graphiti-api/graphiti/pull/463) Add support for Rails 7.1 + Ruby 3.2 + Ruby 3.3
4
+
5
+ Fixes:
6
+ - [464](https://github.com/graphiti-api/graphiti/pull/464) Check for url presence before trying to append
7
+ - [407](https://github.com/graphiti-api/graphiti/pull/407) Sort types in generated schema
8
+ - [421](https://github.com/graphiti-api/graphiti/pull/421) Re-use resource class for remote sideloads to avoid memory leak
9
+ - [452](https://github.com/graphiti-api/graphiti/pull/452) Resolve inconsistency for filters containing curly brackets
10
+ - [446](https://github.com/graphiti-api/graphiti/pull/446) Fix private call
11
+
12
+ ## 1.3.9, May 25th 2022
13
+ Use an options hash for log subscriber instead of positional arguments
14
+
15
+ ## 1.x ??
2
16
 
3
17
  Features:
4
18
  - [329](https://github.com/graphiti-api/graphiti/pull/329) Propagate `extra_fields` to related resource links.
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :test do
7
+ gem "database_cleaner"
7
8
  gem "pry"
8
9
  gem "pry-byebug", platform: [:mri]
9
10
  gem "appraisal"
@@ -0,0 +1,18 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 7.1"
6
+ gem "rspec-rails"
7
+ gem "sqlite3", "~> 1.4.0"
8
+ gem "database_cleaner"
9
+
10
+ group :test do
11
+ gem "pry"
12
+ gem "pry-byebug", platform: [:mri]
13
+ gem "appraisal"
14
+ gem "guard"
15
+ gem "guard-rspec"
16
+ end
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,19 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 7.1"
6
+ gem "rspec-rails"
7
+ gem "sqlite3", "~> 1.4.0"
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: "../"
@@ -140,7 +140,6 @@ module Graphiti
140
140
  params ||= {}
141
141
  params = params.to_unsafe_h if params.respond_to?(:to_unsafe_h)
142
142
  params.reject! { |k, v| [:controller, :action, :format, :debug].include?(k.to_sym) }
143
- params.reject! { |k, v| k.to_sym == :include }
144
143
  params.deep_symbolize_keys
145
144
  end
146
145
 
@@ -76,11 +76,14 @@ module Graphiti
76
76
  end
77
77
  end
78
78
 
79
+ class RemoteSideloadResource < ::Graphiti::Resource
80
+ self.remote = "_remote_sideload_".freeze
81
+ self.abstract_class = true # exclude from schema
82
+ end
83
+
79
84
  def resource_for_sideload(sideload)
80
85
  if @resource.remote?
81
- Class.new(Graphiti::Resource) {
82
- self.remote = "_remote_sideload_"
83
- }.new
86
+ RemoteSideloadResource.new
84
87
  else
85
88
  sideload.resource
86
89
  end
@@ -205,7 +205,7 @@ module Graphiti
205
205
  options[name] ||= send(:"relationships_#{name}_by_default")
206
206
  end
207
207
  end
208
- private :attribute_option
208
+ private :relationship_option
209
209
  end
210
210
  end
211
211
  end
@@ -68,7 +68,7 @@ module Graphiti
68
68
  model_ref = model
69
69
  has_many name, opts do
70
70
  params do |hash|
71
- hash[:filter][:"#{as}_type"] = { eql: model_ref.name }
71
+ hash[:filter][:"#{as}_type"] = {eql: model_ref.name}
72
72
  end
73
73
 
74
74
  instance_eval(&blk) if blk
@@ -82,7 +82,7 @@ module Graphiti
82
82
  model_ref = model
83
83
  has_one name, opts do
84
84
  params do |hash|
85
- hash[:filter][:"#{as}_type"] = { eql: model_ref.name }
85
+ hash[:filter][:"#{as}_type"] = {eql: model_ref.name}
86
86
  end
87
87
 
88
88
  instance_eval(&blk) if blk
@@ -153,11 +153,13 @@ module Graphiti
153
153
  success
154
154
  end
155
155
 
156
- def update_attributes
156
+ def update
157
157
  data
158
158
  save(action: :update)
159
159
  end
160
160
 
161
+ alias update_attributes update # standard:disable Style/Alias
162
+
161
163
  def include_hash
162
164
  @include_hash ||= begin
163
165
  base = @payload ? @payload.include_hash : {}
@@ -42,7 +42,7 @@ module Graphiti
42
42
 
43
43
  def generate_types
44
44
  {}.tap do |types|
45
- Graphiti::Types.map.each_pair do |name, config|
45
+ Graphiti::Types.map.sort.each_entry do |name, config|
46
46
  types[name] = config.slice(:kind, :description)
47
47
  end
48
48
  end
@@ -193,14 +193,14 @@ module Graphiti
193
193
  # Find the quoted strings
194
194
  quotes = value.scan(/{{.*?}}/)
195
195
  # remove them from the rest
196
- quotes.each { |q| value.gsub!(q, "") }
196
+ non_quotes = quotes.inject(value) { |v, q| v.gsub(q, "") }
197
197
  # remove the quote characters from the quoted strings
198
198
  quotes.each { |q| q.gsub!("{{", "").gsub!("}}", "") }
199
199
  # merge everything back together into an array
200
200
  value = if singular_filter
201
- Array(value) + quotes
201
+ Array(non_quotes) + quotes
202
202
  else
203
- Array(value.split(",")) + quotes
203
+ Array(non_quotes.split(",")) + quotes
204
204
  end
205
205
  # remove any blanks that are left
206
206
  value.reject! { |v| v.length.zero? }
@@ -48,6 +48,7 @@ module Graphiti
48
48
 
49
49
  def on_demand_links(url)
50
50
  return url unless Graphiti.config.links_on_demand
51
+ return unless url
51
52
 
52
53
  url << if url.include?("?")
53
54
  "&links=true"
@@ -118,7 +118,7 @@ module Graphiti
118
118
  cache_key = :"#{@sideload.object_id}-#{action}"
119
119
  return if self.class.validated_link_cache.include?(cache_key)
120
120
  prc = Graphiti.config.context_for_endpoint
121
- unless prc.call(sideload.resource.endpoint[:full_path], action)
121
+ unless prc.call(sideload.resource.endpoint[:full_path].to_s, action)
122
122
  raise Errors::InvalidLink.new(@resource_class, sideload, action)
123
123
  end
124
124
  self.class.validated_link_cache << cache_key
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.3.9"
2
+ VERSION = "1.4.0"
3
3
  end
data/lib/graphiti.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "json"
2
2
  require "forwardable"
3
+ require "uri"
3
4
  require "active_support/core_ext/string"
4
5
  require "active_support/core_ext/enumerable"
5
6
  require "active_support/core_ext/class/attribute"
@@ -83,7 +84,12 @@ module Graphiti
83
84
  end
84
85
 
85
86
  def self.log(msg, color = :white, bold = false)
86
- colored = ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold)
87
+ colored = if ::ActiveSupport.version >= Gem::Version.new("7.1")
88
+ ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold: bold)
89
+ else
90
+ ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold)
91
+ end
92
+
87
93
  logger.debug(colored)
88
94
  end
89
95
 
@@ -131,7 +137,6 @@ require "graphiti/resource_proxy"
131
137
  require "graphiti/request_validator"
132
138
  require "graphiti/request_validators/validator"
133
139
  require "graphiti/request_validators/update_validator"
134
- require "graphiti/query"
135
140
  require "graphiti/scope"
136
141
  require "graphiti/deserializer"
137
142
  require "graphiti/renderer"
@@ -170,6 +175,7 @@ require "graphiti/extensions/extra_attribute"
170
175
  require "graphiti/extensions/boolean_attribute"
171
176
  require "graphiti/extensions/temp_id"
172
177
  require "graphiti/serializer"
178
+ require "graphiti/query"
173
179
  require "graphiti/debugger"
174
180
 
175
181
  if defined?(ActiveRecord)
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.3.9
4
+ version: 1.4.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: 2022-05-25 00:00:00.000000000 Z
11
+ date: 2024-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-serializable
@@ -212,6 +212,7 @@ executables:
212
212
  extensions: []
213
213
  extra_rdoc_files: []
214
214
  files:
215
+ - ".github/probots.yml"
215
216
  - ".github/workflows/ci.yml"
216
217
  - ".gitignore"
217
218
  - ".rspec"
@@ -251,6 +252,8 @@ files:
251
252
  - gemfiles/rails_6.gemfile
252
253
  - gemfiles/rails_6_graphiti_rails.gemfile
253
254
  - gemfiles/rails_7.gemfile
255
+ - gemfiles/rails_7_1.gemfile
256
+ - gemfiles/rails_7_1_graphiti_rails.gemfile
254
257
  - gemfiles/rails_7_graphiti_rails.gemfile
255
258
  - graphiti.gemspec
256
259
  - lib/graphiti.rb
@@ -355,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
355
358
  - !ruby/object:Gem::Version
356
359
  version: '0'
357
360
  requirements: []
358
- rubygems_version: 3.3.7
361
+ rubygems_version: 3.5.3
359
362
  signing_key:
360
363
  specification_version: 4
361
364
  summary: Easily build jsonapi.org-compatible APIs