graphql_lazy_load 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +10 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +106 -0
- data/LICENSE.txt +21 -0
- data/README.md +90 -0
- data/Rakefile +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/graphql_lazy_load.gemspec +35 -0
- data/lib/graphql_lazy_load/version.rb +5 -0
- data/lib/graphql_lazy_load.rb +78 -0
- metadata +169 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f712c10800162f814d8f7d170e10231adf25aa518aab8c08b5f7d6459a8b9efe
|
|
4
|
+
data.tar.gz: 98fd3434f3a11930cdd5e7e87be35e03054d7652108f45ecf837cffb7deba177
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 70c960dc556b35794248ac96afcbb067067c8a2f07b1e72987d935afe3a9a7d4eb61bbd40024f3f9dffdb27c2e624caf023080c17ae8a2387fc1ee13db760fc5
|
|
7
|
+
data.tar.gz: 13f918ac5f4d57099d5543c4fa48749ae69179c0026a71ecfef973cdbbcb61673fcbf6fb24bfbe403f6d2df6cdeb0de0b0326f538d47e7e6949a28fd4b3d18cf
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
graphql
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at jonathag@cisco.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
graphql_lazy_load (0.1.0)
|
|
5
|
+
activerecord (>= 4.1.16)
|
|
6
|
+
graphql (>= 1.3.0)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
actionpack (5.2.3)
|
|
12
|
+
actionview (= 5.2.3)
|
|
13
|
+
activesupport (= 5.2.3)
|
|
14
|
+
rack (~> 2.0)
|
|
15
|
+
rack-test (>= 0.6.3)
|
|
16
|
+
rails-dom-testing (~> 2.0)
|
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
18
|
+
actionview (5.2.3)
|
|
19
|
+
activesupport (= 5.2.3)
|
|
20
|
+
builder (~> 3.1)
|
|
21
|
+
erubi (~> 1.4)
|
|
22
|
+
rails-dom-testing (~> 2.0)
|
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
24
|
+
activemodel (5.2.3)
|
|
25
|
+
activesupport (= 5.2.3)
|
|
26
|
+
activerecord (5.2.3)
|
|
27
|
+
activemodel (= 5.2.3)
|
|
28
|
+
activesupport (= 5.2.3)
|
|
29
|
+
arel (>= 9.0)
|
|
30
|
+
activesupport (5.2.3)
|
|
31
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
32
|
+
i18n (>= 0.7, < 2)
|
|
33
|
+
minitest (~> 5.1)
|
|
34
|
+
tzinfo (~> 1.1)
|
|
35
|
+
arel (9.0.0)
|
|
36
|
+
ast (2.4.0)
|
|
37
|
+
builder (3.2.3)
|
|
38
|
+
concurrent-ruby (1.1.5)
|
|
39
|
+
crass (1.0.4)
|
|
40
|
+
erubi (1.8.0)
|
|
41
|
+
graphql (1.9.11)
|
|
42
|
+
i18n (1.6.0)
|
|
43
|
+
concurrent-ruby (~> 1.0)
|
|
44
|
+
jaro_winkler (1.5.3)
|
|
45
|
+
loofah (2.2.3)
|
|
46
|
+
crass (~> 1.0.2)
|
|
47
|
+
nokogiri (>= 1.5.9)
|
|
48
|
+
method_source (0.9.2)
|
|
49
|
+
mini_portile2 (2.4.0)
|
|
50
|
+
minitest (5.11.3)
|
|
51
|
+
nokogiri (1.10.4)
|
|
52
|
+
mini_portile2 (~> 2.4.0)
|
|
53
|
+
parallel (1.17.0)
|
|
54
|
+
parser (2.6.3.0)
|
|
55
|
+
ast (~> 2.4.0)
|
|
56
|
+
psych (3.1.0)
|
|
57
|
+
rack (2.0.7)
|
|
58
|
+
rack-test (1.1.0)
|
|
59
|
+
rack (>= 1.0, < 3)
|
|
60
|
+
rails-dom-testing (2.0.3)
|
|
61
|
+
activesupport (>= 4.2.0)
|
|
62
|
+
nokogiri (>= 1.6)
|
|
63
|
+
rails-html-sanitizer (1.2.0)
|
|
64
|
+
loofah (~> 2.2, >= 2.2.2)
|
|
65
|
+
railties (5.2.3)
|
|
66
|
+
actionpack (= 5.2.3)
|
|
67
|
+
activesupport (= 5.2.3)
|
|
68
|
+
method_source
|
|
69
|
+
rake (>= 0.8.7)
|
|
70
|
+
thor (>= 0.19.0, < 2.0)
|
|
71
|
+
rainbow (3.0.0)
|
|
72
|
+
rake (10.5.0)
|
|
73
|
+
rubocop (0.67.2)
|
|
74
|
+
jaro_winkler (~> 1.5.1)
|
|
75
|
+
parallel (~> 1.10)
|
|
76
|
+
parser (>= 2.5, != 2.5.1.1)
|
|
77
|
+
psych (>= 3.1.0)
|
|
78
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
79
|
+
ruby-progressbar (~> 1.7)
|
|
80
|
+
unicode-display_width (>= 1.4.0, < 1.6)
|
|
81
|
+
rubocop-performance (1.1.0)
|
|
82
|
+
rubocop (>= 0.67.0)
|
|
83
|
+
rubocop-rails_config (0.5.1)
|
|
84
|
+
railties (>= 3.0)
|
|
85
|
+
rubocop (~> 0.60)
|
|
86
|
+
ruby-progressbar (1.10.1)
|
|
87
|
+
thor (0.20.3)
|
|
88
|
+
thread_safe (0.3.6)
|
|
89
|
+
tzinfo (1.2.5)
|
|
90
|
+
thread_safe (~> 0.1)
|
|
91
|
+
unicode-display_width (1.5.0)
|
|
92
|
+
|
|
93
|
+
PLATFORMS
|
|
94
|
+
ruby
|
|
95
|
+
|
|
96
|
+
DEPENDENCIES
|
|
97
|
+
bundler (~> 1.16)
|
|
98
|
+
graphql_lazy_load!
|
|
99
|
+
minitest (~> 5.0)
|
|
100
|
+
rake (~> 10.0)
|
|
101
|
+
rubocop (~> 0.67.2)
|
|
102
|
+
rubocop-performance (~> 1.1)
|
|
103
|
+
rubocop-rails_config (~> 0.5.1)
|
|
104
|
+
|
|
105
|
+
BUNDLED WITH
|
|
106
|
+
1.17.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Jonathon Gardner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# GraphqlLazyLoad
|
|
2
|
+
|
|
3
|
+
Lazy executor for activerecord associations and graphql gem.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
GraphqlLazyLoad requires ActiveRecord >= 4.1.16 and Graphql >= 1.3.0. To use add this line to your application's Gemfile:
|
|
8
|
+
```ruby
|
|
9
|
+
gem 'graphql_lazy_load'
|
|
10
|
+
```
|
|
11
|
+
Then run `bundle install`.
|
|
12
|
+
|
|
13
|
+
Or install it yourself as:
|
|
14
|
+
|
|
15
|
+
$ gem install graphql_lazy_load
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
To use, first add the executor (`GraphqlLazyLoad::ActiveRecordRelation`) to graphqls schema:
|
|
19
|
+
```ruby
|
|
20
|
+
class MySchema < GraphQL::Schema
|
|
21
|
+
mutation(Types::MutationType)
|
|
22
|
+
query(Types::QueryType)
|
|
23
|
+
|
|
24
|
+
lazy_resolve(GraphqlLazyLoad::ActiveRecordRelation, :result)
|
|
25
|
+
end
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Now you can start using it! Wherever you have an association, the syntax is:
|
|
29
|
+
```ruby
|
|
30
|
+
field :field_name, Types::AssociationType, null: false
|
|
31
|
+
def field_name
|
|
32
|
+
GraphqlLazyLoad::ActiveRecordRelation.new(self, :association_name)
|
|
33
|
+
end
|
|
34
|
+
```
|
|
35
|
+
## Examples
|
|
36
|
+
If you have two models `Team` which can have many `Players`. To lazy load players from teams do the following:
|
|
37
|
+
```ruby
|
|
38
|
+
module Types
|
|
39
|
+
class PlayerType < Types::BaseObject
|
|
40
|
+
...
|
|
41
|
+
field :players, [Types::PlayerType], null: false
|
|
42
|
+
def players
|
|
43
|
+
GraphqlLazyLoad::ActiveRecordRelation.new(self, :players)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
```
|
|
48
|
+
And to lazy load teams from players do the following:
|
|
49
|
+
```ruby
|
|
50
|
+
module Types
|
|
51
|
+
class TeamType < Types::BaseObject
|
|
52
|
+
...
|
|
53
|
+
field :team, Types::TeamType, null: false
|
|
54
|
+
def team
|
|
55
|
+
GraphqlLazyLoad::ActiveRecordRelation.new(self, :team)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
```
|
|
60
|
+
### Scoping
|
|
61
|
+
The great thing about `GraphqlLazyLoad::ActiveRecordRelation` is it allows scopes to be passed! So for the example above if you want to allow sorting (or query, paging, etc) do the following.
|
|
62
|
+
```ruby
|
|
63
|
+
module Types
|
|
64
|
+
class PlayerType < Types::BaseObject
|
|
65
|
+
...
|
|
66
|
+
field :players, [Types::PlayerType], null: false do
|
|
67
|
+
argument :order, String, required: false
|
|
68
|
+
end
|
|
69
|
+
def players(order: nil)
|
|
70
|
+
scope = Player.all
|
|
71
|
+
scope = scope.sort(order.underscore) if order
|
|
72
|
+
GraphqlLazyLoad::ActiveRecordRelation.new(self, :players, scope: scope)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
To test this out try the example app at [graph_test](https://github.com/jonathongardner/graph_test)
|
|
79
|
+
|
|
80
|
+
## Contributing
|
|
81
|
+
|
|
82
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jonathongardner/graphql_lazy_load. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
87
|
+
|
|
88
|
+
## Code of Conduct
|
|
89
|
+
|
|
90
|
+
Everyone interacting in the GraphqlLazyLoad project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/graphql_lazy_load/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'graphql_lazy_load'
|
|
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__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require "graphql_lazy_load/version"
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "graphql_lazy_load"
|
|
9
|
+
spec.version = GraphqlLazyLoad::VERSION
|
|
10
|
+
spec.authors = ["Jonathon Gardner"]
|
|
11
|
+
spec.email = ["theappgarnder@gmail.com"]
|
|
12
|
+
|
|
13
|
+
spec.summary = "Lazy executor for activerecord associations and graphql gem."
|
|
14
|
+
spec.description = "Lazy executor for activerecord associations and graphql gem."
|
|
15
|
+
spec.homepage = "http://github.com/jonathongardner/graphql_lazy_load"
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
|
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
22
|
+
end
|
|
23
|
+
spec.bindir = "exe"
|
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
25
|
+
spec.require_paths = ["lib"]
|
|
26
|
+
|
|
27
|
+
spec.add_dependency "activerecord", ">= 4.1.16"
|
|
28
|
+
spec.add_dependency "graphql", ">= 1.3.0"
|
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
30
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
32
|
+
spec.add_development_dependency "rubocop", "~> 0.67.2"
|
|
33
|
+
spec.add_development_dependency "rubocop-performance", "~> 1.1"
|
|
34
|
+
spec.add_development_dependency "rubocop-rails_config", "~> 0.5.1"
|
|
35
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "graphql_lazy_load/version"
|
|
4
|
+
require "active_record"
|
|
5
|
+
|
|
6
|
+
module GraphqlLazyLoad
|
|
7
|
+
class ActiveRecordRelation
|
|
8
|
+
def initialize(type, association, scope: nil)
|
|
9
|
+
@object_class = type.object.class
|
|
10
|
+
@object_id = type.object.id
|
|
11
|
+
@association = association
|
|
12
|
+
@scope = scope
|
|
13
|
+
# Initialize the loading state for this query,
|
|
14
|
+
# or get the previously-initiated state
|
|
15
|
+
# scope cant be used as a hash key because when .hash is called on diff
|
|
16
|
+
# for ~same~ scopes its diff every time but scope == scope will return true if ~same~
|
|
17
|
+
@lazy = (type.context[context_key] ||= []).find { |c| c[:scope] == scope }
|
|
18
|
+
unless @lazy
|
|
19
|
+
@lazy = {
|
|
20
|
+
objects_to_load: Set.new,
|
|
21
|
+
ids: Set.new,
|
|
22
|
+
results: {},
|
|
23
|
+
scope: scope
|
|
24
|
+
}
|
|
25
|
+
type.context[context_key].push(@lazy)
|
|
26
|
+
end
|
|
27
|
+
# Register this to be loaded later unless we've already queued or loaded it
|
|
28
|
+
return if already_loaded_or_queued?
|
|
29
|
+
# use copy of object so it doesnt add preload to associations.
|
|
30
|
+
# this is so associations dont get loaded to object passed so different scopes get reloaded
|
|
31
|
+
lazy_objects.add(object_class.new(type.object.attributes))
|
|
32
|
+
lazy_ids.add(object_id)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Return the loaded record, hitting the database if needed
|
|
36
|
+
def result
|
|
37
|
+
if !already_loaded? && any_to_load?
|
|
38
|
+
ActiveRecord::Associations::Preloader.new.preload(lazy_objects.to_a, association, scope)
|
|
39
|
+
lazy_objects.each do |object|
|
|
40
|
+
lazy_results[object.id] = object.send(association)
|
|
41
|
+
end
|
|
42
|
+
lazy_objects.clear
|
|
43
|
+
end
|
|
44
|
+
lazy_results[object_id]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
attr_reader :object_class, :object_id, :association, :scope
|
|
49
|
+
|
|
50
|
+
def context_key
|
|
51
|
+
[object_class, association]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def already_loaded_or_queued?
|
|
55
|
+
lazy_objects.include?(object_id)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def already_loaded?
|
|
59
|
+
lazy_results.key?(object_id)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def any_to_load?
|
|
63
|
+
lazy_objects.any?
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def lazy_ids
|
|
67
|
+
@lazy[:ids]
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def lazy_objects
|
|
71
|
+
@lazy[:objects_to_load]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def lazy_results
|
|
75
|
+
@lazy[:results]
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: graphql_lazy_load
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jonathon Gardner
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-08-31 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: activerecord
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 4.1.16
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 4.1.16
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: graphql
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 1.3.0
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 1.3.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.16'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.16'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: minitest
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '5.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '5.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rake
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '10.0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '10.0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rubocop
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 0.67.2
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 0.67.2
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rubocop-performance
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '1.1'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '1.1'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: rubocop-rails_config
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 0.5.1
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 0.5.1
|
|
125
|
+
description: Lazy executor for activerecord associations and graphql gem.
|
|
126
|
+
email:
|
|
127
|
+
- theappgarnder@gmail.com
|
|
128
|
+
executables: []
|
|
129
|
+
extensions: []
|
|
130
|
+
extra_rdoc_files: []
|
|
131
|
+
files:
|
|
132
|
+
- ".gitignore"
|
|
133
|
+
- ".rubocop.yml"
|
|
134
|
+
- ".ruby-version"
|
|
135
|
+
- CODE_OF_CONDUCT.md
|
|
136
|
+
- Gemfile
|
|
137
|
+
- Gemfile.lock
|
|
138
|
+
- LICENSE.txt
|
|
139
|
+
- README.md
|
|
140
|
+
- Rakefile
|
|
141
|
+
- bin/console
|
|
142
|
+
- bin/setup
|
|
143
|
+
- graphql_lazy_load.gemspec
|
|
144
|
+
- lib/graphql_lazy_load.rb
|
|
145
|
+
- lib/graphql_lazy_load/version.rb
|
|
146
|
+
homepage: http://github.com/jonathongardner/graphql_lazy_load
|
|
147
|
+
licenses:
|
|
148
|
+
- MIT
|
|
149
|
+
metadata: {}
|
|
150
|
+
post_install_message:
|
|
151
|
+
rdoc_options: []
|
|
152
|
+
require_paths:
|
|
153
|
+
- lib
|
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
|
+
requirements:
|
|
156
|
+
- - ">="
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: '0'
|
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
|
+
requirements:
|
|
161
|
+
- - ">="
|
|
162
|
+
- !ruby/object:Gem::Version
|
|
163
|
+
version: '0'
|
|
164
|
+
requirements: []
|
|
165
|
+
rubygems_version: 3.0.1
|
|
166
|
+
signing_key:
|
|
167
|
+
specification_version: 4
|
|
168
|
+
summary: Lazy executor for activerecord associations and graphql gem.
|
|
169
|
+
test_files: []
|