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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e99e1d718952f3ee55b0a0b37c6f4f9f99789f4740243a6dd7995bee2b5fa6a4
4
- data.tar.gz: 4f082d61109e02db43b06b2ff345dd2fdc697f8a6dc30336b7e6226e352a5e79
3
+ metadata.gz: 1e1dff9e9ccdc886ea784a7276e4a6623e6cfca8df8286492b28cc8bd237039b
4
+ data.tar.gz: 87249e51a1a7f4355d399883567a24acc17b11ed081b7a9f87dd8604bb3a6e33
5
5
  SHA512:
6
- metadata.gz: 58202b58608b54a184ed5831672ebafbd39b216cee19908139b4c9ee6e2874197ed5609fcb2bcd592074e101e77ddce8b1e250db5777c55427a37e7f19abc7be
7
- data.tar.gz: ee4949a68c77cf7ea0b945f4f79d4a5ba6de9e491c64abb472f8091b01c8181512beafbaa16ca66bbecd8cc64b33c8891d2b3d2589659610ad0149c29dfdf6e0
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 profile
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 comments
148
+ def likes
140
149
  dataloader
141
150
  .with(GraphQL::Sources::ActiveRecordCount, ::Like, key: :post_id)
142
151
  .load(object.id)
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './active_record_base'
4
-
5
3
  module GraphQL
6
4
  module Sources
7
5
  # A class for loading `has_many` style associations.
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './active_record_base'
4
-
5
3
  module GraphQL
6
4
  module Sources
7
5
  # A class for loading a count of records.
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './active_record_base'
4
-
5
3
  module GraphQL
6
4
  module Sources
7
5
  # A class for loading `has_one` style associations.
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './active_storage_base'
4
-
5
3
  module GraphQL
6
4
  module Sources
7
5
  # A class for loading `has_many_attached` style associations.
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './active_storage_base'
4
-
5
3
  module GraphQL
6
4
  module Sources
7
5
  # A class for loading `has_one_attached` style associations.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module Sources
5
- VERSION = '0.5.0'
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  end
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'graphql'
4
+ require 'zeitwerk'
4
5
 
5
- require_relative './sources/active_record_count'
6
- require_relative './sources/active_record_collection'
7
- require_relative './sources/active_record_object'
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: 0.5.0
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-05 00:00:00.000000000 Z
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