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

Why not to use `attr_accessor` for `batch_loader`? #88

Open feruzoripov opened 11 months ago

feruzoripov commented 11 months ago

We have this line https://github.com/exAspArk/batch-loader/blob/master/lib/batch_loader/graphql.rb#L51 and it defines attr_writer :batch_loader. Why not to use attr_accessor :batch_loader instead? Let's say we want to get a loaded item for debugging purposes or for whatever reason, but with the current solution we can't proceed with batch_loader variable or instance_variable_get(:@batch_loader) needs to be run which does not look good.

feruzoripov commented 11 months ago

It seems like the .sync method is what I am looking for. We probably need to include why and how to use this method in README because we don't have information about it.