Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rails 6 support #27

Open
modosc opened this issue Aug 12, 2019 · 6 comments · May be fixed by #32
Open

rails 6 support #27

modosc opened this issue Aug 12, 2019 · 6 comments · May be fixed by #32

Comments

@modosc
Copy link

modosc commented Aug 12, 2019

right now rails 6 is excluded here, are there plans to test compatibility out?

@ngouy
Copy link

ngouy commented Sep 26, 2019

I tried to do so (forked it and update dependencies). Sadly because of rails/rails#36638 it's not possible for now

@ngouy
Copy link

ngouy commented Sep 27, 2019

please note the following working with an updated version of this gem with right dependencies.

While preload is still working, The preload_scope is not working anymore.

for now, I figured it out with :

# frozen_string_literal: true

module Extensions
  class OrderedExtension < BaseExtension
    DEFAULT_SCOPE = :ordered

    def after_resolve(value:, **_)
      scope = options.fetch(:scope, DEFAULT_SCOPE)
      value&.send(scope)
    end
  end
end
class myType < BaseType
 # ...
 field :has_many_stuffs, [StuffType], preload: [:whatever], extensions: [Extensions::OrderedExtension]
 field :has_many_other_stuffs, [StuffType], preload: [:whatever] do
    extension(Extensions::RoundedExtension, scope: :active)
 end

This requires some modifications into the extension if you want to have many scopes and call extension(Extensions::RoundedExtension, scope: [:ordered, :active])

@justisb
Copy link

justisb commented Nov 22, 2019

FYI @ngouy in your fork the ActiveRecord dependency change is too restrictive- currently <= 6 locks Rails at exactly 6.0.0, so cannot be updated to 6.0.1.

I removed the upper bound here which allows updating Rails minor versions again: https://github.com/Popmenu/graphql-preload/commit/5499986aad1cf07d9db897dcdb5846068bd0cd43

@ngouy
Copy link

ngouy commented Dec 3, 2019

nice catch. Fixed

@Envek
Copy link

Envek commented Dec 19, 2019

Here is workaround for changed ActiveRecord's preloading by my colleagues:
https://gist.github.com/ssnickolay/f171ae9b4e71fd36686989ef7063bc89

Here I adopted it to my fork: Envek@e868b8d (@ngouy, feel free to cherry-pick it to yours).

I tested it with my micro test suite from #14 and in my project's branch for Rails 6 upgrade and it works.

Envek added a commit to Envek/graphql-preload that referenced this issue Mar 26, 2020
@Envek Envek linked a pull request Mar 26, 2020 that will close this issue
@Envek
Copy link

Envek commented Aug 17, 2020

Preloading seems to be fixed in latest Rails 6 (will be released in 6.0.4) and master: rails/rails#40056

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants