graphql_preload_queries 0.2.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6c097ebc42e856cee8e7bf0d47d97094977294c59b38a4919c83c2cb9dfcd8e
4
- data.tar.gz: 969218ee1d4eb0a6683852ad73b2471ca47966ed4dc785cb554e40f3f2195acc
3
+ metadata.gz: 2033097c8239ec615569f2e51837e68b0300e46c8983a2d4d9db11d98d9ceea8
4
+ data.tar.gz: 1015a0b2bbd114ecc5b8de4c57b42c1591494e0c64b53595a2177d4886d18555
5
5
  SHA512:
6
- metadata.gz: ee2df1f6f245eca40436df7bf93146bd27488ae6c884218b942a15e67b1c40d086e88cc864b834e9dc855b61282373d1e665da18f2c80ee03a146ed90ba4d08d
7
- data.tar.gz: 9c5fcf16de9709a93cb3b2208a1702de7265322dcd57f971232167e61385f4caefa4c6b61127fc0c899db2add1c09b8255d13394f935cc8c8e111b34a79ce062
6
+ metadata.gz: 04df1b49aae6f5978bafb22cfa8740d62ee70eb87963617fcd8b5c8766ee57d0d49a1633d53c5211aaa1f24f76513683b56f2f148f8ff732532fbd7722f6a474
7
+ data.tar.gz: 33432e16d0465307533537cdd1e438b6afafe515a0ac6c06933c828e29905eb697aa7e85d3a8ef1d73b82a861f38d4617bbc49df407464b41f6e8ae5c0eeca6c
@@ -1,3 +1,8 @@
1
+ ## 0.3 (22-01-2021)
2
+ - feat: add debug mode
3
+ ```GraphqlPreloadQueries::DEBUG = true```
4
+ - fix: detect the correct Query Result Type
5
+
1
6
  ## 0.2.2 (21-01-2021)
2
7
  - Fix: Fix deep recursive stack error
3
8
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql_preload_queries (0.2.2)
4
+ graphql_preload_queries (0.3)
5
5
  graphql
6
6
  rails
7
7
 
data/README.md CHANGED
@@ -84,6 +84,12 @@ Or install it yourself as:
84
84
  $ gem install graphql_preload_queries
85
85
  ```
86
86
 
87
+ For debugging mode:
88
+ ```
89
+ # config/initializers/gql_preload.rb
90
+ GraphqlPreloadQueries::DEBUG = true
91
+ ```
92
+
87
93
  ## Contributing
88
94
  Bug reports and pull requests are welcome on GitHub at https://github.com/owen2345/graphql_preload_queries. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
89
95
 
@@ -7,7 +7,7 @@ module GraphqlPreloadQueries::PatchContinueValue # rubocop:disable Style/ClassAn
7
7
  value = args[1]
8
8
  ast_node = args[5]
9
9
  field = args[3]
10
- type_klass = field.owner
10
+ type_klass = Array(field.instance_variable_get(:@return_type_expr))[0]
11
11
  is_active_record = value.is_a?(ActiveRecord::Relation)
12
12
  return super if !is_active_record || value.loaded? || !type_klass.respond_to?(:preloads)
13
13
 
@@ -5,4 +5,8 @@ require 'graphql'
5
5
  require 'graphql_preload_queries/extensions/preload'
6
6
 
7
7
  module GraphqlPreloadQueries
8
+ DEBUG = false
9
+ def self.log(msg)
10
+ puts "***GraphqlPreloadQueries: #{msg}" if DEBUG
11
+ end
8
12
  end
@@ -12,7 +12,10 @@ module GraphqlPreloadQueries
12
12
  # @param @type_klass (GqlTypeKlass)
13
13
  # @return @data with necessary preloads
14
14
  def preload_associations(value, node, type_klass)
15
- apply_preloads(value, filter_preloads(node, type_klass.preloads || {}))
15
+ preloads = filter_preloads(node, type_klass.preloads || {})
16
+ log_info = { type_klass: type_klass, preloads: preloads, configured: type_klass.preloads }
17
+ GraphqlPreloadQueries.log("Preloading: #{log_info}")
18
+ apply_preloads(value, preloads)
16
19
  end
17
20
 
18
21
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GraphqlPreloadQueries
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql_preload_queries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - owen2345
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-21 00:00:00.000000000 Z
11
+ date: 2021-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql