graphql-sources 1.1.2 → 1.3.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: 4e7c380fca740b89a1c8797745da617dd1d0b5eae2de11ca99cb2101b0b666e3
4
- data.tar.gz: ed39e7db2d5c1ae8cd4a3e723a8277e032f2994bc8c5616f765f8ab04da22034
3
+ metadata.gz: b4484ab76e8479321a3b7c451654dfbf6f4d2bc8468305829e45d9edfebf7115
4
+ data.tar.gz: e4838bff5cd3e1755e5a5cb3a714ba0502fdf2c24c6db4aeec190e45b2d9f238
5
5
  SHA512:
6
- metadata.gz: 52d2c0a9b72c0a7cd283ac60854b6827f187bf2e581ff67b1c0ae4f5cf4695721bbd8d704f84f5e773ddcfc1f63a4cb9d68b27356c1e322e4b46e7c18d3dba57
7
- data.tar.gz: 6e4c3cdcd606af9d5bf43c99759459a80fe9812d7e16fb21340a66097fea9b7effc8b575111287ef6dac6ce3039e7199dceb84c34eef0818508337e80c79f8f9
6
+ metadata.gz: 7f4ffac3729a6210f9a4ec7b5fbeebe37442d0e4c3578714e1648bc136b51f7abfe71b28432253607580c475f9c1f74992226f5af363857a715554dce0e92393
7
+ data.tar.gz: f10d7510af4681949aac56d252496da8d633151cd0151e9f34bf920e9d9d192c9943e869f506f2c92c4733c1a8662070173fb923405aa66f3f4967642d46907f
data/Gemfile CHANGED
@@ -3,3 +3,7 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
+
7
+ gem 'rake'
8
+ gem 'rspec'
9
+ gem 'rubocop'
data/README.md CHANGED
@@ -37,7 +37,7 @@ end
37
37
 
38
38
  ```ruby
39
39
  class PurchaseType < GraphQL::Schema::Object
40
- field :customer, [CustomerTYpe], null: false
40
+ field :customer, [CustomerType], null: false
41
41
 
42
42
  def customer
43
43
  dataloader
@@ -147,7 +147,7 @@ class UserType < GraphQL::Schema::Object
147
147
 
148
148
  def photos
149
149
  dataloader
150
- .with(GraphQL::Sources::ActiveStorageHasOneAttached, :photos)
150
+ .with(GraphQL::Sources::ActiveStorageHasManyAttached, :photos)
151
151
  .load(object)
152
152
  end
153
153
  end
@@ -6,7 +6,16 @@ module GraphQL
6
6
  class ActiveRecordBase < GraphQL::Dataloader::Source
7
7
  # @param model [Class] a child class of ActiveRecord::Base (e.g. Comment)
8
8
  # @param key [Symbol] an attribute (typically a foreign key) to use for loading (e.g. :user_id)
9
- def initialize(model, key:)
9
+ # @return [Array] a key
10
+ def self.batch_key_for(model, key: :id)
11
+ return [model.to_sql, key] if model.is_a?(ActiveRecord::Relation)
12
+
13
+ [model, key]
14
+ end
15
+
16
+ # @param model [Class] a child class of ActiveRecord::Base (e.g. Comment)
17
+ # @param key [Symbol] an attribute (typically a foreign key) to use for loading (e.g. :user_id)
18
+ def initialize(model, key: :id)
10
19
  super()
11
20
  @model = model
12
21
  @key = key
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module Sources
5
- VERSION = '1.1.2'
5
+ VERSION = '1.3.0'
6
6
  end
7
7
  end
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: 1.1.2
4
+ version: 1.3.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: 2023-07-02 00:00:00.000000000 Z
11
+ date: 2024-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop-rspec_rails
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: simplecov
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -234,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
248
  - !ruby/object:Gem::Version
235
249
  version: '0'
236
250
  requirements: []
237
- rubygems_version: 3.4.10
251
+ rubygems_version: 3.5.11
238
252
  signing_key:
239
253
  specification_version: 4
240
254
  summary: A set of common GraphQL DataLoader sources.