graphiti 1.0.beta.16 → 1.0.beta.17

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff5dc08a7d35f114a138a26759c857eb11a226de
4
- data.tar.gz: 00d815886fc13aca087ce7b140fc472020cbfd5c
3
+ metadata.gz: 40e367c51c95cce626468a8e5fc363d1e5b462bb
4
+ data.tar.gz: 6456a1f6d474505b2364039083221a056e5f7cba
5
5
  SHA512:
6
- metadata.gz: bff46d68fcb42853a4d9e31e169ce1a06ea6bb84007728f86cc5f3b2901a3b7b5e310c906e5ad147b14161fc215c7158dd56b92b7dd12b810fd9a599c6b7f74a
7
- data.tar.gz: f519c2331d8c4e30550bcd5481ff07c03ab9ce020855e6b1c7993f60e94d1a12f4930a39eebb4c1c4615cb7cf588ee4127bb6c820d17d4c67ed552c4b61cf20e
6
+ metadata.gz: 110202c3f62d3b1dd711f36ae0eac8baa746dc0711e8b30b20f7838c18db22544a89d8485ac361378afe8f7f27c1786396a0233da4823bcf616098a75c3a6469
7
+ data.tar.gz: 95db7dd5fcaa17800abb4d8a0aa80ebe76273ec20de154facbacf994a677bf0f3299c567855ed0a0047782ab2c6e3f6089072e627024784e5e61a3f0e1f797de
@@ -3,15 +3,15 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 4.1"
6
- gem "jsonapi-rails", "~> 0.3.1", :require => "jsonapi/rails"
6
+ gem "jsonapi-rails", "~> 0.3.1", require: "jsonapi/rails"
7
7
  gem "rspec-rails"
8
8
 
9
9
  group :test do
10
10
  gem "pry"
11
- gem "pry-byebug", :platform => [:mri]
11
+ gem "pry-byebug", platform: [:mri]
12
12
  gem "appraisal"
13
13
  gem "guard"
14
14
  gem "guard-rspec"
15
15
  end
16
16
 
17
- gemspec :path => "../"
17
+ gemspec path: "../"
@@ -3,15 +3,15 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.2"
6
- gem "jsonapi-rails", "~> 0.3.1", :require => "jsonapi/rails"
6
+ gem "jsonapi-rails", "~> 0.3.1", require: "jsonapi/rails"
7
7
  gem "rspec-rails"
8
8
 
9
9
  group :test do
10
10
  gem "pry"
11
- gem "pry-byebug", :platform => [:mri]
11
+ gem "pry-byebug", platform: [:mri]
12
12
  gem "appraisal"
13
13
  gem "guard"
14
14
  gem "guard-rspec"
15
15
  end
16
16
 
17
- gemspec :path => "../"
17
+ gemspec path: "../"
@@ -28,6 +28,13 @@ module Graphiti
28
28
  end
29
29
  end
30
30
 
31
+ # The .stat call stores a proc based on adapter
32
+ # So if we assign a new adapter, reconfigure
33
+ def adapter=(val)
34
+ super
35
+ stat total: [:count]
36
+ end
37
+
31
38
  def model
32
39
  klass = super
33
40
  unless klass || abstract_class?
@@ -26,12 +26,22 @@ module Graphiti
26
26
  desc = all_attributes[attr_name][:description]
27
27
  return desc if desc.present?
28
28
 
29
+ resolve_i18n_field_description(attr_name, field_type: :attributes)
30
+ end
31
+
32
+ # @api private
33
+ def sideload_description(sideload_name)
34
+ sideloads[sideload_name].description
35
+ end
36
+
37
+ # @api private
38
+ def resolve_i18n_field_description(name, field_type:)
29
39
  if defined?(::I18n)
30
40
  desc = ::I18n.t :description,
31
- scope: [*i18n_type_scope, :attributes, attr_name],
41
+ scope: [*i18n_type_scope, field_type, name],
32
42
  default: nil
33
43
  desc ||= ::I18n.t :description,
34
- scope: [*i18n_resource_scope, :attributes, attr_name],
44
+ scope: [*i18n_resource_scope, field_type, name],
35
45
  default: nil
36
46
  end
37
47
  end
@@ -188,7 +188,7 @@ module Graphiti
188
188
  def relationships(resource)
189
189
  {}.tap do |r|
190
190
  resource.sideloads.each_pair do |name, config|
191
- schema = { type: config.type.to_s }
191
+ schema = { type: config.type.to_s, description: config.description }
192
192
  if config.type == :polymorphic_belongs_to
193
193
  schema[:resources] = config.children.values
194
194
  .map(&:resource).map(&:class).map(&:name)
@@ -10,7 +10,8 @@ module Graphiti
10
10
  :primary_key,
11
11
  :parent,
12
12
  :group_name,
13
- :link
13
+ :link,
14
+ :description
14
15
 
15
16
  class_attribute :scope_proc,
16
17
  :assign_proc,
@@ -34,6 +35,8 @@ module Graphiti
34
35
  @single = opts[:single]
35
36
  apply_belongs_to_many_filter if type == :many_to_many
36
37
 
38
+ @description = opts[:description]
39
+
37
40
  # polymorphic-specific
38
41
  @group_name = opts[:group_name]
39
42
  @polymorphic_child = opts[:polymorphic_child]
@@ -133,6 +136,11 @@ module Graphiti
133
136
  raise 'Override #load_params in subclass'
134
137
  end
135
138
 
139
+ def description
140
+ return @description if @description.present?
141
+ parent_resource_class.resolve_i18n_field_description(name, field_type: :relationships)
142
+ end
143
+
136
144
  def base_scope
137
145
  if @base_scope
138
146
  @base_scope.respond_to?(:call) ? @base_scope.call : @base_scope
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.0.beta.16"
2
+ VERSION = "1.0.beta.17"
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.0.beta.16
4
+ version: 1.0.beta.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-27 00:00:00.000000000 Z
11
+ date: 2018-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-serializable