hq-graphql 2.1.8 → 2.1.9
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 +4 -4
- data/README.md +1 -1
- data/lib/hq/graphql/object.rb +9 -1
- data/lib/hq/graphql/object_association.rb +5 -0
- data/lib/hq/graphql/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 981f1e51c20c41befde482f0ab312887f597727265508b2f8b4290420c91e2e1
|
4
|
+
data.tar.gz: 3038b46301c4b612a99988ba7fe9aa66aadc401a7a8a4ea8a959b3e8c23e8743
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30e473198ed03eaf14a9a4c9730c2a5816f5914dc745ef1fe0acc0b8e16f6a0b9b1f80bb2861fcb7bec16a5a0860bca1197b54892450686e545ef04f4f141611
|
7
|
+
data.tar.gz: e4b0b57d5674e48fe75ec61de48cf484425b504500b1e201322650211856de5557da6353f95907d77bb41bf0b41ef52c0434349d805dc8b29fec27eb0182c57c
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
OneHQ GraphQL interface to [Ruby Graphql](https://github.com/rmosolgo/graphql-ruby).
|
4
4
|
|
5
|
-
|
5
|
+

|
6
6
|
[](https://github.com/OneHQ/hq-graphql)
|
7
7
|
|
8
8
|
## Configuration
|
data/lib/hq/graphql/object.rb
CHANGED
@@ -80,6 +80,10 @@ module HQ
|
|
80
80
|
end
|
81
81
|
instance_eval(&block) if block
|
82
82
|
end
|
83
|
+
when :has_one
|
84
|
+
field name, type, null: !auto_nil || !has_presence_validation?(association), klass: model_name do
|
85
|
+
extension FieldExtension::AssociationLoaderExtension, klass: klass
|
86
|
+
end
|
83
87
|
else
|
84
88
|
field name, type, null: !auto_nil || !association_required?(association), klass: model_name do
|
85
89
|
extension FieldExtension::AssociationLoaderExtension, klass: klass
|
@@ -97,7 +101,11 @@ module HQ
|
|
97
101
|
end
|
98
102
|
|
99
103
|
def association_required?(association)
|
100
|
-
!association.options[:optional] ||
|
104
|
+
!association.options[:optional] || has_presence_validation?(association)
|
105
|
+
end
|
106
|
+
|
107
|
+
def has_presence_validation?(association)
|
108
|
+
model_klass.validators.any? do |validation|
|
101
109
|
next unless validation.class == ActiveRecord::Validations::PresenceValidator
|
102
110
|
validation.attributes.any? { |a| a.to_s == association.name.to_s }
|
103
111
|
end
|
@@ -15,6 +15,11 @@ module HQ
|
|
15
15
|
add_reflection(name, scope, options, :belongs_to, block)
|
16
16
|
end
|
17
17
|
|
18
|
+
def has_one(name, scope = nil, through: nil, **options, &block)
|
19
|
+
raise TypeError, "has_one through is unsupported" if through
|
20
|
+
add_reflection(name, scope, options, :has_one, block)
|
21
|
+
end
|
22
|
+
|
18
23
|
def has_many(name, scope = nil, through: nil, **options, &block)
|
19
24
|
raise TypeError, "has_many through is unsupported" if through
|
20
25
|
add_reflection(name, scope, options, :has_many, block)
|
data/lib/hq/graphql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hq-graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -285,9 +285,9 @@ require_paths:
|
|
285
285
|
- lib
|
286
286
|
required_ruby_version: !ruby/object:Gem::Requirement
|
287
287
|
requirements:
|
288
|
-
- - "
|
288
|
+
- - "~>"
|
289
289
|
- !ruby/object:Gem::Version
|
290
|
-
version: '
|
290
|
+
version: '2.6'
|
291
291
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
292
292
|
requirements:
|
293
293
|
- - ">="
|