exAspArk / batch-loader

:zap: Powerful tool for avoiding N+1 DB or HTTP queries
https://engineering.universe.com/batching-a-powerful-way-to-solve-n-1-queries-every-rubyist-should-know-24e20c6e7b94
MIT License
1.04k stars 52 forks source link

Wrong number of arguments (given 1, expected 0) #73

Closed saurabhshinde02 closed 3 years ago

saurabhshinde02 commented 3 years ago

Hi, I tried the example given here https://github.com/exAspArk/batch-loader#batch-key after updating ruby version to 3.0.0.

  id = post.association_id
  key = post.association_type

  BatchLoader.for(id).batch(key: key) do |ids, loader, args|
    model = Object.const_get(args[:key])
    model.where(id: ids).each { |record| loader.call(record.id, record) }
  end

It gives me wrong number of arguments (given 1, expected 0) error when passing arguments in batch method, Now, It is not expecting any argument. Is there any alternative way to do the same?

ruby version: 3.0.0 rails version: 6.0.3.4 graphql version: (>= 1.8)

an-lee commented 3 years ago

Same problem here. Merge this PR https://github.com/exAspArk/batch-loader/pull/71 should fix this.

I use my own fork to work around this for now.

saurabhshinde02 commented 3 years ago

Hi, any update on the issue?

adammeghji commented 3 years ago

+1 would be great to see batch-loader be compatible with ruby 3.0.0! 😍

jandudulski commented 3 years ago

@exAspArk any chances to take a look? :pray:

ThiagoAnunciacao commented 3 years ago

🙏🏼 👍🏼

exAspArk commented 3 years ago

It should be fixed by #71. Thanks, @an-lee! 🎉

I released the new 2.0.1 version. Here is the changelog. Please let me know if there are any issues 🙏