diff --git a/Gemfile.lock b/Gemfile.lock index e895bd6..c29ddb7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,37 +1,36 @@ PATH remote: . specs: - graphql-fancy_loader (0.1.6) + graphql-fancy_loader (0.2.0) activesupport (>= 5.0, < 9.0) - graphql (>= 1.3, < 3) - graphql-batch (>= 0.4.3, < 1) + graphql (>= 1.8, < 3) GEM remote: https://rubygems.org/ specs: - actioncable (8.0.0) - actionpack (= 8.0.0) - activesupport (= 8.0.0) + actioncable (8.0.2) + actionpack (= 8.0.2) + activesupport (= 8.0.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (8.0.0) - actionpack (= 8.0.0) - activejob (= 8.0.0) - activerecord (= 8.0.0) - activestorage (= 8.0.0) - activesupport (= 8.0.0) + actionmailbox (8.0.2) + actionpack (= 8.0.2) + activejob (= 8.0.2) + activerecord (= 8.0.2) + activestorage (= 8.0.2) + activesupport (= 8.0.2) mail (>= 2.8.0) - actionmailer (8.0.0) - actionpack (= 8.0.0) - actionview (= 8.0.0) - activejob (= 8.0.0) - activesupport (= 8.0.0) + actionmailer (8.0.2) + actionpack (= 8.0.2) + actionview (= 8.0.2) + activejob (= 8.0.2) + activesupport (= 8.0.2) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.0.0) - actionview (= 8.0.0) - activesupport (= 8.0.0) + actionpack (8.0.2) + actionview (= 8.0.2) + activesupport (= 8.0.2) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -39,35 +38,35 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (8.0.0) - actionpack (= 8.0.0) - activerecord (= 8.0.0) - activestorage (= 8.0.0) - activesupport (= 8.0.0) + actiontext (8.0.2) + actionpack (= 8.0.2) + activerecord (= 8.0.2) + activestorage (= 8.0.2) + activesupport (= 8.0.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (8.0.0) - activesupport (= 8.0.0) + actionview (8.0.2) + activesupport (= 8.0.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (8.0.0) - activesupport (= 8.0.0) + activejob (8.0.2) + activesupport (= 8.0.2) globalid (>= 0.3.6) - activemodel (8.0.0) - activesupport (= 8.0.0) - activerecord (8.0.0) - activemodel (= 8.0.0) - activesupport (= 8.0.0) + activemodel (8.0.2) + activesupport (= 8.0.2) + activerecord (8.0.2) + activemodel (= 8.0.2) + activesupport (= 8.0.2) timeout (>= 0.4.0) - activestorage (8.0.0) - actionpack (= 8.0.0) - activejob (= 8.0.0) - activerecord (= 8.0.0) - activesupport (= 8.0.0) + activestorage (8.0.2) + actionpack (= 8.0.2) + activejob (= 8.0.2) + activerecord (= 8.0.2) + activesupport (= 8.0.2) marcel (~> 1.0) - activesupport (8.0.0) + activesupport (8.0.2) base64 benchmark (>= 0.3) bigdecimal @@ -80,56 +79,61 @@ GEM securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) - base64 (0.2.0) - benchmark (0.3.0) - bigdecimal (3.1.8) - bootsnap (1.18.4) + base64 (0.3.0) + benchmark (0.4.1) + bigdecimal (3.2.2) + bootsnap (1.18.6) msgpack (~> 1.2) builder (3.3.0) - byebug (11.1.3) + byebug (12.0.0) coderay (1.1.3) - concurrent-ruby (1.3.4) - connection_pool (2.4.1) + concurrent-ruby (1.3.5) + connection_pool (2.5.3) crass (1.0.6) database_cleaner (2.1.0) database_cleaner-active_record (>= 2, < 3) - database_cleaner-active_record (2.2.0) + database_cleaner-active_record (2.2.1) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.4.0) - diff-lcs (1.5.1) + date (3.4.1) + diff-lcs (1.6.2) docile (1.4.1) - drb (2.2.1) - erubi (1.13.0) - factory_bot (6.5.0) - activesupport (>= 5.0.0) - factory_bot_rails (6.4.4) + drb (2.2.3) + erb (5.0.1) + erubi (1.13.1) + factory_bot (6.5.4) + activesupport (>= 6.1.0) + factory_bot_rails (6.5.0) factory_bot (~> 6.5) - railties (>= 5.0.0) - ffi (1.17.0) - ffi (1.17.0-x86_64-darwin) - ffi (1.17.0-x86_64-linux-gnu) - fiber-storage (1.0.0) + railties (>= 6.1.0) + ffi (1.17.2-aarch64-linux-gnu) + ffi (1.17.2-aarch64-linux-musl) + ffi (1.17.2-arm-linux-gnu) + ffi (1.17.2-arm-linux-musl) + ffi (1.17.2-arm64-darwin) + ffi (1.17.2-x86_64-darwin) + ffi (1.17.2-x86_64-linux-gnu) + ffi (1.17.2-x86_64-linux-musl) + fiber-storage (1.0.1) globalid (1.2.1) activesupport (>= 6.1) - graphql (2.4.2) + graphql (2.5.11) base64 fiber-storage - graphql-batch (0.6.0) - graphql (>= 1.12.18, < 3) - promise.rb (~> 0.7.2) - i18n (1.14.6) + logger + i18n (1.14.7) concurrent-ruby (~> 1.0) - io-console (0.7.2) - irb (1.14.1) + io-console (0.8.0) + irb (1.15.2) + pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.1) - loofah (2.23.1) + logger (1.7.0) + loofah (2.24.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -138,144 +142,163 @@ GEM net-pop net-smtp marcel (1.0.4) - method_source (1.0.0) + method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.7) - minitest (5.25.1) - msgpack (1.7.3) - net-imap (0.5.0) + minitest (5.25.5) + msgpack (1.8.0) + net-imap (0.5.9) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.5.0) + net-smtp (0.5.1) net-protocol nio4r (2.7.4) - nokogiri (1.16.7) - mini_portile2 (~> 2.8.2) + nokogiri (1.18.8-aarch64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.8-aarch64-linux-musl) + racc (~> 1.4) + nokogiri (1.18.8-arm-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.8-arm-linux-musl) racc (~> 1.4) - nokogiri (1.16.7-x86_64-darwin) + nokogiri (1.18.8-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.7-x86_64-linux) + nokogiri (1.18.8-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-linux-musl) racc (~> 1.4) pg (1.5.9) - promise.rb (0.7.4) - pry (0.14.1) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) + pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.10.1) - byebug (~> 11.0) - pry (>= 0.13, < 0.15) - psych (5.2.0) + pry-byebug (3.11.0) + byebug (~> 12.0) + pry (>= 0.13, < 0.16) + psych (5.2.6) + date stringio racc (1.8.1) - rack (3.1.8) - rack-session (2.0.0) + rack (3.1.16) + rack-session (2.1.1) + base64 (>= 0.1.0) rack (>= 3.0.0) - rack-test (2.1.0) + rack-test (2.2.0) rack (>= 1.3) - rackup (2.2.0) + rackup (2.2.1) rack (>= 3) - rails (8.0.0) - actioncable (= 8.0.0) - actionmailbox (= 8.0.0) - actionmailer (= 8.0.0) - actionpack (= 8.0.0) - actiontext (= 8.0.0) - actionview (= 8.0.0) - activejob (= 8.0.0) - activemodel (= 8.0.0) - activerecord (= 8.0.0) - activestorage (= 8.0.0) - activesupport (= 8.0.0) + rails (8.0.2) + actioncable (= 8.0.2) + actionmailbox (= 8.0.2) + actionmailer (= 8.0.2) + actionpack (= 8.0.2) + actiontext (= 8.0.2) + actionview (= 8.0.2) + activejob (= 8.0.2) + activemodel (= 8.0.2) + activerecord (= 8.0.2) + activestorage (= 8.0.2) + activesupport (= 8.0.2) bundler (>= 1.15.0) - railties (= 8.0.0) - rails-dom-testing (2.2.0) + railties (= 8.0.2) + rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.2) loofah (~> 2.21) - nokogiri (~> 1.14) - railties (8.0.0) - actionpack (= 8.0.0) - activesupport (= 8.0.0) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (8.0.2) + actionpack (= 8.0.2) + activesupport (= 8.0.2) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) - rake (13.2.1) + rake (13.3.0) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rdoc (6.7.0) + rdoc (6.14.2) + erb psych (>= 4.0.0) - reline (0.5.10) + reline (0.6.1) io-console (~> 0.5) - rspec (3.13.0) + rspec (3.13.1) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.2) + rspec-core (3.13.5) rspec-support (~> 3.13.0) - rspec-expectations (3.13.3) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.2) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (7.0.1) - actionpack (>= 7.0) - activesupport (>= 7.0) - railties (>= 7.0) + rspec-rails (8.0.1) + actionpack (>= 7.2) + activesupport (>= 7.2) + railties (>= 7.2) rspec-core (~> 3.13) rspec-expectations (~> 3.13) rspec-mocks (~> 3.13) rspec-support (~> 3.13) - rspec-support (3.13.1) - securerandom (0.3.1) + rspec-support (3.13.4) + securerandom (0.4.1) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) - stringio (3.1.2) + stringio (3.1.7) thor (1.3.2) - timecop (0.9.5) - timeout (0.4.2) + timecop (0.9.10) + timeout (0.4.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uri (1.0.0) - useragent (0.16.10) - websocket-driver (0.7.6) + uri (1.0.3) + useragent (0.16.11) + websocket-driver (0.8.0) + base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.7.1) + zeitwerk (2.7.3) PLATFORMS - ruby - x86_64-darwin-19 - x86_64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES bootsnap (~> 1.18) - bundler (~> 2.0) + bundler (>= 2.0) database_cleaner (~> 2.1) factory_bot_rails (~> 6.4) graphql-fancy_loader! - listen (~> 3.9) + listen (>= 3.9) pg (~> 1.5) - pry-byebug (~> 3.10) - rails (= 8.0) + pry-byebug (~> 3.11) + rails (>= 8.0) rake (>= 13.2) rspec (~> 3.13) - rspec-rails (~> 7.0) + rspec-rails (>= 7.0) simplecov (~> 0.22) timecop (~> 0.9) BUNDLED WITH - 2.3.13 + 2.6.7 diff --git a/README.md b/README.md index 9b6b4fd..edf8849 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,21 @@ # GraphQL::FancyLoader -FancyLoader (built on top of the [graphql-batch][graphql-batch] gem) efficiently batches queries +> [!NOTE] +> This is a fork of the original [hummingbird-me/graphql-fancy-loader](https://github.com/hummingbird-me/graphql-fancy-loader) that has been migrated to use graphql-ruby's built-in dataloader instead of graphql-batch. If you need the original graphql-batch implementation, please use the upstream repository. + +FancyLoader (built on top of graphql-ruby's dataloader) efficiently batches queries using postgres window functions to allow advanced features such as orders, limits, pagination, and authorization scoping. Built on top of Arel, FancyLoader is highly extensible and capable of handling complex sorts (including sorting based on a join) with minimal effort and high performance. We use FancyLoader in production to power large swaths of the Kitsu GraphQL API. -[graphql-batch]: https://github.com/Shopify/graphql-batch - ## Installation Add this line to your application's Gemfile: ```ruby -gem 'graphql-fancy_loader' +gem 'graphql-fancy_loader', github: 'metafy-gg/graphql-fancy-loader' ``` And then execute: @@ -23,12 +24,6 @@ And then execute: $ bundle install ``` -Or install it yourself as: - -``` -$ gem install graphql-fancy_loader -``` - ## Basic Usage ### Defining a Loader @@ -54,7 +49,7 @@ end This loader class provides two primary methods: `.sort_argument` and `.connection_for`. `.sort_argument` gives you a convenient auto-generated sort field which allows for multiple sorts. -`.connection_for` is a wrapper around graphql-batch which returns a connection. Pagination will be +`.connection_for` is a wrapper around graphql-ruby's dataloader which returns a connection. Pagination will be automatically applied to this connection by the graphql gem, so you just need to pass in your other options: @@ -77,8 +72,7 @@ end ### Testing the Loader -Testing a FancyLoader is pretty much exactly the same as testing any other graphql-batch Loader -class: +Testing a FancyLoader works with graphql-ruby's dataloader pattern: ```ruby RSpec.describe Loaders::PostsLoader do @@ -90,13 +84,11 @@ RSpec.describe Loaders::PostsLoader do let(:sort) { [{ on: :created_at, direction: :desc }] } it 'loads all the posts for a user' do - posts = GraphQL::Batch.batch do - described_class.connection_for({ - find_by: :user_id, - sort: sort, - context: context - }, user.id).nodes - end + posts = described_class.connection_for({ + find_by: :user_id, + sort: sort, + context: context + }, user.id).nodes expect(posts.count).to eq(user.posts.count) end @@ -208,7 +200,7 @@ will create a git tag for the version, push git commits and tags, and push the ` ## Contributing Bug reports and pull requests are welcome on GitHub at -https://github.com/hummingbird-me/graphql-fancy-loader. +https://github.com/metafy-gg/graphql-fancy-loader. ## License diff --git a/graphql-fancy_loader.gemspec b/graphql-fancy_loader.gemspec index 09477cf..3211f94 100644 --- a/graphql-fancy_loader.gemspec +++ b/graphql-fancy_loader.gemspec @@ -6,18 +6,18 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'graphql/fancy_loader/version' Gem::Specification.new do |spec| - spec.name = 'graphql-fancy_loader' - spec.version = GraphQL::FancyLoader::VERSION - spec.authors = ['Toyhammered', 'Emma Lejeck'] - spec.email = ['nuck@kitsu.io'] + spec.name = 'graphql-fancy_loader' + spec.version = GraphQL::FancyLoader::VERSION + spec.authors = ['Toyhammered', 'Emma Lejeck', 'Thomas McNiven'] + spec.email = ['nuck@kitsu.io', 'tom@metafy.gg'] - spec.summary = 'FancyLoader efficiently batches queries using postgres window functions to allow advanced features such as orders, limits, pagination, and authorization scoping.' - spec.description = 'FancyLoader (built on top of the graphql-batch gem) efficiently batches queries using postgres window functions to allow advanced features such as orders, limits, pagination, and authorization scoping. Built on top of Arel, FancyLoader is highly extensible and capable of handling complex sorts (including sorting based on a join) with minimal effort and high performance.' - spec.homepage = 'https://github.com/hummingbird-me/graphql-fancy-loader' - spec.license = 'Apache-2.0' + spec.summary = 'FancyLoader efficiently batches queries using postgres window functions to allow advanced features such as orders, limits, pagination, and authorization scoping.' + spec.description = "FancyLoader (built on top of graphql-ruby's dataloader) efficiently batches queries using postgres window functions to allow advanced features such as orders, limits, pagination, and authorization scoping. Built on top of Arel, FancyLoader is highly extensible and capable of handling complex sorts (including sorting based on a join) with minimal effort and high performance." + spec.homepage = 'https://github.com/metafy-gg/graphql-fancy-loader' + spec.license = 'Apache-2.0' spec.metadata['homepage_uri'] = spec.homepage - spec.metadata['source_code_uri'] = 'https://github.com/hummingbird-me/graphql-fancy-loader' + spec.metadata['source_code_uri'] = 'https://github.com/metafy-gg/graphql-fancy-loader' spec.metadata['allowed_push_host'] = 'https://rubygems.org' # Specify which files should be added to the gem when it is released. @@ -25,16 +25,15 @@ Gem::Specification.new do |spec| spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } end - spec.bindir = 'exe' - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.bindir = 'exe' + spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] spec.add_runtime_dependency 'activesupport', '>= 5.0', '< 9.0' - spec.add_runtime_dependency 'graphql', '>= 1.3', '< 3' - spec.add_runtime_dependency 'graphql-batch', '>= 0.4.3', '< 1' + spec.add_runtime_dependency 'graphql', '>= 1.8', '< 3' - spec.add_development_dependency 'bundler', '~> 2.0' - spec.add_development_dependency 'pry-byebug', '~> 3.10' + spec.add_development_dependency 'bundler', '>= 2.0' + spec.add_development_dependency 'pry-byebug', '~> 3.11' spec.add_development_dependency 'rake', '>= 13.2' spec.add_development_dependency 'rspec', '~> 3.13' spec.add_development_dependency 'simplecov', '~> 0.22' @@ -43,8 +42,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bootsnap', '~> 1.18' spec.add_development_dependency 'database_cleaner', '~> 2.1' spec.add_development_dependency 'factory_bot_rails', '~> 6.4' - spec.add_development_dependency 'listen', '~> 3.9' + spec.add_development_dependency 'listen', '>= 3.9' spec.add_development_dependency 'pg', '~> 1.5' - spec.add_development_dependency 'rails', '8.0' - spec.add_development_dependency 'rspec-rails', '~> 7.0' + spec.add_development_dependency 'rails', '>= 8.0' + spec.add_development_dependency 'rspec-rails', '>= 7.0' end diff --git a/lib/graphql/fancy_connection.rb b/lib/graphql/fancy_connection.rb index fe2017f..0aa1b91 100644 --- a/lib/graphql/fancy_connection.rb +++ b/lib/graphql/fancy_connection.rb @@ -9,64 +9,61 @@ def initialize(loader, args, key, **super_args) super(nil, **super_args) end - # @return [Promise>] + # @return [Array] def nodes + resolved_nodes = base_nodes if @then - base_nodes.then(@then) + @then.call(resolved_nodes) else - base_nodes + resolved_nodes end end def edges - @edges ||= nodes.then do |nodes| - nodes.map { |n| @edge_class.new(n, self) } + @edges ||= begin + resolved_nodes = nodes + resolved_nodes.map { |n| @edge_class.new(n, self) } end end - # @return [Promise] + # @return [Integer] def total_count - base_nodes.then do |results| - if results.first - results.first.attributes['total_count'] - else - 0 - end + results = base_nodes + if results.first + results.first.attributes['total_count'] + else + 0 end end - # @return [Promise] + # @return [Boolean] def has_next_page # rubocop:disable Naming/PredicateName - base_nodes.then do |results| - if results.last - results.last.attributes['row_number'] < results.last.attributes['total_count'] - else - false - end + results = base_nodes + if results.last + results.last.attributes['row_number'] < results.last.attributes['total_count'] + else + false end end - # @return [Promise] + # @return [Boolean] def has_previous_page # rubocop:disable Naming/PredicateName - base_nodes.then do |results| - if results.first - results.first.attributes['row_number'] > 1 - else - false - end + results = base_nodes + if results.first + results.first.attributes['row_number'] > 1 + else + false end end def start_cursor - base_nodes.then do |results| - cursor_for(results.first) - end + results = base_nodes + cursor_for(results.first) end def end_cursor - base_nodes.then do |results| - cursor_for(results.last) - end + results = base_nodes + cursor_for(results.last) end def cursor_for(item) @@ -81,7 +78,7 @@ def then(&block) private def base_nodes - @base_nodes ||= @loader.for(**loader_args).load(@key) + @base_nodes ||= context.dataloader.with(@loader, **loader_args).load(@key) end def after_offset diff --git a/lib/graphql/fancy_loader.rb b/lib/graphql/fancy_loader.rb index ea1a680..2028a48 100644 --- a/lib/graphql/fancy_loader.rb +++ b/lib/graphql/fancy_loader.rb @@ -5,18 +5,19 @@ # To use +FancyLoader+, you'll make a subclass to define your sorts and source model. You can then # create a field which uses your subclass to load data. -require 'graphql/batch' +require 'graphql' require 'active_support' require 'active_support/concern' require 'active_support/configurable' require 'active_support/core_ext/class/attribute' +require 'graphql/fancy_loader/version' require 'graphql/fancy_loader/dsl' module GraphQL - class FancyLoader < GraphQL::Batch::Loader + class FancyLoader < GraphQL::Dataloader::Source include ActiveSupport::Configurable - include GraphQL::FancyLoader::DSL + include DSL config_accessor :middleware @@ -61,8 +62,8 @@ def initialize(find_by:, sort:, before: nil, after: 0, first: nil, last: nil, wh end # Perform the loading. Uses {GraphQL::FancyLoader::QueryGenerator} to build a query, then groups - # the results by the @find_by column, then fulfills all the Promises. - def perform(keys) + # the results by the @find_by column, then returns the grouped results. + def fetch(keys) query = QueryGenerator.new( model: model, find_by: @find_by, @@ -78,9 +79,7 @@ def perform(keys) ).query results = query.to_a.group_by { |rec| rec[@find_by] } - keys.each do |key| - fulfill(key, results[key] || []) - end + keys.map { |key| results[key] || [] } end private @@ -100,6 +99,5 @@ def sort require 'graphql/fancy_loader/query_generator' require 'graphql/fancy_loader/rank_query_generator' require 'graphql/fancy_loader/type_generator' -require 'graphql/fancy_loader/version' # Middleware require 'graphql/fancy_loader/pundit_middleware' diff --git a/lib/graphql/fancy_loader/dsl.rb b/lib/graphql/fancy_loader/dsl.rb index 059d864..747ede2 100644 --- a/lib/graphql/fancy_loader/dsl.rb +++ b/lib/graphql/fancy_loader/dsl.rb @@ -1,5 +1,5 @@ module GraphQL - class FancyLoader < GraphQL::Batch::Loader + class FancyLoader module DSL extend ActiveSupport::Concern diff --git a/lib/graphql/fancy_loader/version.rb b/lib/graphql/fancy_loader/version.rb index 6f61414..80c7918 100644 --- a/lib/graphql/fancy_loader/version.rb +++ b/lib/graphql/fancy_loader/version.rb @@ -1,11 +1,10 @@ module GraphQL - # HACK: This allows us to import the version number in the gemspec class FancyLoader < (begin - require 'graphql/batch' - GraphQL::Batch::Loader + require 'graphql/dataloader' + GraphQL::Dataloader::Source rescue LoadError BasicObject end) - VERSION = '0.1.6'.freeze # .3 + VERSION = '0.2.0'.freeze end end diff --git a/spec/dummy/config/database.yml b/spec/dummy/config/database.yml index 2bce268..7037242 100644 --- a/spec/dummy/config/database.yml +++ b/spec/dummy/config/database.yml @@ -1,6 +1,8 @@ default: &default adapter: postgresql encoding: unicode + host: localhost + port: 5432 prepared_statements: false advisory_locks: false <% if ENV.include?('DATABASE_URL') %> diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index e6e6919..0a291b7 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -10,24 +10,23 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_10_17_215654) do - +ActiveRecord::Schema[8.0].define(version: 2021_10_17_215654) do # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" + enable_extension "pg_catalog.plpgsql" create_table "posts", force: :cascade do |t| t.bigint "user_id" t.string "title", null: false t.string "description" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.index ["user_id"], name: "index_posts_on_user_id" end create_table "users", force: :cascade do |t| t.string "email", null: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_foreign_key "posts", "users"