graphql 2.0.5 → 2.0.6
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.
Potentially problematic release.
This version of graphql might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/generators/graphql/install_generator.rb +1 -1
- data/lib/graphql/introspection/type_type.rb +1 -1
- data/lib/graphql/introspection.rb +1 -1
- data/lib/graphql/pagination/array_connection.rb +4 -2
- data/lib/graphql/schema/field.rb +20 -22
- data/lib/graphql/schema/loader.rb +1 -1
- data/lib/graphql/schema/member/has_fields.rb +1 -1
- data/lib/graphql/schema/resolver.rb +1 -1
- data/lib/graphql/schema.rb +1 -0
- data/lib/graphql/types/iso_8601_date.rb +4 -1
- data/lib/graphql/types/iso_8601_date_time.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c31ecaae04f8ea6bca65c031a2a41d124d8a1e1dade016decfb047cae3f900ae
|
4
|
+
data.tar.gz: af77a6ac50b38ca0d23a08da8f63fea1ca8f14ef11ccda56de55e678518380c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6038fd4fe140b2196011e14cc61ba8b0ad72008b3cbe9d317bc87996fe6b42f7f289e188cd0d8c22a9d5f08c558d9774fa3533690355a16258b8276ad885e53
|
7
|
+
data.tar.gz: ff7c5db4532240f9c11d7f3008441f27c5b3a6948cfe942eaf337711436fe9c678de913a849a2e627689a15a08bb2f90f9a345185945308669447ec31dd61027
|
@@ -47,7 +47,7 @@ module Graphql
|
|
47
47
|
#
|
48
48
|
# Accept a `--batch` option which adds `GraphQL::Batch` setup.
|
49
49
|
#
|
50
|
-
# Use `--
|
50
|
+
# Use `--skip-graphiql` to skip `graphiql-rails` installation.
|
51
51
|
#
|
52
52
|
# TODO: also add base classes
|
53
53
|
class InstallGenerator < Rails::Generators::Base
|
@@ -35,9 +35,11 @@ module GraphQL
|
|
35
35
|
def load_nodes
|
36
36
|
@nodes ||= begin
|
37
37
|
sliced_nodes = if before && after
|
38
|
-
|
38
|
+
end_idx = index_from_cursor(before)-1
|
39
|
+
end_idx < 0 ? [] : items[index_from_cursor(after)..end_idx] || []
|
39
40
|
elsif before
|
40
|
-
|
41
|
+
end_idx = index_from_cursor(before)-2
|
42
|
+
end_idx < 0 ? [] : items[0..end_idx] || []
|
41
43
|
elsif after
|
42
44
|
items[index_from_cursor(after)..-1] || []
|
43
45
|
else
|
data/lib/graphql/schema/field.rb
CHANGED
@@ -28,6 +28,9 @@ module GraphQL
|
|
28
28
|
# @return [String] Method or hash key on the underlying object to look up
|
29
29
|
attr_reader :method_str
|
30
30
|
|
31
|
+
attr_reader :hash_key
|
32
|
+
attr_reader :dig_keys
|
33
|
+
|
31
34
|
# @return [Symbol] The method on the type to look up
|
32
35
|
def resolver_method
|
33
36
|
if @resolver_class
|
@@ -243,14 +246,13 @@ module GraphQL
|
|
243
246
|
end
|
244
247
|
end
|
245
248
|
|
246
|
-
|
247
|
-
method_name = method || hash_key || name_s
|
249
|
+
method_name = method || name_s
|
248
250
|
@dig_keys = dig
|
249
|
-
|
251
|
+
@hash_key = hash_key
|
250
252
|
|
251
253
|
@method_str = -method_name.to_s
|
252
254
|
@method_sym = method_name.to_sym
|
253
|
-
@resolver_method = resolver_method
|
255
|
+
@resolver_method = (resolver_method || name_s).to_sym
|
254
256
|
@complexity = complexity
|
255
257
|
@return_type_expr = type
|
256
258
|
@return_type_null = if !null.nil?
|
@@ -635,14 +637,13 @@ module GraphQL
|
|
635
637
|
obj = @resolver_class.new(object: obj, context: query_ctx, field: self)
|
636
638
|
end
|
637
639
|
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
if obj.respond_to?(resolver_method)
|
640
|
+
inner_object = obj.object
|
641
|
+
|
642
|
+
if @hash_key
|
643
|
+
inner_object[@hash_key]
|
644
|
+
elsif @dig_keys
|
645
|
+
inner_object.dig(*@dig_keys)
|
646
|
+
elsif obj.respond_to?(resolver_method)
|
646
647
|
method_to_call = resolver_method
|
647
648
|
method_receiver = obj
|
648
649
|
# Call the method with kwargs, if there are any
|
@@ -651,30 +652,27 @@ module GraphQL
|
|
651
652
|
else
|
652
653
|
obj.public_send(resolver_method)
|
653
654
|
end
|
654
|
-
elsif
|
655
|
-
inner_object
|
656
|
-
if @dig_keys
|
657
|
-
inner_object.dig(*@dig_keys)
|
658
|
-
elsif inner_object.key?(@method_sym)
|
655
|
+
elsif inner_object.is_a?(Hash)
|
656
|
+
if inner_object.key?(@method_sym)
|
659
657
|
inner_object[@method_sym]
|
660
658
|
else
|
661
659
|
inner_object[@method_str]
|
662
660
|
end
|
663
|
-
elsif
|
661
|
+
elsif inner_object.respond_to?(@method_sym)
|
664
662
|
method_to_call = @method_sym
|
665
663
|
method_receiver = obj.object
|
666
664
|
if ruby_kwargs.any?
|
667
|
-
|
665
|
+
inner_object.public_send(@method_sym, **ruby_kwargs)
|
668
666
|
else
|
669
|
-
|
667
|
+
inner_object.public_send(@method_sym)
|
670
668
|
end
|
671
669
|
else
|
672
670
|
raise <<-ERR
|
673
671
|
Failed to implement #{@owner.graphql_name}.#{@name}, tried:
|
674
672
|
|
675
673
|
- `#{obj.class}##{resolver_method}`, which did not exist
|
676
|
-
- `#{
|
677
|
-
- Looking up hash key `#{@method_sym.inspect}` or `#{@method_str.inspect}` on `#{
|
674
|
+
- `#{inner_object.class}##{@method_sym}`, which did not exist
|
675
|
+
- Looking up hash key `#{@method_sym.inspect}` or `#{@method_str.inspect}` on `#{inner_object}`, but it wasn't a Hash
|
678
676
|
|
679
677
|
To implement this field, define one of the methods above (and check for typos)
|
680
678
|
ERR
|
@@ -72,7 +72,7 @@ module GraphQL
|
|
72
72
|
def add_field(field_defn, method_conflict_warning: field_defn.method_conflict_warning?)
|
73
73
|
# Check that `field_defn.original_name` equals `resolver_method` and `method_sym` --
|
74
74
|
# that shows that no override value was given manually.
|
75
|
-
if method_conflict_warning && CONFLICT_FIELD_NAMES.include?(field_defn.resolver_method) && field_defn.original_name == field_defn.resolver_method && field_defn.original_name == field_defn.method_sym
|
75
|
+
if method_conflict_warning && CONFLICT_FIELD_NAMES.include?(field_defn.resolver_method) && field_defn.original_name == field_defn.resolver_method && field_defn.original_name == field_defn.method_sym && field_defn.hash_key.nil? && field_defn.dig_keys.nil?
|
76
76
|
warn(conflict_field_name_warning(field_defn))
|
77
77
|
end
|
78
78
|
prev_defn = own_fields[field_defn.name]
|
@@ -73,7 +73,7 @@ module GraphQL
|
|
73
73
|
context.schema.after_lazy(ready_val) do |is_ready, ready_early_return|
|
74
74
|
if ready_early_return
|
75
75
|
if is_ready != false
|
76
|
-
raise "Unexpected result from #ready? (expected `true`, `false` or `[false, {...}]`): [#{
|
76
|
+
raise "Unexpected result from #ready? (expected `true`, `false` or `[false, {...}]`): [#{is_ready.inspect}, #{ready_early_return.inspect}]"
|
77
77
|
else
|
78
78
|
ready_early_return
|
79
79
|
end
|
data/lib/graphql/schema.rb
CHANGED
@@ -14,6 +14,7 @@ module GraphQL
|
|
14
14
|
# own Date type.
|
15
15
|
class ISO8601Date < GraphQL::Schema::Scalar
|
16
16
|
description "An ISO 8601-encoded date"
|
17
|
+
specified_by_url "https://tools.ietf.org/html/rfc3339"
|
17
18
|
|
18
19
|
# @param value [Date,Time,DateTime,String]
|
19
20
|
# @return [String]
|
@@ -22,7 +23,7 @@ module GraphQL
|
|
22
23
|
end
|
23
24
|
|
24
25
|
# @param str_value [String, Date, DateTime, Time]
|
25
|
-
# @return [Date]
|
26
|
+
# @return [Date, nil]
|
26
27
|
def self.coerce_input(value, ctx)
|
27
28
|
if value.is_a?(::Date)
|
28
29
|
value
|
@@ -30,6 +31,8 @@ module GraphQL
|
|
30
31
|
value.to_date
|
31
32
|
elsif value.is_a?(::Time)
|
32
33
|
value.to_date
|
34
|
+
elsif value.nil?
|
35
|
+
nil
|
33
36
|
else
|
34
37
|
Date.iso8601(value)
|
35
38
|
end
|
@@ -17,6 +17,7 @@ module GraphQL
|
|
17
17
|
# own DateTime type.
|
18
18
|
class ISO8601DateTime < GraphQL::Schema::Scalar
|
19
19
|
description "An ISO 8601-encoded datetime"
|
20
|
+
specified_by_url "https://tools.ietf.org/html/rfc3339"
|
20
21
|
|
21
22
|
# It's not compatible with Rails' default,
|
22
23
|
# i.e. ActiveSupport::JSON::Encoder.time_precision (3 by default)
|
data/lib/graphql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|