Skip to content

Commit d43f124

Browse files
committed
init
0 parents  commit d43f124

37 files changed

+766
-0
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/spec/reports/
8+
/tmp/
9+
10+
# rspec failure tracking
11+
.rspec_status
12+
13+
spec/internal/db/database.sqlite3

.rspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--format documentation
2+
--color
3+
--require spec_helper

.rubocop.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require:
2+
- rubocop-performance
3+
- rubocop-rspec
4+
5+
AllCops:
6+
Exclude:
7+
- bin/*
8+
9+
Metrics/BlockLength:
10+
Exclude:
11+
- spec/**/*

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
language: ruby
3+
cache: bundler
4+
rvm:
5+
- 2.7.1
6+
before_install: gem install bundler -v 2.1.4

Gemfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
4+
5+
# Specify your gem's dependencies in graphql-eager-loader.gemspec
6+
gemspec
7+
8+
gem 'graphql'
9+
10+
group :test, :development do
11+
gem 'combustion'
12+
gem 'rails'
13+
gem 'rake'
14+
gem 'rubocop'
15+
gem 'rubocop-performance'
16+
gem 'rubocop-rspec'
17+
end
18+
19+
group :test do
20+
gem 'rspec'
21+
gem 'rspec-rails'
22+
gem 'sqlite3'
23+
end

Gemfile.lock

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
PATH
2+
remote: .
3+
specs:
4+
graphql-eager_loader (0.1.0)
5+
6+
GEM
7+
remote: https://rubygems.org/
8+
specs:
9+
actioncable (6.0.3.2)
10+
actionpack (= 6.0.3.2)
11+
nio4r (~> 2.0)
12+
websocket-driver (>= 0.6.1)
13+
actionmailbox (6.0.3.2)
14+
actionpack (= 6.0.3.2)
15+
activejob (= 6.0.3.2)
16+
activerecord (= 6.0.3.2)
17+
activestorage (= 6.0.3.2)
18+
activesupport (= 6.0.3.2)
19+
mail (>= 2.7.1)
20+
actionmailer (6.0.3.2)
21+
actionpack (= 6.0.3.2)
22+
actionview (= 6.0.3.2)
23+
activejob (= 6.0.3.2)
24+
mail (~> 2.5, >= 2.5.4)
25+
rails-dom-testing (~> 2.0)
26+
actionpack (6.0.3.2)
27+
actionview (= 6.0.3.2)
28+
activesupport (= 6.0.3.2)
29+
rack (~> 2.0, >= 2.0.8)
30+
rack-test (>= 0.6.3)
31+
rails-dom-testing (~> 2.0)
32+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
33+
actiontext (6.0.3.2)
34+
actionpack (= 6.0.3.2)
35+
activerecord (= 6.0.3.2)
36+
activestorage (= 6.0.3.2)
37+
activesupport (= 6.0.3.2)
38+
nokogiri (>= 1.8.5)
39+
actionview (6.0.3.2)
40+
activesupport (= 6.0.3.2)
41+
builder (~> 3.1)
42+
erubi (~> 1.4)
43+
rails-dom-testing (~> 2.0)
44+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
45+
activejob (6.0.3.2)
46+
activesupport (= 6.0.3.2)
47+
globalid (>= 0.3.6)
48+
activemodel (6.0.3.2)
49+
activesupport (= 6.0.3.2)
50+
activerecord (6.0.3.2)
51+
activemodel (= 6.0.3.2)
52+
activesupport (= 6.0.3.2)
53+
activestorage (6.0.3.2)
54+
actionpack (= 6.0.3.2)
55+
activejob (= 6.0.3.2)
56+
activerecord (= 6.0.3.2)
57+
marcel (~> 0.3.1)
58+
activesupport (6.0.3.2)
59+
concurrent-ruby (~> 1.0, >= 1.0.2)
60+
i18n (>= 0.7, < 2)
61+
minitest (~> 5.1)
62+
tzinfo (~> 1.1)
63+
zeitwerk (~> 2.2, >= 2.2.2)
64+
ast (2.4.1)
65+
builder (3.2.4)
66+
combustion (1.3.0)
67+
activesupport (>= 3.0.0)
68+
railties (>= 3.0.0)
69+
thor (>= 0.14.6)
70+
concurrent-ruby (1.1.6)
71+
crass (1.0.6)
72+
diff-lcs (1.4.4)
73+
erubi (1.9.0)
74+
globalid (0.4.2)
75+
activesupport (>= 4.2.0)
76+
graphql (1.11.1)
77+
i18n (1.8.5)
78+
concurrent-ruby (~> 1.0)
79+
loofah (2.6.0)
80+
crass (~> 1.0.2)
81+
nokogiri (>= 1.5.9)
82+
mail (2.7.1)
83+
mini_mime (>= 0.1.1)
84+
marcel (0.3.3)
85+
mimemagic (~> 0.3.2)
86+
method_source (1.0.0)
87+
mimemagic (0.3.5)
88+
mini_mime (1.0.2)
89+
mini_portile2 (2.4.0)
90+
minitest (5.14.1)
91+
nio4r (2.5.2)
92+
nokogiri (1.10.10)
93+
mini_portile2 (~> 2.4.0)
94+
parallel (1.19.2)
95+
parser (2.7.1.4)
96+
ast (~> 2.4.1)
97+
rack (2.2.3)
98+
rack-test (1.1.0)
99+
rack (>= 1.0, < 3)
100+
rails (6.0.3.2)
101+
actioncable (= 6.0.3.2)
102+
actionmailbox (= 6.0.3.2)
103+
actionmailer (= 6.0.3.2)
104+
actionpack (= 6.0.3.2)
105+
actiontext (= 6.0.3.2)
106+
actionview (= 6.0.3.2)
107+
activejob (= 6.0.3.2)
108+
activemodel (= 6.0.3.2)
109+
activerecord (= 6.0.3.2)
110+
activestorage (= 6.0.3.2)
111+
activesupport (= 6.0.3.2)
112+
bundler (>= 1.3.0)
113+
railties (= 6.0.3.2)
114+
sprockets-rails (>= 2.0.0)
115+
rails-dom-testing (2.0.3)
116+
activesupport (>= 4.2.0)
117+
nokogiri (>= 1.6)
118+
rails-html-sanitizer (1.3.0)
119+
loofah (~> 2.3)
120+
railties (6.0.3.2)
121+
actionpack (= 6.0.3.2)
122+
activesupport (= 6.0.3.2)
123+
method_source
124+
rake (>= 0.8.7)
125+
thor (>= 0.20.3, < 2.0)
126+
rainbow (3.0.0)
127+
rake (12.3.3)
128+
regexp_parser (1.7.1)
129+
rexml (3.2.4)
130+
rspec (3.9.0)
131+
rspec-core (~> 3.9.0)
132+
rspec-expectations (~> 3.9.0)
133+
rspec-mocks (~> 3.9.0)
134+
rspec-core (3.9.2)
135+
rspec-support (~> 3.9.3)
136+
rspec-expectations (3.9.2)
137+
diff-lcs (>= 1.2.0, < 2.0)
138+
rspec-support (~> 3.9.0)
139+
rspec-mocks (3.9.1)
140+
diff-lcs (>= 1.2.0, < 2.0)
141+
rspec-support (~> 3.9.0)
142+
rspec-rails (4.0.1)
143+
actionpack (>= 4.2)
144+
activesupport (>= 4.2)
145+
railties (>= 4.2)
146+
rspec-core (~> 3.9)
147+
rspec-expectations (~> 3.9)
148+
rspec-mocks (~> 3.9)
149+
rspec-support (~> 3.9)
150+
rspec-support (3.9.3)
151+
rubocop (0.88.0)
152+
parallel (~> 1.10)
153+
parser (>= 2.7.1.1)
154+
rainbow (>= 2.2.2, < 4.0)
155+
regexp_parser (>= 1.7)
156+
rexml
157+
rubocop-ast (>= 0.1.0, < 1.0)
158+
ruby-progressbar (~> 1.7)
159+
unicode-display_width (>= 1.4.0, < 2.0)
160+
rubocop-ast (0.2.0)
161+
parser (>= 2.7.0.1)
162+
rubocop-performance (1.7.1)
163+
rubocop (>= 0.82.0)
164+
rubocop-rspec (1.42.0)
165+
rubocop (>= 0.87.0)
166+
ruby-progressbar (1.10.1)
167+
sprockets (4.0.2)
168+
concurrent-ruby (~> 1.0)
169+
rack (> 1, < 3)
170+
sprockets-rails (3.2.1)
171+
actionpack (>= 4.0)
172+
activesupport (>= 4.0)
173+
sprockets (>= 3.0.0)
174+
sqlite3 (1.4.2)
175+
thor (1.0.1)
176+
thread_safe (0.3.6)
177+
tzinfo (1.2.7)
178+
thread_safe (~> 0.1)
179+
unicode-display_width (1.7.0)
180+
websocket-driver (0.7.3)
181+
websocket-extensions (>= 0.1.0)
182+
websocket-extensions (0.1.5)
183+
zeitwerk (2.4.0)
184+
185+
PLATFORMS
186+
ruby
187+
188+
DEPENDENCIES
189+
combustion
190+
graphql
191+
graphql-eager_loader!
192+
rails
193+
rake
194+
rspec
195+
rspec-rails
196+
rubocop
197+
rubocop-performance
198+
rubocop-rspec
199+
sqlite3
200+
201+
BUNDLED WITH
202+
2.1.4

LICENSE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Copyright (c) 2020 HOVER Inc.

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Graphql::Eager::Loader
2+
3+
This gem traverses your graphql query looking for fields on types that match
4+
associations on those types. For each field found to be an association, this
5+
gem adds those associations to an [ActiveRecord::QueryMethods#includes](https://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html#method-i-includes) hash. That hash can then be used to
6+
eager load the associations of records returned in your graphql resolver.
7+
8+
## Installation
9+
10+
Add this line to your application's Gemfile:
11+
12+
```ruby
13+
gem 'graphql-eager-loader', git: 'https://github.com/hoverinc/graphql-eager-loader', require: 'graphql/eager_loader'
14+
```
15+
16+
And then execute:
17+
18+
$ bundle install
19+
20+
## Usage
21+
22+
```ruby
23+
module Resolvers
24+
class Users < Resolvers::Base
25+
eager_load_model ::User
26+
27+
type Types::User.connection_type, null: false
28+
29+
def resolve
30+
User.active.includes(associations_to_eager_load)
31+
end
32+
end
33+
end
34+
```
35+
36+
The `.eager_load_model` and `#associations_to_eager_load` methods are provided by this gem.
37+
38+
## Development
39+
40+
After checking out the repo, run `bundle` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bundle exec bin/console` for an interactive prompt that will allow you to experiment.
41+
42+
To release a new version:
43+
44+
- Update the version number in `version.rb`
45+
- Make a PR with your changes and the version number increment
46+
- After the PR is merged, make the new release https://github.com/hoverinc/graphql-eager-loader/releases
47+
48+
## Contributing
49+
50+
Bug reports and pull requests are welcome on GitHub at https://github.com/hoverinc/graphql-eager-loader.
51+
52+
53+
## License
54+
55+
HOVER owns it. Ask Legal.

Rakefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
require 'bundler/gem_tasks'
4+
require 'rspec/core/rake_task'
5+
6+
RSpec::Core::RakeTask.new(:spec)
7+
8+
task default: :spec

bin/console

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'bundler/setup'
4+
require 'graphql/eager_loader'
5+
6+
# You can add fixtures and/or initialization code here to make experimenting
7+
# with your gem easier. You can also use a different console, if you like.
8+
9+
# (If you use this, don't forget to add pry to your Gemfile!)
10+
# require "pry"
11+
# Pry.start
12+
13+
require 'irb'
14+
IRB.start(__FILE__)

0 commit comments

Comments
 (0)