graphql-rails-resolver 0.2.4 → 0.2.5

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: 4113268e7739312f6ac4f42a9eb6ae4b9f70684a
4
- data.tar.gz: e2c711048172d3fdbe2260b236d09118f44c69b5
3
+ metadata.gz: bd138790cf8944a77acea1535d813421e37cdfdd
4
+ data.tar.gz: a61fbe2035032bf6dc0acd09ce6786635732f178
5
5
  SHA512:
6
- metadata.gz: 0bce6833bfc2057460610600a79f538e76b52d0340abf018ff3ace056a0bcf3e2f72d5b167d10903ae76139b9be6e1c714f6364dbe34b710988408ad3dd20f44
7
- data.tar.gz: adf079f574b375f4ea02aa83b86191fb73748910cd24d14fbbe39651a3ee8b0f8607be5a4f0d6ca0c5b9bd20b71f01293affcc6a8bd44d062b8ab38cb23df8ab
6
+ metadata.gz: 5c0fe031a810c3368921b2e215da435a47a33f3694c060e91f5ca037577c5d23a3e2e1ffb78a3080446aa12b3b7e66271e42ac392803e4237e00a2fb88ba3fdf
7
+ data.tar.gz: ec1191eb7e4f9601f5eef38e59ea941615f2adf4d28a84f53a62c48230b8e69ac3dece258fd54cc03543216e68eb53cd245177633ade16cfec1dacee5a06f466
@@ -1,6 +1,11 @@
1
1
  # GraphQL::Rails::Resolver
2
2
  ## CHANGELOG
3
3
 
4
+ ### Version 0.2.5
5
+ Adds heirarchal resolution strategy
6
+
7
+ The base resolver will now check for the field's resolver method on the object. If resolving `Child` on `Parent` it will now default to `Parent.child` instead of `Child.all`
8
+
4
9
  ### Version 0.2.4
5
10
  Adds ID resolution for non-primary ID field arguments
6
11
  Adds `get_field_args` to get type declarations for arguments
@@ -1,7 +1,7 @@
1
1
  module GraphQL
2
2
  module Rails
3
3
  class Resolver
4
- VERSION = '0.2.4'
4
+ VERSION = '0.2.5'
5
5
 
6
6
  attr_accessor :resolvers
7
7
 
@@ -10,7 +10,20 @@ module GraphQL
10
10
  raise ArgumentError, "Resolver requires a callable type or nil" unless callable.respond_to? :call
11
11
  end
12
12
 
13
- @callable = callable || Proc.new { model.all }
13
+ @callable =
14
+ if callable.present?
15
+ callable
16
+ else
17
+ Proc.new { |obj|
18
+ subfield = model.name.underscore.pluralize
19
+ if obj.respond_to? subfield
20
+ obj.send(subfield)
21
+ else
22
+ model.all
23
+ end
24
+ }
25
+ end
26
+
14
27
  @obj = nil
15
28
  @args = nil
16
29
  @ctx = nil
@@ -41,7 +54,7 @@ module GraphQL
41
54
  scope_name = scope_name.call(value) if scope_name.respond_to? :call
42
55
 
43
56
  scope_args = []
44
- scope_args.push(value) if params.key? :with_value && params[:with_value] == true
57
+ scope_args.push(value) if params.key? :with_value and params[:with_value] == true
45
58
 
46
59
  @result = @result.send(scope_name, *scope_args) unless scope_name.nil?
47
60
  # Match custom methods
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-rails-resolver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cole Turner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-10 00:00:00.000000000 Z
11
+ date: 2016-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql