From 34e9f8e828db5fda97247dc4a2b177a2bea8f181 Mon Sep 17 00:00:00 2001 From: Andrei Mochalov Date: Mon, 30 Oct 2023 21:02:53 +0300 Subject: [PATCH 1/8] Use an options hash for log subscriber instead of positional arguments --- lib/graphiti.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphiti.rb b/lib/graphiti.rb index 16b2141a..61be706f 100644 --- a/lib/graphiti.rb +++ b/lib/graphiti.rb @@ -83,7 +83,7 @@ def self.logger=(val) end def self.log(msg, color = :white, bold = false) - colored = ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold) + colored = ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold: bold) logger.debug(colored) end From df2f5666a9baf3f831f49b04e1d194d3b1d62165 Mon Sep 17 00:00:00 2001 From: Andrei Mochalov Date: Tue, 31 Oct 2023 12:36:33 +0300 Subject: [PATCH 2/8] Make changes backward compatible with Rails pre-7.1 --- lib/graphiti.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/graphiti.rb b/lib/graphiti.rb index 61be706f..5a9da909 100644 --- a/lib/graphiti.rb +++ b/lib/graphiti.rb @@ -83,7 +83,12 @@ def self.logger=(val) end def self.log(msg, color = :white, bold = false) - colored = ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold: bold) + if ::Rails::VERSION::MAJOR >= 7 && ::Rails::VERSION::MINOR >= 1 + colored = ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold: bold) + else + colored = ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold) + end + logger.debug(colored) end From 621233584359ca44ee631e6265d238d7214cda54 Mon Sep 17 00:00:00 2001 From: Andrei Mochalov Date: Tue, 31 Oct 2023 12:49:40 +0300 Subject: [PATCH 3/8] Check ActiveSupport version properly --- lib/graphiti.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphiti.rb b/lib/graphiti.rb index 5a9da909..8a38263e 100644 --- a/lib/graphiti.rb +++ b/lib/graphiti.rb @@ -83,7 +83,7 @@ def self.logger=(val) end def self.log(msg, color = :white, bold = false) - if ::Rails::VERSION::MAJOR >= 7 && ::Rails::VERSION::MINOR >= 1 + if ::ActiveSupport.version >= Gem::Version.new("7.1") colored = ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold: bold) else colored = ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold) From 1f112b013bafc3f7e6181bcdbdafc87a7dcf9037 Mon Sep 17 00:00:00 2001 From: Martin Svoboda Date: Tue, 30 Jan 2024 21:35:19 +0800 Subject: [PATCH 4/8] =?UTF-8?q?460=20=F0=9F=90=9B=20Fix=20bug:=20graphiti?= =?UTF-8?q?=20not=20compatible=20with=20Rails=207.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/graphiti-api/graphiti/issues/460 --- lib/graphiti/util/serializer_relationships.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphiti/util/serializer_relationships.rb b/lib/graphiti/util/serializer_relationships.rb index 5ab52b2e..70bf886d 100644 --- a/lib/graphiti/util/serializer_relationships.rb +++ b/lib/graphiti/util/serializer_relationships.rb @@ -118,7 +118,7 @@ def validate_link_for_sideload!(sideload) cache_key = :"#{@sideload.object_id}-#{action}" return if self.class.validated_link_cache.include?(cache_key) prc = Graphiti.config.context_for_endpoint - unless prc.call(sideload.resource.endpoint[:full_path], action) + unless prc.call(sideload.resource.endpoint[:full_path].to_s, action) raise Errors::InvalidLink.new(@resource_class, sideload, action) end self.class.validated_link_cache << cache_key From d2c34866ad73b1c5ea1041d7cc0610120762592f Mon Sep 17 00:00:00 2001 From: Josh Bebbington Date: Thu, 15 Feb 2024 12:37:20 +0000 Subject: [PATCH 5/8] Show includes for sideloads in debugger --- lib/graphiti/debugger.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/graphiti/debugger.rb b/lib/graphiti/debugger.rb index 070f4fac..b5fd3991 100644 --- a/lib/graphiti/debugger.rb +++ b/lib/graphiti/debugger.rb @@ -140,7 +140,6 @@ def scrub_params(params) params ||= {} params = params.to_unsafe_h if params.respond_to?(:to_unsafe_h) params.reject! { |k, v| [:controller, :action, :format, :debug].include?(k.to_sym) } - params.reject! { |k, v| k.to_sym == :include } params.deep_symbolize_keys end From 0cf85babd6492c8c929f06ecc91256064ea7f871 Mon Sep 17 00:00:00 2001 From: Jeff Keen Date: Tue, 27 Feb 2024 07:49:29 -0600 Subject: [PATCH 6/8] Linter fixes --- lib/graphiti.rb | 6 +++--- lib/graphiti/resource_proxy.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/graphiti.rb b/lib/graphiti.rb index 8a38263e..89636b1e 100644 --- a/lib/graphiti.rb +++ b/lib/graphiti.rb @@ -83,10 +83,10 @@ def self.logger=(val) end def self.log(msg, color = :white, bold = false) - if ::ActiveSupport.version >= Gem::Version.new("7.1") - colored = ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold: bold) + colored = if ::ActiveSupport.version >= Gem::Version.new("7.1") + ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold: bold) else - colored = ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold) + ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold) end logger.debug(colored) diff --git a/lib/graphiti/resource_proxy.rb b/lib/graphiti/resource_proxy.rb index b68482c5..f699fa79 100644 --- a/lib/graphiti/resource_proxy.rb +++ b/lib/graphiti/resource_proxy.rb @@ -158,7 +158,7 @@ def update save(action: :update) end - alias update_attributes update + alias_method update_attributes update def include_hash @include_hash ||= begin From f374bbcbd0784c7b3d8edc9095abdb07015a9cfe Mon Sep 17 00:00:00 2001 From: Jeff Keen Date: Tue, 27 Feb 2024 07:58:48 -0600 Subject: [PATCH 7/8] Ignore lint warning for using the incorrect method --- lib/graphiti/resource_proxy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphiti/resource_proxy.rb b/lib/graphiti/resource_proxy.rb index f699fa79..d03105be 100644 --- a/lib/graphiti/resource_proxy.rb +++ b/lib/graphiti/resource_proxy.rb @@ -158,7 +158,7 @@ def update save(action: :update) end - alias_method update_attributes update + alias update_attributes update # standard:disable Style/Alias def include_hash @include_hash ||= begin From 61ea2c3179c15b433ff63a1cd757d77b598b7323 Mon Sep 17 00:00:00 2001 From: Jeff Keen Date: Tue, 27 Feb 2024 11:15:27 -0600 Subject: [PATCH 8/8] Update appraisals to include Rails 7.1 and Ruby 3.2 + 3.3 (#463) - Removed Ruby 2.6 from the official support test matrix (EOL'd in April 2022). - Added Rails 7.1, Ruby 3.2, Ruby 3.3 to test matrix - Fixed ruby-head configuration --- .github/workflows/ci.yml | 23 +++++++++++++++-------- Appraisals | 15 +++++++++++++++ Gemfile | 1 + gemfiles/rails_7_1.gemfile | 18 ++++++++++++++++++ gemfiles/rails_7_1_graphiti_rails.gemfile | 19 +++++++++++++++++++ lib/graphiti.rb | 1 + 6 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 gemfiles/rails_7_1.gemfile create mode 100644 gemfiles/rails_7_1_graphiti_rails.gemfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e87a704c..af4f0e60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,10 +28,11 @@ jobs: fail-fast: false matrix: ruby: - - "2.6" - "2.7" - "3.0" - "3.1" + - "3.2" + - "3.3" gemfile: - Gemfile - gemfiles/rails_5_2.gemfile @@ -40,12 +41,13 @@ jobs: - gemfiles/rails_5_2_graphiti_rails.gemfile - gemfiles/rails_6_graphiti_rails.gemfile - gemfiles/rails_7_graphiti_rails.gemfile + - gemfiles/rails_7_1_graphiti_rails.gemfile appraisal: - true - false include: - ruby: ruby-head - gemfile: Gemfile + gemfile: gemfiles/rails_7_1.gemfile appraisal: true - ruby: ruby-head gemfile: Gemfile @@ -66,7 +68,9 @@ jobs: appraisal: false - gemfile: gemfiles/rails_7_graphiti_rails.gemfile appraisal: false - # Rails 5 can't run on Ruby 3 + - gemfile: gemfiles/rails_7_1_graphiti_rails.gemfile + appraisal: false + # Rails 5 can't run on Ruby 3 - gemfile: gemfiles/rails_5_2.gemfile ruby: 3.0 - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile @@ -75,11 +79,14 @@ jobs: ruby: 3.1 - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile ruby: 3.1 - # Raise 7 can't run on 2.6 - - gemfile: gemfiles/rails_7.gemfile - ruby: 2.6 - - gemfile: gemfiles/rails_7_graphiti_rails.gemfile - ruby: 2.6 + - gemfile: gemfiles/rails_5_2.gemfile + ruby: 3.2 + - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile + ruby: 3.2 + - gemfile: gemfiles/rails_5_2.gemfile + ruby: 3.3 + - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile + ruby: 3.3 continue-on-error: ${{ matrix.ruby == 'ruby-head' }} env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }} diff --git a/Appraisals b/Appraisals index 34484a86..72b86b0d 100644 --- a/Appraisals +++ b/Appraisals @@ -42,3 +42,18 @@ appraise "rails-7-graphiti-rails" do gem "database_cleaner" gem "graphiti-rails", "~> 0.4.0" end + +appraise "rails-7-1" do + gem "rails", "~> 7.1" + gem "rspec-rails" + gem "sqlite3", "~> 1.4.0" + gem "database_cleaner" +end + +appraise "rails-7-1-graphiti-rails" do + gem "rails", "~> 7.1" + gem "rspec-rails" + gem "sqlite3", "~> 1.4.0" + gem "database_cleaner" + gem "graphiti-rails", "~> 0.4.0" +end diff --git a/Gemfile b/Gemfile index 3317b886..6d80a9aa 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,7 @@ source "https://rubygems.org" gemspec group :test do + gem "database_cleaner" gem "pry" gem "pry-byebug", platform: [:mri] gem "appraisal" diff --git a/gemfiles/rails_7_1.gemfile b/gemfiles/rails_7_1.gemfile new file mode 100644 index 00000000..7f61a90e --- /dev/null +++ b/gemfiles/rails_7_1.gemfile @@ -0,0 +1,18 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 7.1" +gem "rspec-rails" +gem "sqlite3", "~> 1.4.0" +gem "database_cleaner" + +group :test do + gem "pry" + gem "pry-byebug", platform: [:mri] + gem "appraisal" + gem "guard" + gem "guard-rspec" +end + +gemspec path: "../" diff --git a/gemfiles/rails_7_1_graphiti_rails.gemfile b/gemfiles/rails_7_1_graphiti_rails.gemfile new file mode 100644 index 00000000..97c0a5e5 --- /dev/null +++ b/gemfiles/rails_7_1_graphiti_rails.gemfile @@ -0,0 +1,19 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 7.1" +gem "rspec-rails" +gem "sqlite3", "~> 1.4.0" +gem "database_cleaner" +gem "graphiti-rails", "~> 0.4.0" + +group :test do + gem "pry" + gem "pry-byebug", platform: [:mri] + gem "appraisal" + gem "guard" + gem "guard-rspec" +end + +gemspec path: "../" diff --git a/lib/graphiti.rb b/lib/graphiti.rb index 89636b1e..0b545924 100644 --- a/lib/graphiti.rb +++ b/lib/graphiti.rb @@ -1,5 +1,6 @@ require "json" require "forwardable" +require "uri" require "active_support/core_ext/string" require "active_support/core_ext/enumerable" require "active_support/core_ext/class/attribute"