Skip to content

Instantly share code, notes, and snippets.

View egorbarakhov's full-sized avatar
:shipit:

Egor Barakhov egorbarakhov

:shipit:
  • Turkiye
View GitHub Profile
@itkrt2y
itkrt2y / association.rb
Last active September 3, 2024 11:45
Association dataloader with graphql-ruby
# official docs: https://graphql-ruby.org/dataloader/sources.html
# app/graphql/sources/association.rb
class Sources::Association < ::GraphQL::Dataloader::Source
def initialize(association_name, scope = nil)
@association_name = association_name
@scope = scope
end
def fetch(records)
@DmitryTsepelev
DmitryTsepelev / 1_graphql_ruby_n_plus_one.md
Last active January 5, 2024 15:16
N+1 in graphql-ruby

How to run examples:

  1. Run $ createdb nplusonedb to create DB
  2. Run specs $ rspec demo.rb
@rfelix
rfelix / ruby_annotations.rb
Created May 28, 2010 15:02
Ruby annotations
#
# Show how to implement Java-like method annotations in Ruby. This example shows how to create
# something more like Ruby's own private and public annotations, where each method that's declared
# afterwards has its visibility set to private/public.
#
# To make this work more like a Java annotation (works for only one method), then you just have
# to @_admin_only to nil in the "unless" condition from #method_added
#
# (source: http://www.diegocarrion.com/2010/05/27/ruby-annotations/)
#