graphiti 1.0.beta.16 → 1.0.beta.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemfiles/rails_4.gemfile +3 -3
- data/gemfiles/rails_5.gemfile +3 -3
- data/lib/graphiti/resource/configuration.rb +7 -0
- data/lib/graphiti/resource/documentation.rb +12 -2
- data/lib/graphiti/schema.rb +1 -1
- data/lib/graphiti/sideload.rb +9 -1
- data/lib/graphiti/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40e367c51c95cce626468a8e5fc363d1e5b462bb
|
4
|
+
data.tar.gz: 6456a1f6d474505b2364039083221a056e5f7cba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 110202c3f62d3b1dd711f36ae0eac8baa746dc0711e8b30b20f7838c18db22544a89d8485ac361378afe8f7f27c1786396a0233da4823bcf616098a75c3a6469
|
7
|
+
data.tar.gz: 95db7dd5fcaa17800abb4d8a0aa80ebe76273ec20de154facbacf994a677bf0f3299c567855ed0a0047782ab2c6e3f6089072e627024784e5e61a3f0e1f797de
|
data/gemfiles/rails_4.gemfile
CHANGED
@@ -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", :
|
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", :
|
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 :
|
17
|
+
gemspec path: "../"
|
data/gemfiles/rails_5.gemfile
CHANGED
@@ -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", :
|
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", :
|
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 :
|
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,
|
41
|
+
scope: [*i18n_type_scope, field_type, name],
|
32
42
|
default: nil
|
33
43
|
desc ||= ::I18n.t :description,
|
34
|
-
scope: [*i18n_resource_scope,
|
44
|
+
scope: [*i18n_resource_scope, field_type, name],
|
35
45
|
default: nil
|
36
46
|
end
|
37
47
|
end
|
data/lib/graphiti/schema.rb
CHANGED
@@ -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)
|
data/lib/graphiti/sideload.rb
CHANGED
@@ -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
|
data/lib/graphiti/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2018-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializable
|