graphiti_gql 0.2.25 → 0.2.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/graphiti_gql/graphiti_hax.rb +20 -1
- data/lib/graphiti_gql/schema/resource_type.rb +6 -4
- data/lib/graphiti_gql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00d26d5be2b1e9f1f277e0d0922faec91599f72a28fabe77ff16fb1f2ae6870f
|
4
|
+
data.tar.gz: a868703b6bf2a2fbf88464396f0fe17ba836ffc183cee22e2aad06b5bd6a1223
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02f91817b443a31d0eaa280316ddd1ab18691936e401c431a38354370f8a6a1b435076fa022df6d37041f35e08d06fb99fc8104aa957cca4e3b9507bba828117
|
7
|
+
data.tar.gz: 94ca96b977800303c54ecf61fabfeeca65c4b839fc1ae501e6192fdbb30af86181a1aada59d64a47339c28ff3ca4e5469d071a27db9280a59e8c0b339b0f70f6
|
data/Gemfile.lock
CHANGED
@@ -131,7 +131,7 @@ module GraphitiGql
|
|
131
131
|
|
132
132
|
def value_object(name, opts = {})
|
133
133
|
opts[:array] ||= false
|
134
|
-
opts[:null]
|
134
|
+
opts[:null] = true if opts[:null] != false
|
135
135
|
config[:value_objects][name] = Graphiti::ValueObjectAssociation.new(
|
136
136
|
name,
|
137
137
|
parent_resource_class: self,
|
@@ -438,6 +438,7 @@ module GraphitiGql
|
|
438
438
|
|
439
439
|
def resolve(*args)
|
440
440
|
results = super
|
441
|
+
raise Graphiti::Errors::InvalidResolve unless results.is_a?(Array)
|
441
442
|
results.reverse! if @query.hash[:reverse]
|
442
443
|
results
|
443
444
|
end
|
@@ -458,6 +459,24 @@ module GraphitiGql
|
|
458
459
|
end
|
459
460
|
end
|
460
461
|
|
462
|
+
class Graphiti::Errors::InvalidResolve < Graphiti::Errors::Base
|
463
|
+
def message
|
464
|
+
"Resource#resolve must always return an array"
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
468
|
+
class Graphiti::Errors::InvalidValueObject < Graphiti::Errors::Base
|
469
|
+
def initialize(resource, name, value)
|
470
|
+
@resource = resource
|
471
|
+
@name = name
|
472
|
+
@value = value
|
473
|
+
end
|
474
|
+
|
475
|
+
def message
|
476
|
+
"#{@resource} - value object '#{@name}' configured with array: true but returned non-array: #{@value.inspect}"
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
461
480
|
class Graphiti::ValueObjectAssociation
|
462
481
|
attr_reader :name,
|
463
482
|
:parent_resource_class,
|
@@ -44,12 +44,14 @@ module GraphitiGql
|
|
44
44
|
end
|
45
45
|
|
46
46
|
result = vo_resource_class.all({ parent: object }).to_a
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
if result == object || result == [object]
|
47
|
+
default_behavior = result == [object]
|
48
|
+
result = result.first if !_array
|
49
|
+
if default_behavior
|
51
50
|
method_name = vo_association.alias.presence || name
|
52
51
|
result = object.send(method_name)
|
52
|
+
if _array && !result.is_a?(Array)
|
53
|
+
raise Graphiti::Errors::InvalidValueObject.new(resource, name, result)
|
54
|
+
end
|
53
55
|
end
|
54
56
|
result
|
55
57
|
end
|
data/lib/graphiti_gql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphiti_gql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.26
|
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-08-
|
11
|
+
date: 2022-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|