graphql 2.0.5 → 2.0.6

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: 248d39942011f4175ee77643a6e8d103d17d60ac73ee95418eb25e0eee2bbb27
4
- data.tar.gz: 062c4d1402adf7f3612d888c6e00df91623340239996b6bc14db59ebbec41814
3
+ metadata.gz: c31ecaae04f8ea6bca65c031a2a41d124d8a1e1dade016decfb047cae3f900ae
4
+ data.tar.gz: af77a6ac50b38ca0d23a08da8f63fea1ca8f14ef11ccda56de55e678518380c1
5
5
  SHA512:
6
- metadata.gz: 87813bc8354e52215099b99f932b615856337649897313982e7945b9f039625fd4a788a1edba62faf4f6ee8438d87feafe39b374504561726fd7b9b5f5959d0d
7
- data.tar.gz: d58627c8387a891814bf5a362a23035f9c58f2b5959fe3857afdec66cac7a2944601cfa03311c3791cc18038fd4a1c4faf5dd1793c54b9bbab1d2bd487e4b140
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 `--no-graphiql` to skip `graphiql-rails` installation.
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
@@ -27,7 +27,7 @@ module GraphQL
27
27
  end
28
28
  field :of_type, GraphQL::Schema::LateBoundType.new("__Type")
29
29
 
30
- field :specified_by_url, String
30
+ field :specifiedByURL, String, resolver_method: :specified_by_url
31
31
 
32
32
  def specified_by_url
33
33
  if object.kind.scalar?
@@ -29,7 +29,7 @@ fragment FullType on __Type {
29
29
  kind
30
30
  name
31
31
  description
32
- #{include_specified_by_url ? "specifiedByUrl" : ""}
32
+ #{include_specified_by_url ? "specifiedByURL" : ""}
33
33
  fields(includeDeprecated: true) {
34
34
  name
35
35
  description
@@ -35,9 +35,11 @@ module GraphQL
35
35
  def load_nodes
36
36
  @nodes ||= begin
37
37
  sliced_nodes = if before && after
38
- items[index_from_cursor(after)..index_from_cursor(before)-1] || []
38
+ end_idx = index_from_cursor(before)-1
39
+ end_idx < 0 ? [] : items[index_from_cursor(after)..end_idx] || []
39
40
  elsif before
40
- items[0..index_from_cursor(before)-2] || []
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
@@ -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
- # TODO: I think non-string/symbol hash keys are wrongly normalized (eg `1` will not work)
247
- method_name = method || hash_key || name_s
249
+ method_name = method || name_s
248
250
  @dig_keys = dig
249
- resolver_method ||= name_s.to_sym
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
- # Find a way to resolve this field, checking:
639
- #
640
- # - A method on the type instance;
641
- # - Hash keys, if the wrapped object is a hash;
642
- # - A method on the wrapped object;
643
- # - Or, raise not implemented.
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 obj.object.is_a?(Hash)
655
- inner_object = obj.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 obj.object.respond_to?(@method_sym)
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
- obj.object.public_send(@method_sym, **ruby_kwargs)
665
+ inner_object.public_send(@method_sym, **ruby_kwargs)
668
666
  else
669
- obj.object.public_send(@method_sym)
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
- - `#{obj.object.class}##{@method_sym}`, which did not exist
677
- - Looking up hash key `#{@method_sym.inspect}` or `#{@method_str.inspect}` on `#{obj.object}`, but it wasn't a Hash
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
@@ -142,7 +142,7 @@ module GraphQL
142
142
  Class.new(GraphQL::Schema::Scalar) do
143
143
  graphql_name(type["name"])
144
144
  description(type["description"])
145
- specified_by_url(type["specifiedByUrl"])
145
+ specified_by_url(type["specifiedByURL"])
146
146
  end
147
147
  end
148
148
  when "UNION"
@@ -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, {...}]`): [#{authorized_result.inspect}, #{ready_early_return.inspect}]"
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
@@ -932,6 +932,7 @@ module GraphQL
932
932
  {
933
933
  backtrace: ctx[:backtrace],
934
934
  tracers: ctx[:tracers],
935
+ dataloader: ctx[:dataloader],
935
936
  }
936
937
  else
937
938
  {}
@@ -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)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.0.5"
3
+ VERSION = "2.0.6"
4
4
  end
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.5
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-03-28 00:00:00.000000000 Z
11
+ date: 2022-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips