graphql 1.5.14 → 1.5.15

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
  SHA1:
3
- metadata.gz: 52c3a037cffdd261304a07f17e427b35de5d7806
4
- data.tar.gz: '081c7064bb76ddb0b3829a4efb3f0c3c6a91337c'
3
+ metadata.gz: 75e66219aaa22753f69fb7bef629535bd80e987e
4
+ data.tar.gz: dac5274307d3d472f739daf07c9daca74f010af4
5
5
  SHA512:
6
- metadata.gz: e579bc6f36376d75b2760de68da8dd7d22623993977d295d6656021dda740a02df6241e32c04c71ff2c18963b16a183c3f3dc286628ca414a800d3d619bc0947
7
- data.tar.gz: 90096a42e99d15a6a492b93a8ebb65bf01bf213335950c8c13274f356715ab1fac8958b06dc562f6a0dae857ffabdb2c9976f0b43eec741aa449925f32107071
6
+ metadata.gz: 5161c7c97fc9ffe14db133ad61099addfea4ccf94eba8bc0f2ff56e1e6cb541740018fed81644292915a76ccebd9640f2b22d7a81fb3a41d60c6a7a377b45a9a
7
+ data.tar.gz: 4ec7454191f5c7bf67aef5459bcfaeae1184c5968265a5f15b3e453827586b9a61d9783059aefcfc3df6285dec3ca7eb2445399123f9c9fee26012fb5a9621f2
@@ -3,9 +3,26 @@ require "delegate"
3
3
  require "json"
4
4
  require "set"
5
5
  require "singleton"
6
- require "forwardable"
7
6
 
8
7
  module GraphQL
8
+ # Ruby stdlib was pretty busted until this fix:
9
+ # https://github.com/ruby/ruby/commit/46c0e79bb5b96c45c166ef62f8e585f528862abb#diff-43adf0e587a50dbaf51764a262008d40
10
+ module Delegate
11
+ def def_delegators(accessor, *method_names)
12
+ method_names.each do |method_name|
13
+ class_eval <<-RUBY
14
+ def #{method_name}(*args)
15
+ if block_given?
16
+ #{accessor}.#{method_name}(*args, &Proc.new)
17
+ else
18
+ #{accessor}.#{method_name}(*args)
19
+ end
20
+ end
21
+ RUBY
22
+ end
23
+ end
24
+ end
25
+
9
26
  class Error < StandardError
10
27
  end
11
28
 
@@ -70,7 +70,7 @@ module GraphQL
70
70
  # Find the maximum possible complexity among those combinations.
71
71
  class TypeComplexity
72
72
  def initialize
73
- @types = Hash.new { |h, k| h[k] = 0 }
73
+ @types = Hash.new(0)
74
74
  end
75
75
 
76
76
  # Return the max possible complexity for types in this selection
@@ -40,9 +40,9 @@ module GraphQL
40
40
  end
41
41
 
42
42
  # @return [Lazy] A {Lazy} whose value depends on another {Lazy}, plus any transformations in `block`
43
- def then(&block)
43
+ def then
44
44
  self.class.new {
45
- block.call(value)
45
+ yield(value)
46
46
  }
47
47
  end
48
48
  end
@@ -14,8 +14,10 @@ module GraphQL
14
14
 
15
15
  def self.resolve_in_place(value)
16
16
  lazies = []
17
+ acc = []
18
+ each_lazy(acc, value)
17
19
 
18
- each_lazy(value) do |field_result|
20
+ acc.each do |field_result|
19
21
  inner_lazy = field_result.value.then do |inner_v|
20
22
  field_result.value = inner_v
21
23
  resolve_in_place(inner_v)
@@ -26,25 +28,26 @@ module GraphQL
26
28
  Lazy.new { lazies.map(&:value) }
27
29
  end
28
30
 
29
- # If `value` is a collection, call `block`
30
- # with any {Lazy} instances in the collection
31
+ # If `value` is a collection,
32
+ # add any {Lazy} instances in the collection
33
+ # to `acc`
31
34
  # @return [void]
32
- def self.each_lazy(value, &block)
35
+ def self.each_lazy(acc, value)
33
36
  case value
34
37
  when SelectionResult
35
38
  value.each do |key, field_result|
36
- each_lazy(field_result, &block)
39
+ each_lazy(acc, field_result)
37
40
  end
38
41
  when Array
39
42
  value.each do |field_result|
40
- each_lazy(field_result, &block)
43
+ each_lazy(acc, field_result)
41
44
  end
42
45
  when FieldResult
43
46
  field_value = value.value
44
47
  if field_value.is_a?(Lazy)
45
- yield(value)
48
+ acc << value
46
49
  else
47
- each_lazy(field_value, &block)
50
+ each_lazy(acc, field_value)
48
51
  end
49
52
  end
50
53
  end
@@ -2,6 +2,8 @@
2
2
  module GraphQL
3
3
  module InternalRepresentation
4
4
  class Node
5
+ # @api private
6
+ DEFAULT_TYPED_CHILDREN = Proc.new { |h, k| h[k] = {} }
5
7
  # @return [String] the name this node has in the response
6
8
  attr_reader :name
7
9
 
@@ -15,7 +17,7 @@ module GraphQL
15
17
  # @return [Hash<GraphQL::ObjectType, Hash<String => Node>>]
16
18
  def typed_children
17
19
  @typed_childen ||= begin
18
- new_tc = Hash.new { |h, k| h[k] = {} }
20
+ new_tc = Hash.new(&DEFAULT_TYPED_CHILDREN)
19
21
  if @scoped_children.any?
20
22
  all_object_types = Set.new
21
23
  scoped_children.each_key { |t| all_object_types.merge(@query.possible_types(t)) }
@@ -14,7 +14,7 @@ require "graphql/query/validation_pipeline"
14
14
  module GraphQL
15
15
  # A combination of query string and {Schema} instance which can be reduced to a {#result}.
16
16
  class Query
17
- extend Forwardable
17
+ extend GraphQL::Delegate
18
18
 
19
19
  class OperationNameMissingError < GraphQL::ExecutionError
20
20
  def initialize(name)
@@ -5,7 +5,7 @@ module GraphQL
5
5
  #
6
6
  # {Arguments} recursively wraps the input in {Arguments} instances.
7
7
  class Arguments
8
- extend Forwardable
8
+ extend GraphQL::Delegate
9
9
 
10
10
  def initialize(values, argument_definitions:)
11
11
  @original_values = values
@@ -22,13 +22,15 @@ module GraphQL
22
22
  # @param key [String, Symbol] name or index of value to access
23
23
  # @return [Object] the argument at that key
24
24
  def [](key)
25
- @argument_values.fetch(key.to_s, NULL_ARGUMENT_VALUE).value
25
+ key_s = key.is_a?(String) ? key : key.to_s
26
+ @argument_values.fetch(key_s, NULL_ARGUMENT_VALUE).value
26
27
  end
27
28
 
28
29
  # @param key [String, Symbol] name of value to access
29
30
  # @return [Boolean] true if the argument was present in this field
30
31
  def key?(key)
31
- @argument_values.key?(key.to_s)
32
+ key_s = key.is_a?(String) ? key : key.to_s
33
+ @argument_values.key?(key_s)
32
34
  end
33
35
 
34
36
  # Get the original Ruby hash
@@ -5,11 +5,14 @@ module GraphQL
5
5
  # @return [Hash<InternalRepresentation::Node, GraphQL::Language::NodesDirectiveNode => Hash<GraphQL::Field, GraphQL::Directive => GraphQL::Query::Arguments>>]
6
6
  def self.build(query)
7
7
  Hash.new do |h1, irep_or_ast_node|
8
- Hash.new do |h2, definition|
8
+ h1[irep_or_ast_node] = Hash.new do |h2, definition|
9
9
  ast_node = irep_or_ast_node.is_a?(GraphQL::InternalRepresentation::Node) ? irep_or_ast_node.ast_node : irep_or_ast_node
10
10
  ast_arguments = ast_node.arguments
11
- if ast_arguments.none?
12
- definition.default_arguments
11
+
12
+ h2[definition] = if ast_arguments.none?
13
+ definition.default_arguments
14
+ elsif definition.arguments.none?
15
+ GraphQL::Query::Arguments::NO_ARGS
13
16
  else
14
17
  GraphQL::Query::LiteralInput.from_arguments(
15
18
  ast_arguments,
@@ -72,7 +72,7 @@ module GraphQL
72
72
  end
73
73
 
74
74
  class FieldResolutionContext
75
- extend Forwardable
75
+ extend GraphQL::Delegate
76
76
 
77
77
  attr_reader :path, :selection, :field, :parent_type
78
78
 
@@ -3,7 +3,7 @@ module GraphQL
3
3
  class Query
4
4
  # Read-only access to query variables, applying default values if needed.
5
5
  class Variables
6
- extend Forwardable
6
+ extend GraphQL::Delegate
7
7
 
8
8
  # @return [Array<GraphQL::Query::VariableValidationError>] Any errors encountered when parsing the provided variables and literal values
9
9
  attr_reader :errors
@@ -26,16 +26,14 @@ module GraphQL
26
26
  # @return [subclass of BaseConnection] a connection Class for wrapping `nodes`
27
27
  def connection_for_nodes(nodes)
28
28
  # Check for class _names_ because classes can be redefined in Rails development
29
- ancestor_names = nodes.class.ancestors.map(&:name)
30
- implementation_class_name = ancestor_names.find do |ancestor_class_name|
31
- CONNECTION_IMPLEMENTATIONS.include? ancestor_class_name
32
- end
33
-
34
- if implementation_class_name.nil?
35
- raise("No connection implementation to wrap #{nodes.class} (#{nodes})")
36
- else
37
- CONNECTION_IMPLEMENTATIONS[implementation_class_name]
29
+ nodes.class.ancestors.each do |ancestor|
30
+ conn_impl = CONNECTION_IMPLEMENTATIONS[ancestor.name]
31
+ if conn_impl
32
+ return conn_impl
33
+ end
38
34
  end
35
+ # Should have found a connection during the loop:
36
+ raise("No connection implementation to wrap #{nodes.class} (#{nodes})")
39
37
  end
40
38
 
41
39
  # Add `connection_class` as the connection wrapper for `nodes_class`
@@ -5,7 +5,7 @@ module GraphQL
5
5
  #
6
6
  # Steps should call `next_step.call` to continue the chain, or _not_ call it to stop the chain.
7
7
  class MiddlewareChain
8
- extend Forwardable
8
+ extend GraphQL::Delegate
9
9
 
10
10
  # @return [Array<#call(*args)>] Steps in this chain, will be called with arguments and `next_middleware`
11
11
  attr_reader :steps, :final_step
@@ -8,7 +8,7 @@ module GraphQL
8
8
  #
9
9
  # If you want a type, but want to handle the undefined case, use {#fetch}.
10
10
  class TypeMap
11
- extend Forwardable
11
+ extend GraphQL::Delegate
12
12
  def_delegators :@storage, :key?, :keys, :values, :to_h, :fetch, :each, :each_value
13
13
 
14
14
  def initialize
@@ -103,7 +103,7 @@ module GraphQL
103
103
  end
104
104
 
105
105
  class NodeWithPath
106
- extend Forwardable
106
+ extend GraphQL::Delegate
107
107
  attr_reader :node, :path
108
108
  def initialize(node, path)
109
109
  @node = node
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.5.14"
3
+ VERSION = "1.5.15"
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: 1.5.14
4
+ version: 1.5.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-27 00:00:00.000000000 Z
11
+ date: 2017-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips