graphiti 1.3.6 → 1.3.9

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: 016b045277e289f9fe3ee4969581503d8fe7fd1dc6018b6193534b85e9fb5b6b
4
- data.tar.gz: 7a9579101b104027f07b2c9b844e5239dc2d17e8ad231ec1c67a2b01c542e404
3
+ metadata.gz: 30f5b9382256603c1f3f8f4ab8c4e614804c1a2e2152617d7b19892bca6bd465
4
+ data.tar.gz: 948837bfa0f8deee2f44849aba9df2bb18f2fdf532a1caaab92b16c7d9ba91fd
5
5
  SHA512:
6
- metadata.gz: 70be8b04670e43e695ae2dee287230485cf29656446a16d2e1a38085d3d5cf110ac2e3e3e8a349e655d2d57f4bab0d98e2aa827453643572921aa17def40b6fb
7
- data.tar.gz: bf4ff958225d4c593782980878f6b18e43c1568ebd03279361692d4af7de7cc3009bbf5e1678544c854caaa9b427c74afa7df2f2f405c28cb3e0a5fcd751c156
6
+ metadata.gz: 4fe6fff9c219fd463378bbdc793f648cbeffe27c61c191f11e2aab4723e952d2d8f7cc26b334255e12adca3e9d819b1bbde17697a6621f11a28151d2649d6d9c
7
+ data.tar.gz: becca9eaa17f328a99669e1e855a4024862b45d1902ddf30de597f7b33e3f52e4145b0f1dba1542a0d144ba2bc1bdec280ad9d8fa599a102ead9efb5260e1ab3
@@ -415,6 +415,10 @@ module Graphiti
415
415
  [:eq, :not_eq, :gt, :gte, :lt, :lte].freeze
416
416
  end
417
417
 
418
+ def can_group?
419
+ false
420
+ end
421
+
418
422
  private
419
423
 
420
424
  def activerecord_adapter
@@ -305,6 +305,14 @@ module Graphiti
305
305
  ::ActiveRecord::Base.clear_active_connections!
306
306
  end
307
307
 
308
+ def can_group?
309
+ true
310
+ end
311
+
312
+ def group(scope, attribute)
313
+ scope.group(attribute)
314
+ end
315
+
308
316
  private
309
317
 
310
318
  def column_for(scope, name)
@@ -192,7 +192,11 @@ module Graphiti
192
192
  if options[:meta] && !options[:meta].empty?
193
193
  if @graphql
194
194
  if (stats = options[:meta][:stats])
195
- hash[top_level_key][:stats] = stats
195
+ camelized = {}
196
+ stats.each_pair do |key, value|
197
+ camelized[key.to_s.camelize(:lower).to_sym] = value
198
+ end
199
+ hash[top_level_key][:stats] = camelized
196
200
  end
197
201
  else
198
202
  hash.merge!(options.slice(:meta))
@@ -68,7 +68,7 @@ module Graphiti
68
68
  model_ref = model
69
69
  has_many name, opts do
70
70
  params do |hash|
71
- hash[:filter][:"#{as}_type"] = model_ref.name
71
+ hash[:filter][:"#{as}_type"] = { eql: model_ref.name }
72
72
  end
73
73
 
74
74
  instance_eval(&blk) if blk
@@ -82,7 +82,7 @@ module Graphiti
82
82
  model_ref = model
83
83
  has_one name, opts do
84
84
  params do |hash|
85
- hash[:filter][:"#{as}_type"] = model_ref.name
85
+ hash[:filter][:"#{as}_type"] = { eql: model_ref.name }
86
86
  end
87
87
 
88
88
  instance_eval(&blk) if blk
@@ -85,9 +85,15 @@ module Graphiti
85
85
 
86
86
  def stats
87
87
  @stats ||= if @query.hash[:stats]
88
+ scope = @scope.unpaginated_object
89
+ if resource.adapter.can_group?
90
+ if (group = @query.hash[:stats].delete(:group_by))
91
+ scope = resource.adapter.group(scope, group[0])
92
+ end
93
+ end
88
94
  payload = Stats::Payload.new @resource,
89
95
  @query,
90
- @scope.unpaginated_object,
96
+ scope,
91
97
  data
92
98
  payload.generate
93
99
  else
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.3.6"
2
+ VERSION = "1.3.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-04 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-serializable
@@ -355,7 +355,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
355
355
  - !ruby/object:Gem::Version
356
356
  version: '0'
357
357
  requirements: []
358
- rubygems_version: 3.2.22
358
+ rubygems_version: 3.3.7
359
359
  signing_key:
360
360
  specification_version: 4
361
361
  summary: Easily build jsonapi.org-compatible APIs