graphql_includable 0.5.0.beta.4 → 0.5.0.beta.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: e8a7ae35b0df182e490dd380acbc3f84fa80dfb6
4
- data.tar.gz: da16677c177a2b9aaaa6a9723bc90763a774cbf5
3
+ metadata.gz: 706c871878ee4b1fcd14a42f2f6a2fde885fc989
4
+ data.tar.gz: b1420f85c9c648658c03d6068fba5411f32570ad
5
5
  SHA512:
6
- metadata.gz: 71bf2450237b9ea22c42dd5d1d6aea7850ac9712dfaa7e21f2bfd8831d407aaf32a8962a04d45618e06d3e971d9b44dbe9a0c38ad2590b5ed5f0dc082eb634cb
7
- data.tar.gz: 9adc06e9202198ccf155f545556b865c73929cf4c7f464cb0d45e5ac1ca28f2fa1efc08250fb28d1172d2360c613e76bfbf339ac9cda3d654c4a9740761a68fe
6
+ metadata.gz: ab95ad8c6023765f6211ca8fefc1f1f076516bf7b94972e4b87827e82f357c25164f0e45bfff1b7e4c9ba9953ba37a4542ac78e32fda43d62c739d8aaf786e07
7
+ data.tar.gz: c87e7351efde15a6247f7d82abd771e4b5a33c9d6940e241c0676dba746e5a8cf975ae7c42df0cb3c7f6ffcfd8d38d012120b71b4f24e9ef31db56edb7d83201
@@ -7,19 +7,32 @@ require_relative 'relay/instrumentation'
7
7
 
8
8
  module GraphQLIncludable
9
9
  module New
10
- def self.includes(ctx)
10
+ def self.includes(ctx, starting_at: nil)
11
11
  ActiveSupport::Notifications.instrument('graphql_includable.includes') do |instrument|
12
12
  instrument[:operation_name] = ctx.query&.operation_name
13
13
  instrument[:field_name] = ctx.irep_node.name
14
+ instrument[:starting_at] = starting_at
14
15
 
15
16
  includes = Includes.new(nil)
16
17
  resolver = Resolver.new(ctx)
17
- resolver.includes_for_node(ctx.irep_node, includes)
18
+
19
+ node = ctx.irep_node
20
+ node = node_for_path(node, starting_at) if starting_at.present?
21
+ byebug
22
+ raise ArgumentError, 'Invalid starting_at path' unless node.present?
23
+
24
+ resolver.includes_for_node(node, includes)
18
25
  generated_includes = includes.active_record_includes
26
+
19
27
  instrument[:includes] = generated_includes
20
28
  generated_includes
21
29
  end
22
30
  end
31
+
32
+ def self.node_for_path(node, path_into_query)
33
+ children = node.scoped_children[node.return_type.unwrap]&.with_indifferent_access || {}
34
+ children.dig(path_into_query)
35
+ end
23
36
  end
24
37
  end
25
38
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql_includable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.beta.4
4
+ version: 0.5.0.beta.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Rouse
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-09-03 00:00:00.000000000 Z
13
+ date: 2019-09-04 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description:
16
16
  email: