graphql-sources 0.5.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/lib/graphql/sources/active_record_collection.rb +0 -2
- data/lib/graphql/sources/active_record_count.rb +0 -2
- data/lib/graphql/sources/active_record_object.rb +0 -2
- data/lib/graphql/sources/active_storage_has_many_attached.rb +0 -2
- data/lib/graphql/sources/active_storage_has_one_attached.rb +0 -2
- data/lib/graphql/sources/version.rb +1 -1
- data/lib/graphql/sources.rb +4 -6
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e1dff9e9ccdc886ea784a7276e4a6623e6cfca8df8286492b28cc8bd237039b
|
4
|
+
data.tar.gz: 87249e51a1a7f4355d399883567a24acc17b11ed081b7a9f87dd8604bb3a6e33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32737d8bff6005b5e41a1c19e8d526ae0ce8e8665902f26983d8210cfe2b28f16fb27cab6b16a03cb35549c86f74637ac1f8462eafec4e28a8c0483392e691e5
|
7
|
+
data.tar.gz: 29f417cbdcac1a76846d52110c815bb76816532cd3e82be93fb2637b3176809d0c51e88a9d73d2d1f04a02d4e8e2d3374d423ea62754a8ceb4ef028747367a13
|
data/README.md
CHANGED
@@ -10,6 +10,15 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
10
10
|
|
11
11
|
$ gem install graphql-sources
|
12
12
|
|
13
|
+
The `GraphQL::Dataloader` plugin must be installed in the schema:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
class AppSchema < GraphQL::Schema
|
17
|
+
use GraphQL::Dataloader
|
18
|
+
# ...
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
13
22
|
## Usage
|
14
23
|
|
15
24
|
### Loading `has_one` Associations
|
@@ -63,7 +72,7 @@ end
|
|
63
72
|
class UserType < GraphQL::Schema::Object
|
64
73
|
field :comments, [CommentType], null: false
|
65
74
|
|
66
|
-
def
|
75
|
+
def comments
|
67
76
|
dataloader
|
68
77
|
.with(GraphQL::Sources::ActiveRecordCollection, ::Comment, key: :user_id)
|
69
78
|
.load(object.id)
|
@@ -136,7 +145,7 @@ end
|
|
136
145
|
class PostType < GraphQL::Schema::Object
|
137
146
|
field :likes, Integer, null: false
|
138
147
|
|
139
|
-
def
|
148
|
+
def likes
|
140
149
|
dataloader
|
141
150
|
.with(GraphQL::Sources::ActiveRecordCount, ::Like, key: :post_id)
|
142
151
|
.load(object.id)
|
data/lib/graphql/sources.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'graphql'
|
4
|
+
require 'zeitwerk'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
require_relative './sources/active_storage_has_many_attached'
|
9
|
-
require_relative './sources/active_storage_has_one_attached'
|
10
|
-
require_relative './sources/rails_cache'
|
6
|
+
loader = Zeitwerk::Loader.for_gem
|
7
|
+
loader.push_dir(__dir__, namespace: GraphQL)
|
8
|
+
loader.setup
|
11
9
|
|
12
10
|
module GraphQL
|
13
11
|
# A collection of common GraphQL dataloader classes.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-sources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Sylvestre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: zeitwerk
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: factory_bot
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|