graphql 1.5.14 → 1.5.15
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 +4 -4
- data/lib/graphql.rb +18 -1
- data/lib/graphql/analysis/query_complexity.rb +1 -1
- data/lib/graphql/execution/lazy.rb +2 -2
- data/lib/graphql/execution/lazy/resolve.rb +11 -8
- data/lib/graphql/internal_representation/node.rb +3 -1
- data/lib/graphql/query.rb +1 -1
- data/lib/graphql/query/arguments.rb +5 -3
- data/lib/graphql/query/arguments_cache.rb +6 -3
- data/lib/graphql/query/context.rb +1 -1
- data/lib/graphql/query/variables.rb +1 -1
- data/lib/graphql/relay/base_connection.rb +7 -9
- data/lib/graphql/schema/middleware_chain.rb +1 -1
- data/lib/graphql/schema/type_map.rb +1 -1
- data/lib/graphql/static_validation/definition_dependencies.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75e66219aaa22753f69fb7bef629535bd80e987e
|
4
|
+
data.tar.gz: dac5274307d3d472f739daf07c9daca74f010af4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5161c7c97fc9ffe14db133ad61099addfea4ccf94eba8bc0f2ff56e1e6cb541740018fed81644292915a76ccebd9640f2b22d7a81fb3a41d60c6a7a377b45a9a
|
7
|
+
data.tar.gz: 4ec7454191f5c7bf67aef5459bcfaeae1184c5968265a5f15b3e453827586b9a61d9783059aefcfc3df6285dec3ca7eb2445399123f9c9fee26012fb5a9621f2
|
data/lib/graphql.rb
CHANGED
@@ -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
|
73
|
+
@types = Hash.new(0)
|
74
74
|
end
|
75
75
|
|
76
76
|
# Return the max possible complexity for types in this selection
|
@@ -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
|
-
|
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,
|
30
|
-
#
|
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(
|
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(
|
39
|
+
each_lazy(acc, field_result)
|
37
40
|
end
|
38
41
|
when Array
|
39
42
|
value.each do |field_result|
|
40
|
-
each_lazy(
|
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
|
-
|
48
|
+
acc << value
|
46
49
|
else
|
47
|
-
each_lazy(
|
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
|
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)) }
|
data/lib/graphql/query.rb
CHANGED
@@ -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
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
12
|
-
|
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,
|
@@ -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
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
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
|
11
|
+
extend GraphQL::Delegate
|
12
12
|
def_delegators :@storage, :key?, :keys, :values, :to_h, :fetch, :each, :each_value
|
13
13
|
|
14
14
|
def initialize
|
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: 1.5.
|
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-
|
11
|
+
date: 2017-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|