graphql-result_cache 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: a82a463a163e049de4904d6c8ccc2dcd434ba9f2d9b8cc290a607691b7444086
4
- data.tar.gz: a1614159c06e2924a3a11c082bae2668da3acd315ddc881ed70d01a9889ef6a5
3
+ metadata.gz: c49ef03b8c247374a8b3374471873c4a921dc9fc1b4a4e9e379e2d6f04a61cdd
4
+ data.tar.gz: bc292f89395de326e1e84feee22a648fe4a553d7151f0e50dd46a11a234a5adf
5
5
  SHA512:
6
- metadata.gz: f5437965558d61fbb534ac2cef46c51b70f9a1ba08550dc3aece6b474bb3501b7fbcd53a386f999f5efbe776c0e41fb56bef632c3a5c238687bd516fb6503a46
7
- data.tar.gz: bf03d88d2fa2a4fab03522f1b14321ddf35076ae3781a4e545c0f683d25b5d1c5d03f25364fa74deb2c350f5becb9ba0b1c4cabf452b9a602cbb41b93cee640d
6
+ metadata.gz: 7acd578c4015a18728af29976c44267cd11bf79978db95164c8a01f82bc4aeb2e076080fe87440448b08eea17b4e652ad588711e5c581704cf678ecb78f779f4
7
+ data.tar.gz: a072f2778e71b313151a4af9f6683f2ec633c12da1cfd477b2db596f4ab8b8b057f91d4cfbb5e386705eb8d80f817e5d2022afc802cb5a19b3d79e1bfc5827a9
data/README.md CHANGED
@@ -110,15 +110,10 @@ GraphQL::ResultCache.configure do |config|
110
110
  end
111
111
  ```
112
112
 
113
- When the query is an introspection, you can set the value to avoid getting the nullable type for a non-null type.
113
+ When using with introspection, you need to assign custom introspection to avoid getting the nullable type for a non-null type.
114
114
  ```ruby
115
- class GraphqlController < ApplicationController
116
- def execute
117
- # ...
118
- GraphQL::ResultCache.introspection = params[:query].include? '__schema'
119
- result = MySchema.execute(params[:query], variables: ensure_hash(params[:variables]), context: context, operation_name: params[:operationName])
120
- render json: GraphQL::ResultCache::Result.new(result)
121
- end
115
+ class MySchema < GraphQL::Schema
116
+ introspection ::GraphQL::ResultCache::Introspection
122
117
  end
123
118
  ```
124
119
 
@@ -9,6 +9,7 @@ module GraphQL
9
9
  def to_graphql
10
10
  field_defn = super # Returns a GraphQL::Field
11
11
  field_defn.metadata[:result_cache] = @result_cache_config
12
+ field_defn.metadata[:original_non_null] = true if @result_cache_config && field_defn.type.non_null?
12
13
  field_defn
13
14
  end
14
15
  end
@@ -12,7 +12,7 @@ module GraphQL
12
12
  cached_resolve_proc = cached_resolve(field)
13
13
  field.redefine do
14
14
  resolve(cached_resolve_proc)
15
- type(field.type.of_type) if !::GraphQL::ResultCache.introspection? && field.type.non_null?
15
+ type(field.type.of_type) if field.type.non_null?
16
16
  end
17
17
  end
18
18
 
@@ -0,0 +1,13 @@
1
+ module GraphQL
2
+ module ResultCache
3
+ module Introspection
4
+ class FieldType < ::GraphQL::Introspection::FieldType
5
+
6
+ def type
7
+ @object.metadata[:original_non_null] && !@object.type.non_null? ? @object.type.to_non_null_type : @object.type
8
+ end
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ module GraphQL
2
+ module ResultCache
3
+ module Introspection
4
+ end
5
+ end
6
+ end
7
+
8
+ require 'graphql/result_cache/introspection/field_type'
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module ResultCache
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
@@ -3,6 +3,7 @@ require 'graphql/result_cache/version'
3
3
  require 'graphql/result_cache/field'
4
4
  require 'graphql/result_cache/result'
5
5
  require 'graphql/result_cache/field_instrument'
6
+ require 'graphql/result_cache/introspection'
6
7
 
7
8
  module GraphQL
8
9
  module ResultCache
@@ -16,9 +17,6 @@ module GraphQL
16
17
  # c.client_hash = -> { Rails.cache.read(:deploy_version) }
17
18
  attr_accessor :client_hash
18
19
 
19
- attr_accessor :introspection
20
- alias introspection? introspection
21
-
22
20
  # ```
23
21
  # GraphQL::ResultCache.configure do |c|
24
22
  # c.namespace = "GraphQL:Result"
@@ -34,7 +32,6 @@ module GraphQL
34
32
  # Default configuration
35
33
  @expires_in = 3600 # 1.hour
36
34
  @namespace = 'GraphQL:Result'
37
- @introspection = false
38
35
 
39
36
  def self.use(schema_def, options: {})
40
37
  schema_def.instrument(:field, ::GraphQL::ResultCache::FieldInstrument.new)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-result_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ying Fu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-06 00:00:00.000000000 Z
11
+ date: 2019-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -90,6 +90,8 @@ files:
90
90
  - lib/graphql/result_cache/context_config.rb
91
91
  - lib/graphql/result_cache/field.rb
92
92
  - lib/graphql/result_cache/field_instrument.rb
93
+ - lib/graphql/result_cache/introspection.rb
94
+ - lib/graphql/result_cache/introspection/field_type.rb
93
95
  - lib/graphql/result_cache/key.rb
94
96
  - lib/graphql/result_cache/rails.rb
95
97
  - lib/graphql/result_cache/result.rb