graphql-rails-resolver 0.1.6 → 0.2.1
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/CHANGELOG.md +9 -0
- data/README.md +2 -2
- data/lib/graphql/rails/resolver.rb +8 -22
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee64d6bca94b2b156ab178b9b6af0414541b00c5
|
4
|
+
data.tar.gz: 4ee20e05bdd3b527ec60c4b8777a2d1cd69590df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d82b6daa19709b47f577eb2a4844a9061dab3b9efeacfb3f9e484f897ff7d1e485076afeab0f8dbe84fb75a13c9c39bcc633c373015d661a3bed6d7134c0f2f
|
7
|
+
data.tar.gz: 72965597f70fa865abe78f802173b176e3c4fea37ba5626186f322366c93d010845c7b3bc3659261d21c743550f025acc68375f81a252e05e87fc22f0976956e
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# GraphQL::Rails::Resolver
|
2
2
|
## CHANGELOG
|
3
3
|
|
4
|
+
### Version 0.2.1
|
5
|
+
Added `resolve_id` that resolves a single or list of ID type objects.
|
6
|
+
|
7
|
+
### Version 0.2.0
|
8
|
+
Update to support GraphQL 0.19.0
|
9
|
+
|
10
|
+
Removes `to_model_id` and `lookup_id` functions. This functionality should be decided on the application level via `Schema.object_from_id`
|
11
|
+
Uses schema functions to resolve objects.
|
12
|
+
|
4
13
|
### Version 0.1.5
|
5
14
|
Fixed `where` method resolving superseding attribute.
|
6
15
|
|
data/README.md
CHANGED
@@ -139,9 +139,9 @@ end
|
|
139
139
|
```
|
140
140
|
|
141
141
|
### Find Model by ID
|
142
|
-
`GraphQL::Rails::Resolver` includes the ability to resolve
|
142
|
+
`GraphQL::Rails::Resolver` includes the ability to resolve an object by ID (or a list of ID types). Using the following method, by default the resolver will find a model by **Schema.object_from_id(value)**.
|
143
143
|
```
|
144
|
-
def
|
144
|
+
def object_from_id(value=...)
|
145
145
|
...
|
146
146
|
end
|
147
147
|
```
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module GraphQL
|
2
2
|
module Rails
|
3
3
|
class Resolver
|
4
|
-
VERSION = '0.1
|
4
|
+
VERSION = '0.2.1'
|
5
5
|
|
6
6
|
attr_accessor :resolvers
|
7
7
|
|
@@ -27,7 +27,7 @@ module GraphQL
|
|
27
27
|
|
28
28
|
# If there's an ID type, offer ID resolution_strategy
|
29
29
|
if has_id_argument and args.key? @id_field
|
30
|
-
|
30
|
+
@result = resolve_id(args[@id_field])
|
31
31
|
end
|
32
32
|
|
33
33
|
@resolvers.each do |field,resolvers|
|
@@ -141,33 +141,19 @@ module GraphQL
|
|
141
141
|
"::#{self.class.name.demodulize}".constantize
|
142
142
|
end
|
143
143
|
|
144
|
-
def
|
145
|
-
if is_global_id(value)
|
146
|
-
type_name, id = NodeIdentification.from_global_id(value)
|
147
|
-
constantized = "::#{type_name}".constantize
|
148
|
-
|
149
|
-
if constantized == model
|
150
|
-
id
|
151
|
-
else
|
152
|
-
nil
|
153
|
-
end
|
154
|
-
else
|
155
|
-
value
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def lookup_id(value)
|
144
|
+
def resolve_id(value)
|
160
145
|
if value.kind_of? Array
|
161
|
-
value
|
146
|
+
value.compact.map { |v| @ctx.schema.object_from_id(v, @ctx) }.compact
|
147
|
+
else
|
148
|
+
@ctx.schema.object_from_id(value, @ctx)
|
162
149
|
end
|
163
|
-
|
164
|
-
@result = @result.where(:id => value)
|
165
150
|
end
|
166
151
|
|
167
152
|
class << self
|
168
153
|
@@id_field = :id
|
169
154
|
|
170
|
-
def id_field
|
155
|
+
def id_field(value=nil)
|
156
|
+
@@id_field = value if value.present?
|
171
157
|
@@id_field
|
172
158
|
end
|
173
159
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-rails-resolver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cole Turner
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.19.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.19.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|