graphql 1.13.10 → 2.0.2
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/analysis/ast/max_query_complexity.rb +0 -1
- data/lib/graphql/analysis/ast/query_complexity.rb +1 -1
- data/lib/graphql/analysis/ast/query_depth.rb +0 -1
- data/lib/graphql/analysis/ast/visitor.rb +1 -1
- data/lib/graphql/analysis/ast.rb +0 -10
- data/lib/graphql/analysis.rb +0 -7
- data/lib/graphql/backtrace/table.rb +0 -18
- data/lib/graphql/backtrace/tracer.rb +1 -2
- data/lib/graphql/backtrace.rb +2 -8
- data/lib/graphql/dataloader/null_dataloader.rb +3 -1
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/errors.rb +1 -9
- data/lib/graphql/execution/interpreter/runtime.rb +17 -31
- data/lib/graphql/execution/interpreter.rb +0 -22
- data/lib/graphql/execution/lazy.rb +1 -1
- data/lib/graphql/execution/lookahead.rb +6 -13
- data/lib/graphql/execution/multiplex.rb +50 -107
- data/lib/graphql/execution.rb +11 -3
- data/lib/graphql/introspection/dynamic_fields.rb +3 -8
- data/lib/graphql/introspection/entry_points.rb +2 -15
- data/lib/graphql/language/document_from_schema_definition.rb +0 -17
- data/lib/graphql/pagination/connections.rb +2 -28
- data/lib/graphql/query/context.rb +97 -194
- data/lib/graphql/query/input_validation_result.rb +10 -1
- data/lib/graphql/query/validation_pipeline.rb +8 -37
- data/lib/graphql/query/variables.rb +22 -18
- data/lib/graphql/query.rb +5 -36
- data/lib/graphql/railtie.rb +0 -104
- data/lib/graphql/relay.rb +0 -15
- data/lib/graphql/schema/addition.rb +1 -8
- data/lib/graphql/schema/argument.rb +5 -26
- data/lib/graphql/schema/build_from_definition.rb +0 -1
- data/lib/graphql/schema/directive.rb +0 -21
- data/lib/graphql/schema/enum.rb +4 -23
- data/lib/graphql/schema/enum_value.rb +0 -22
- data/lib/graphql/schema/field.rb +70 -230
- data/lib/graphql/schema/input_object.rb +21 -68
- data/lib/graphql/schema/interface.rb +0 -25
- data/lib/graphql/schema/introspection_system.rb +3 -8
- data/lib/graphql/schema/late_bound_type.rb +2 -2
- data/lib/graphql/schema/list.rb +2 -7
- data/lib/graphql/schema/loader.rb +0 -1
- data/lib/graphql/schema/member/base_dsl_methods.rb +0 -5
- data/lib/graphql/schema/member/build_type.rb +4 -6
- data/lib/graphql/schema/member/has_arguments.rb +50 -24
- data/lib/graphql/schema/member/has_fields.rb +2 -2
- data/lib/graphql/schema/member/has_interfaces.rb +1 -3
- data/lib/graphql/schema/member/validates_input.rb +2 -2
- data/lib/graphql/schema/member.rb +0 -6
- data/lib/graphql/schema/mutation.rb +0 -9
- data/lib/graphql/schema/non_null.rb +1 -7
- data/lib/graphql/schema/object.rb +7 -42
- data/lib/graphql/schema/relay_classic_mutation.rb +49 -42
- data/lib/graphql/schema/resolver/has_payload_type.rb +11 -1
- data/lib/graphql/schema/resolver.rb +23 -45
- data/lib/graphql/schema/scalar.rb +4 -19
- data/lib/graphql/schema/subscription.rb +0 -7
- data/lib/graphql/schema/union.rb +0 -16
- data/lib/graphql/schema/warden.rb +2 -2
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +106 -944
- data/lib/graphql/static_validation/base_visitor.rb +4 -21
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +12 -12
- data/lib/graphql/static_validation/validator.rb +2 -24
- data/lib/graphql/static_validation.rb +0 -2
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +38 -1
- data/lib/graphql/subscriptions/event.rb +1 -1
- data/lib/graphql/subscriptions/instrumentation.rb +0 -51
- data/lib/graphql/subscriptions.rb +14 -16
- data/lib/graphql/tracing/platform_tracing.rb +0 -23
- data/lib/graphql/tracing.rb +0 -1
- data/lib/graphql/types/relay/connection_behaviors.rb +2 -6
- data/lib/graphql/types/relay/default_relay.rb +0 -10
- data/lib/graphql/types/relay/node_behaviors.rb +5 -1
- data/lib/graphql/types/relay.rb +0 -2
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +1 -65
- metadata +2 -128
- data/lib/graphql/analysis/analyze_query.rb +0 -98
- data/lib/graphql/analysis/field_usage.rb +0 -45
- data/lib/graphql/analysis/max_query_complexity.rb +0 -26
- data/lib/graphql/analysis/max_query_depth.rb +0 -26
- data/lib/graphql/analysis/query_complexity.rb +0 -88
- data/lib/graphql/analysis/query_depth.rb +0 -43
- data/lib/graphql/analysis/reducer_state.rb +0 -48
- data/lib/graphql/argument.rb +0 -131
- data/lib/graphql/authorization.rb +0 -82
- data/lib/graphql/backtrace/legacy_tracer.rb +0 -56
- data/lib/graphql/backwards_compatibility.rb +0 -61
- data/lib/graphql/base_type.rb +0 -232
- data/lib/graphql/boolean_type.rb +0 -2
- data/lib/graphql/compatibility/execution_specification/counter_schema.rb +0 -53
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +0 -200
- data/lib/graphql/compatibility/execution_specification.rb +0 -436
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
- data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -215
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -87
- data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -266
- data/lib/graphql/compatibility/schema_parser_specification.rb +0 -682
- data/lib/graphql/compatibility.rb +0 -5
- data/lib/graphql/define/assign_argument.rb +0 -12
- data/lib/graphql/define/assign_connection.rb +0 -13
- data/lib/graphql/define/assign_enum_value.rb +0 -18
- data/lib/graphql/define/assign_global_id_field.rb +0 -11
- data/lib/graphql/define/assign_mutation_function.rb +0 -34
- data/lib/graphql/define/assign_object_field.rb +0 -42
- data/lib/graphql/define/defined_object_proxy.rb +0 -53
- data/lib/graphql/define/instance_definable.rb +0 -240
- data/lib/graphql/define/no_definition_error.rb +0 -7
- data/lib/graphql/define/non_null_with_bang.rb +0 -16
- data/lib/graphql/define/type_definer.rb +0 -31
- data/lib/graphql/define.rb +0 -31
- data/lib/graphql/deprecated_dsl.rb +0 -55
- data/lib/graphql/directive/deprecated_directive.rb +0 -2
- data/lib/graphql/directive/include_directive.rb +0 -2
- data/lib/graphql/directive/skip_directive.rb +0 -2
- data/lib/graphql/directive.rb +0 -107
- data/lib/graphql/enum_type.rb +0 -133
- data/lib/graphql/execution/execute.rb +0 -333
- data/lib/graphql/execution/flatten.rb +0 -40
- data/lib/graphql/execution/typecast.rb +0 -50
- data/lib/graphql/field/resolve.rb +0 -59
- data/lib/graphql/field.rb +0 -226
- data/lib/graphql/float_type.rb +0 -2
- data/lib/graphql/function.rb +0 -128
- data/lib/graphql/id_type.rb +0 -2
- data/lib/graphql/input_object_type.rb +0 -138
- data/lib/graphql/int_type.rb +0 -2
- data/lib/graphql/interface_type.rb +0 -72
- data/lib/graphql/internal_representation/document.rb +0 -27
- data/lib/graphql/internal_representation/node.rb +0 -206
- data/lib/graphql/internal_representation/print.rb +0 -51
- data/lib/graphql/internal_representation/rewrite.rb +0 -184
- data/lib/graphql/internal_representation/scope.rb +0 -88
- data/lib/graphql/internal_representation/visit.rb +0 -36
- data/lib/graphql/internal_representation.rb +0 -7
- data/lib/graphql/list_type.rb +0 -80
- data/lib/graphql/non_null_type.rb +0 -71
- data/lib/graphql/object_type.rb +0 -130
- data/lib/graphql/query/arguments.rb +0 -189
- data/lib/graphql/query/arguments_cache.rb +0 -24
- data/lib/graphql/query/executor.rb +0 -52
- data/lib/graphql/query/literal_input.rb +0 -136
- data/lib/graphql/query/serial_execution/field_resolution.rb +0 -92
- data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -19
- data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -23
- data/lib/graphql/query/serial_execution/value_resolution.rb +0 -87
- data/lib/graphql/query/serial_execution.rb +0 -40
- data/lib/graphql/relay/array_connection.rb +0 -83
- data/lib/graphql/relay/base_connection.rb +0 -189
- data/lib/graphql/relay/connection_instrumentation.rb +0 -54
- data/lib/graphql/relay/connection_resolve.rb +0 -43
- data/lib/graphql/relay/connection_type.rb +0 -54
- data/lib/graphql/relay/edge.rb +0 -27
- data/lib/graphql/relay/edge_type.rb +0 -19
- data/lib/graphql/relay/edges_instrumentation.rb +0 -39
- data/lib/graphql/relay/global_id_resolve.rb +0 -17
- data/lib/graphql/relay/mongo_relation_connection.rb +0 -50
- data/lib/graphql/relay/mutation/instrumentation.rb +0 -23
- data/lib/graphql/relay/mutation/resolve.rb +0 -56
- data/lib/graphql/relay/mutation/result.rb +0 -38
- data/lib/graphql/relay/mutation.rb +0 -106
- data/lib/graphql/relay/node.rb +0 -39
- data/lib/graphql/relay/page_info.rb +0 -7
- data/lib/graphql/relay/relation_connection.rb +0 -188
- data/lib/graphql/relay/type_extensions.rb +0 -32
- data/lib/graphql/scalar_type.rb +0 -91
- data/lib/graphql/schema/catchall_middleware.rb +0 -35
- data/lib/graphql/schema/default_parse_error.rb +0 -10
- data/lib/graphql/schema/default_type_error.rb +0 -17
- data/lib/graphql/schema/member/accepts_definition.rb +0 -164
- data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -58
- data/lib/graphql/schema/member/instrumentation.rb +0 -131
- data/lib/graphql/schema/middleware_chain.rb +0 -82
- data/lib/graphql/schema/possible_types.rb +0 -44
- data/lib/graphql/schema/rescue_middleware.rb +0 -60
- data/lib/graphql/schema/timeout_middleware.rb +0 -88
- data/lib/graphql/schema/traversal.rb +0 -228
- data/lib/graphql/schema/validation.rb +0 -313
- data/lib/graphql/static_validation/default_visitor.rb +0 -15
- data/lib/graphql/static_validation/no_validate_visitor.rb +0 -10
- data/lib/graphql/string_type.rb +0 -2
- data/lib/graphql/subscriptions/subscription_root.rb +0 -76
- data/lib/graphql/tracing/skylight_tracing.rb +0 -70
- data/lib/graphql/types/relay/node_field.rb +0 -24
- data/lib/graphql/types/relay/nodes_field.rb +0 -43
- data/lib/graphql/union_type.rb +0 -115
- data/lib/graphql/upgrader/member.rb +0 -937
- data/lib/graphql/upgrader/schema.rb +0 -38
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 445a61081bd654dbd59e1d6472e027958f8f88bcb5b3f32351921c5f24f7c572
|
|
4
|
+
data.tar.gz: d33ff0a628621fe4ccb4e19fbf727ce1e2cffe950697b33bc3682420bb6d2a81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5d2f6f4c7556db47fec205db4007958f397e8a6b25c40a1838cf0789bf5e71162b0fe62305cb703ec5d5e61371513e978e9544a2f8622787c488d1fbad547af2
|
|
7
|
+
data.tar.gz: c477b6a6c782e0bd5ef1eec47fc5dc6fa4ff56d21352c4ee1f6783debd8506c52cf6eace82c639166033b02436d4eebf5a18116624ad7ffd62d19ed8c5735dc0
|
|
@@ -5,7 +5,7 @@ module GraphQL
|
|
|
5
5
|
module AST
|
|
6
6
|
class QueryComplexity < Analyzer
|
|
7
7
|
# State for the query complexity calculation:
|
|
8
|
-
# - `complexities_on_type` holds complexity scores for each type
|
|
8
|
+
# - `complexities_on_type` holds complexity scores for each type
|
|
9
9
|
def initialize(query)
|
|
10
10
|
super
|
|
11
11
|
@complexities_on_type_by_query = {}
|
|
@@ -43,7 +43,7 @@ module GraphQL
|
|
|
43
43
|
|
|
44
44
|
# Visit Helpers
|
|
45
45
|
|
|
46
|
-
# @return [GraphQL::
|
|
46
|
+
# @return [GraphQL::Execution::Interpreter::Arguments] Arguments for this node, merging default values, literal values and query variables
|
|
47
47
|
# @see {GraphQL::Query#arguments_for}
|
|
48
48
|
def arguments_for(ast_node, field_definition)
|
|
49
49
|
@query.arguments_for(ast_node, field_definition)
|
data/lib/graphql/analysis/ast.rb
CHANGED
|
@@ -11,16 +11,6 @@ module GraphQL
|
|
|
11
11
|
module Analysis
|
|
12
12
|
module AST
|
|
13
13
|
module_function
|
|
14
|
-
|
|
15
|
-
def use(schema_class)
|
|
16
|
-
if schema_class.analysis_engine == self
|
|
17
|
-
definition_line = caller(2, 1).first
|
|
18
|
-
GraphQL::Deprecation.warn("GraphQL::Analysis::AST is now the default; remove `use GraphQL::Analysis::AST` from the schema definition (#{definition_line})")
|
|
19
|
-
else
|
|
20
|
-
schema_class.analysis_engine = self
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
14
|
# Analyze a multiplex, and all queries within.
|
|
25
15
|
# Multiplex analyzers are ran for all queries, keeping state.
|
|
26
16
|
# Query analyzers are ran per query, without carrying state between queries.
|
data/lib/graphql/analysis.rb
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
require "graphql/analysis/ast"
|
|
3
|
-
require "graphql/analysis/max_query_complexity"
|
|
4
|
-
require "graphql/analysis/max_query_depth"
|
|
5
|
-
require "graphql/analysis/query_complexity"
|
|
6
|
-
require "graphql/analysis/query_depth"
|
|
7
|
-
require "graphql/analysis/reducer_state"
|
|
8
|
-
require "graphql/analysis/analyze_query"
|
|
9
|
-
require "graphql/analysis/field_usage"
|
|
@@ -97,24 +97,6 @@ module GraphQL
|
|
|
97
97
|
else
|
|
98
98
|
rows
|
|
99
99
|
end
|
|
100
|
-
when GraphQL::Query::Context::FieldResolutionContext
|
|
101
|
-
ctx = context_entry
|
|
102
|
-
field_name = "#{ctx.irep_node.owner_type.name}.#{ctx.field.name}"
|
|
103
|
-
position = "#{ctx.ast_node.line}:#{ctx.ast_node.col}"
|
|
104
|
-
field_alias = ctx.ast_node.alias
|
|
105
|
-
object = ctx.object
|
|
106
|
-
if object.is_a?(GraphQL::Schema::Object)
|
|
107
|
-
object = object.object
|
|
108
|
-
end
|
|
109
|
-
rows << [
|
|
110
|
-
"#{position}",
|
|
111
|
-
"#{field_name}#{field_alias ? " as #{field_alias}" : ""}",
|
|
112
|
-
"#{object.inspect}",
|
|
113
|
-
ctx.irep_node.arguments.to_h.inspect,
|
|
114
|
-
Backtrace::InspectResult.inspect_result(top && @override_value ? @override_value : ctx.value),
|
|
115
|
-
]
|
|
116
|
-
|
|
117
|
-
build_rows(ctx.parent, rows: rows)
|
|
118
100
|
when GraphQL::Query::Context
|
|
119
101
|
query = context_entry.query
|
|
120
102
|
op = query.selected_operation
|
|
@@ -23,7 +23,7 @@ module GraphQL
|
|
|
23
23
|
push_data = multiplex.queries.first
|
|
24
24
|
end
|
|
25
25
|
when "execute_field", "execute_field_lazy"
|
|
26
|
-
query = metadata[:query]
|
|
26
|
+
query = metadata[:query]
|
|
27
27
|
multiplex = query.multiplex
|
|
28
28
|
push_key = metadata[:path]
|
|
29
29
|
parent_frame = multiplex.context[:graphql_backtrace_contexts][push_key[0..-2]]
|
|
@@ -62,7 +62,6 @@ module GraphQL
|
|
|
62
62
|
potential_context = multiplex_context[:last_graphql_backtrace_context]
|
|
63
63
|
|
|
64
64
|
if potential_context.is_a?(GraphQL::Query::Context) ||
|
|
65
|
-
potential_context.is_a?(GraphQL::Query::Context::FieldResolutionContext) ||
|
|
66
65
|
potential_context.is_a?(Backtrace::Frame)
|
|
67
66
|
raise TracedError.new(err, potential_context)
|
|
68
67
|
else
|
data/lib/graphql/backtrace.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
require "graphql/backtrace/inspect_result"
|
|
3
|
-
require "graphql/backtrace/legacy_tracer"
|
|
4
3
|
require "graphql/backtrace/table"
|
|
5
4
|
require "graphql/backtrace/traced_error"
|
|
6
5
|
require "graphql/backtrace/tracer"
|
|
@@ -23,13 +22,8 @@ module GraphQL
|
|
|
23
22
|
|
|
24
23
|
def_delegators :to_a, :each, :[]
|
|
25
24
|
|
|
26
|
-
def self.use(schema_defn
|
|
27
|
-
tracer
|
|
28
|
-
self::LegacyTracer
|
|
29
|
-
else
|
|
30
|
-
self::Tracer
|
|
31
|
-
end
|
|
32
|
-
schema_defn.tracer(tracer)
|
|
25
|
+
def self.use(schema_defn)
|
|
26
|
+
schema_defn.tracer(self::Tracer)
|
|
33
27
|
end
|
|
34
28
|
|
|
35
29
|
def initialize(context, value: nil)
|
|
@@ -11,7 +11,9 @@ module GraphQL
|
|
|
11
11
|
# executed sychronously.
|
|
12
12
|
def run; end
|
|
13
13
|
def run_isolated; yield; end
|
|
14
|
-
def yield
|
|
14
|
+
def yield
|
|
15
|
+
raise GraphQL::Error, "GraphQL::Dataloader is not running -- add `use GraphQL::Dataloader` to your schema to use Dataloader sources."
|
|
16
|
+
end
|
|
15
17
|
|
|
16
18
|
def append_job
|
|
17
19
|
yield
|
data/lib/graphql/dig.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
module GraphQL
|
|
3
3
|
module Dig
|
|
4
4
|
# implemented using the old activesupport #dig instead of the ruby built-in
|
|
5
|
-
# so we can use some of the magic in Schema::InputObject and
|
|
5
|
+
# so we can use some of the magic in Schema::InputObject and Interpreter::Arguments
|
|
6
6
|
# to handle stringified/symbolized keys.
|
|
7
7
|
#
|
|
8
8
|
# @param args [Array<[String, Symbol>] Retrieves the value object corresponding to the each key objects repeatedly
|
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
module GraphQL
|
|
4
4
|
module Execution
|
|
5
|
-
# A plugin that wraps query execution with error handling.
|
|
6
|
-
# Supports class-based schemas and the new {Interpreter} runtime only.
|
|
5
|
+
# A plugin that wraps query execution with error handling. Installed by default.
|
|
7
6
|
#
|
|
8
7
|
# @example Handling ActiveRecord::NotFound
|
|
9
8
|
#
|
|
10
9
|
# class MySchema < GraphQL::Schema
|
|
11
|
-
# use GraphQL::Execution::Errors
|
|
12
|
-
#
|
|
13
10
|
# rescue_from(ActiveRecord::NotFound) do |err, obj, args, ctx, field|
|
|
14
11
|
# ErrorTracker.log("Not Found: #{err.message}")
|
|
15
12
|
# nil
|
|
@@ -17,11 +14,6 @@ module GraphQL
|
|
|
17
14
|
# end
|
|
18
15
|
#
|
|
19
16
|
class Errors
|
|
20
|
-
def self.use(schema)
|
|
21
|
-
definition_line = caller(2, 1).first
|
|
22
|
-
GraphQL::Deprecation.warn("GraphQL::Execution::Errors is now installed by default, remove `use GraphQL::Execution::Errors` from #{definition_line}")
|
|
23
|
-
end
|
|
24
|
-
|
|
25
17
|
NEW_HANDLER_HASH = ->(h, k) {
|
|
26
18
|
h[k] = {
|
|
27
19
|
class: k,
|
|
@@ -230,7 +230,6 @@ module GraphQL
|
|
|
230
230
|
call_method_on_directives(:resolve, object_proxy, selections.graphql_directives) do
|
|
231
231
|
evaluate_selections(
|
|
232
232
|
path,
|
|
233
|
-
context.scoped_context,
|
|
234
233
|
object_proxy,
|
|
235
234
|
root_type,
|
|
236
235
|
root_op_type == "mutation",
|
|
@@ -349,7 +348,7 @@ module GraphQL
|
|
|
349
348
|
NO_ARGS = {}.freeze
|
|
350
349
|
|
|
351
350
|
# @return [void]
|
|
352
|
-
def evaluate_selections(path,
|
|
351
|
+
def evaluate_selections(path, owner_object, owner_type, is_eager_selection, gathered_selections, selections_result, target_result, parent_object) # rubocop:disable Metrics/ParameterLists
|
|
353
352
|
set_all_interpreter_context(owner_object, nil, nil, path)
|
|
354
353
|
|
|
355
354
|
finished_jobs = 0
|
|
@@ -357,7 +356,7 @@ module GraphQL
|
|
|
357
356
|
gathered_selections.each do |result_name, field_ast_nodes_or_ast_node|
|
|
358
357
|
@dataloader.append_job {
|
|
359
358
|
evaluate_selection(
|
|
360
|
-
path, result_name, field_ast_nodes_or_ast_node,
|
|
359
|
+
path, result_name, field_ast_nodes_or_ast_node, owner_object, owner_type, is_eager_selection, selections_result, parent_object
|
|
361
360
|
)
|
|
362
361
|
finished_jobs += 1
|
|
363
362
|
if target_result && finished_jobs == enqueued_jobs
|
|
@@ -372,7 +371,7 @@ module GraphQL
|
|
|
372
371
|
attr_reader :progress_path
|
|
373
372
|
|
|
374
373
|
# @return [void]
|
|
375
|
-
def evaluate_selection(path, result_name, field_ast_nodes_or_ast_node,
|
|
374
|
+
def evaluate_selection(path, result_name, field_ast_nodes_or_ast_node, owner_object, owner_type, is_eager_field, selections_result, parent_object) # rubocop:disable Metrics/ParameterLists
|
|
376
375
|
return if dead_result?(selections_result)
|
|
377
376
|
# As a performance optimization, the hash key will be a `Node` if
|
|
378
377
|
# there's only one selection of the field. But if there are multiple
|
|
@@ -414,8 +413,6 @@ module GraphQL
|
|
|
414
413
|
end
|
|
415
414
|
# Set this before calling `run_with_directives`, so that the directive can have the latest path
|
|
416
415
|
set_all_interpreter_context(nil, field_defn, nil, next_path)
|
|
417
|
-
|
|
418
|
-
context.scoped_context = scoped_context
|
|
419
416
|
object = owner_object
|
|
420
417
|
|
|
421
418
|
if is_introspection
|
|
@@ -425,19 +422,18 @@ module GraphQL
|
|
|
425
422
|
total_args_count = field_defn.arguments(context).size
|
|
426
423
|
if total_args_count == 0
|
|
427
424
|
resolved_arguments = GraphQL::Execution::Interpreter::Arguments::EMPTY
|
|
428
|
-
evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes,
|
|
425
|
+
evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes, owner_type, object, is_eager_field, result_name, selections_result, parent_object)
|
|
429
426
|
else
|
|
430
427
|
# TODO remove all arguments(...) usages?
|
|
431
428
|
@query.arguments_cache.dataload_for(ast_node, field_defn, object) do |resolved_arguments|
|
|
432
|
-
evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes,
|
|
429
|
+
evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes, owner_type, object, is_eager_field, result_name, selections_result, parent_object)
|
|
433
430
|
end
|
|
434
431
|
end
|
|
435
432
|
end
|
|
436
433
|
|
|
437
|
-
def evaluate_selection_with_args(arguments, field_defn, next_path, ast_node, field_ast_nodes,
|
|
438
|
-
context.scoped_context = scoped_context
|
|
434
|
+
def evaluate_selection_with_args(arguments, field_defn, next_path, ast_node, field_ast_nodes, owner_type, object, is_eager_field, result_name, selection_result, parent_object) # rubocop:disable Metrics/ParameterLists
|
|
439
435
|
return_type = field_defn.type
|
|
440
|
-
after_lazy(arguments, owner: owner_type, field: field_defn, path: next_path, ast_node: ast_node,
|
|
436
|
+
after_lazy(arguments, owner: owner_type, field: field_defn, path: next_path, ast_node: ast_node, owner_object: object, arguments: arguments, result_name: result_name, result: selection_result) do |resolved_arguments|
|
|
441
437
|
if resolved_arguments.is_a?(GraphQL::ExecutionError) || resolved_arguments.is_a?(GraphQL::UnauthorizedError)
|
|
442
438
|
continue_value(next_path, resolved_arguments, owner_type, field_defn, return_type.non_null?, ast_node, result_name, selection_result)
|
|
443
439
|
next
|
|
@@ -472,10 +468,6 @@ module GraphQL
|
|
|
472
468
|
# Use this flag to tell Interpreter::Arguments to add itself
|
|
473
469
|
# to the keyword args hash _before_ freezing everything.
|
|
474
470
|
extra_args[:argument_details] = :__arguments_add_self
|
|
475
|
-
when :irep_node
|
|
476
|
-
# This is used by `__typename` in order to support the legacy runtime,
|
|
477
|
-
# but it has no use here (and it's always `nil`).
|
|
478
|
-
# Stop adding it here to avoid the overhead of `.merge_extras` below.
|
|
479
471
|
when :parent
|
|
480
472
|
extra_args[:parent] = parent_object
|
|
481
473
|
else
|
|
@@ -514,7 +506,7 @@ module GraphQL
|
|
|
514
506
|
rescue GraphQL::ExecutionError => err
|
|
515
507
|
err
|
|
516
508
|
end
|
|
517
|
-
after_lazy(app_result, owner: owner_type, field: field_defn, path: next_path, ast_node: ast_node,
|
|
509
|
+
after_lazy(app_result, owner: owner_type, field: field_defn, path: next_path, ast_node: ast_node, owner_object: object, arguments: resolved_arguments, result_name: result_name, result: selection_result) do |inner_result|
|
|
518
510
|
continue_value = continue_value(next_path, inner_result, owner_type, field_defn, return_type.non_null?, ast_node, result_name, selection_result)
|
|
519
511
|
if HALT != continue_value
|
|
520
512
|
continue_field(next_path, continue_value, owner_type, field_defn, return_type, ast_node, next_selections, false, object, resolved_arguments, result_name, selection_result)
|
|
@@ -619,7 +611,7 @@ module GraphQL
|
|
|
619
611
|
err
|
|
620
612
|
end
|
|
621
613
|
continue_value(path, next_value, parent_type, field, is_non_null, ast_node, result_name, selection_result)
|
|
622
|
-
elsif GraphQL::Execution::
|
|
614
|
+
elsif GraphQL::Execution::SKIP == value
|
|
623
615
|
# It's possible a lazy was already written here
|
|
624
616
|
case selection_result
|
|
625
617
|
when GraphQLResultHash
|
|
@@ -692,7 +684,7 @@ module GraphQL
|
|
|
692
684
|
resolved_type_or_lazy, resolved_value = resolve_type(current_type, value, path)
|
|
693
685
|
resolved_value ||= value
|
|
694
686
|
|
|
695
|
-
after_lazy(resolved_type_or_lazy, owner: current_type, path: path, ast_node: ast_node,
|
|
687
|
+
after_lazy(resolved_type_or_lazy, owner: current_type, path: path, ast_node: ast_node, field: field, owner_object: owner_object, arguments: arguments, trace: false, result_name: result_name, result: selection_result) do |resolved_type|
|
|
696
688
|
possible_types = query.possible_types(current_type)
|
|
697
689
|
|
|
698
690
|
if !possible_types.include?(resolved_type)
|
|
@@ -712,7 +704,7 @@ module GraphQL
|
|
|
712
704
|
rescue GraphQL::ExecutionError => err
|
|
713
705
|
err
|
|
714
706
|
end
|
|
715
|
-
after_lazy(object_proxy, owner: current_type, path: path, ast_node: ast_node,
|
|
707
|
+
after_lazy(object_proxy, owner: current_type, path: path, ast_node: ast_node, field: field, owner_object: owner_object, arguments: arguments, trace: false, result_name: result_name, result: selection_result) do |inner_object|
|
|
716
708
|
continue_value = continue_value(path, inner_object, owner_type, field, is_non_null, ast_node, result_name, selection_result)
|
|
717
709
|
if HALT != continue_value
|
|
718
710
|
response_hash = GraphQLResultHash.new(result_name, selection_result)
|
|
@@ -738,7 +730,6 @@ module GraphQL
|
|
|
738
730
|
call_method_on_directives(:resolve, continue_value, selections.graphql_directives) do
|
|
739
731
|
evaluate_selections(
|
|
740
732
|
path,
|
|
741
|
-
context.scoped_context,
|
|
742
733
|
continue_value,
|
|
743
734
|
current_type,
|
|
744
735
|
false,
|
|
@@ -761,7 +752,6 @@ module GraphQL
|
|
|
761
752
|
set_result(selection_result, result_name, response_list)
|
|
762
753
|
|
|
763
754
|
idx = 0
|
|
764
|
-
scoped_context = context.scoped_context
|
|
765
755
|
begin
|
|
766
756
|
value.each do |inner_value|
|
|
767
757
|
break if dead_result?(response_list)
|
|
@@ -772,10 +762,10 @@ module GraphQL
|
|
|
772
762
|
idx += 1
|
|
773
763
|
if use_dataloader_job
|
|
774
764
|
@dataloader.append_job do
|
|
775
|
-
resolve_list_item(inner_value, inner_type, next_path, ast_node,
|
|
765
|
+
resolve_list_item(inner_value, inner_type, next_path, ast_node, field, owner_object, arguments, this_idx, response_list, next_selections, owner_type)
|
|
776
766
|
end
|
|
777
767
|
else
|
|
778
|
-
resolve_list_item(inner_value, inner_type, next_path, ast_node,
|
|
768
|
+
resolve_list_item(inner_value, inner_type, next_path, ast_node, field, owner_object, arguments, this_idx, response_list, next_selections, owner_type)
|
|
779
769
|
end
|
|
780
770
|
end
|
|
781
771
|
rescue NoMethodError => err
|
|
@@ -795,11 +785,11 @@ module GraphQL
|
|
|
795
785
|
end
|
|
796
786
|
end
|
|
797
787
|
|
|
798
|
-
def resolve_list_item(inner_value, inner_type, next_path, ast_node,
|
|
788
|
+
def resolve_list_item(inner_value, inner_type, next_path, ast_node, field, owner_object, arguments, this_idx, response_list, next_selections, owner_type) # rubocop:disable Metrics/ParameterLists
|
|
799
789
|
set_all_interpreter_context(nil, nil, nil, next_path)
|
|
800
790
|
call_method_on_directives(:resolve_each, owner_object, ast_node.directives) do
|
|
801
791
|
# This will update `response_list` with the lazy
|
|
802
|
-
after_lazy(inner_value, owner: inner_type, path: next_path, ast_node: ast_node,
|
|
792
|
+
after_lazy(inner_value, owner: inner_type, path: next_path, ast_node: ast_node, field: field, owner_object: owner_object, arguments: arguments, result_name: this_idx, result: response_list) do |inner_inner_value|
|
|
803
793
|
continue_value = continue_value(next_path, inner_inner_value, owner_type, field, inner_type.non_null?, ast_node, this_idx, response_list)
|
|
804
794
|
if HALT != continue_value
|
|
805
795
|
continue_field(next_path, continue_value, owner_type, field, inner_type, ast_node, next_selections, false, owner_object, arguments, this_idx, response_list)
|
|
@@ -819,9 +809,6 @@ module GraphQL
|
|
|
819
809
|
yield
|
|
820
810
|
else
|
|
821
811
|
dir_defn = @schema_directives.fetch(dir_node.name)
|
|
822
|
-
if !dir_defn.is_a?(Class)
|
|
823
|
-
dir_defn = dir_defn.type_class || raise("Only class-based directives are supported (not `@#{dir_node.name}`)")
|
|
824
|
-
end
|
|
825
812
|
raw_dir_args = arguments(nil, dir_defn, dir_node)
|
|
826
813
|
dir_args = continue_value(
|
|
827
814
|
@context[:current_path], # path
|
|
@@ -847,7 +834,7 @@ module GraphQL
|
|
|
847
834
|
# Check {Schema::Directive.include?} for each directive that's present
|
|
848
835
|
def directives_include?(node, graphql_object, parent_type)
|
|
849
836
|
node.directives.each do |dir_node|
|
|
850
|
-
dir_defn = @schema_directives.fetch(dir_node.name)
|
|
837
|
+
dir_defn = @schema_directives.fetch(dir_node.name)
|
|
851
838
|
args = arguments(graphql_object, dir_defn, dir_node)
|
|
852
839
|
if !dir_defn.include?(graphql_object, args, context)
|
|
853
840
|
return false
|
|
@@ -877,11 +864,10 @@ module GraphQL
|
|
|
877
864
|
# @param eager [Boolean] Set to `true` for mutation root fields only
|
|
878
865
|
# @param trace [Boolean] If `false`, don't wrap this with field tracing
|
|
879
866
|
# @return [GraphQL::Execution::Lazy, Object] If loading `object` will be deferred, it's a wrapper over it.
|
|
880
|
-
def after_lazy(lazy_obj, owner:, field:, path:,
|
|
867
|
+
def after_lazy(lazy_obj, owner:, field:, path:, owner_object:, arguments:, ast_node:, result:, result_name:, eager: false, trace: true, &block)
|
|
881
868
|
if lazy?(lazy_obj)
|
|
882
869
|
lazy = GraphQL::Execution::Lazy.new(path: path, field: field) do
|
|
883
870
|
set_all_interpreter_context(owner_object, field, arguments, path)
|
|
884
|
-
context.scoped_context = scoped_context
|
|
885
871
|
# Wrap the execution of _this_ method with tracing,
|
|
886
872
|
# but don't wrap the continuation below
|
|
887
873
|
inner_obj = begin
|
|
@@ -11,28 +11,6 @@ require "graphql/execution/interpreter/handles_raw_value"
|
|
|
11
11
|
module GraphQL
|
|
12
12
|
module Execution
|
|
13
13
|
class Interpreter
|
|
14
|
-
def initialize
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Support `Executor` :S
|
|
18
|
-
def execute(_operation, _root_type, query)
|
|
19
|
-
runtime = evaluate(query)
|
|
20
|
-
sync_lazies(query: query)
|
|
21
|
-
runtime.final_result
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def self.use(schema_class)
|
|
25
|
-
if schema_class.interpreter?
|
|
26
|
-
definition_line = caller(2, 1).first
|
|
27
|
-
GraphQL::Deprecation.warn("GraphQL::Execution::Interpreter is now the default; remove `use GraphQL::Execution::Interpreter` from the schema definition (#{definition_line})")
|
|
28
|
-
else
|
|
29
|
-
schema_class.query_execution_strategy(self)
|
|
30
|
-
schema_class.mutation_execution_strategy(self)
|
|
31
|
-
schema_class.subscription_execution_strategy(self)
|
|
32
|
-
schema_class.add_subscription_extension_if_necessary
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
14
|
def self.begin_multiplex(multiplex)
|
|
37
15
|
# Since this is basically the batching context,
|
|
38
16
|
# share it for a whole multiplex
|
|
@@ -52,7 +52,7 @@ module GraphQL
|
|
|
52
52
|
# (fewer clauses in a hot `case` block), but now it requires special handling here.
|
|
53
53
|
# I think it's still worth it for the performance win, but if the number of special
|
|
54
54
|
# cases grows, then maybe it's worth rethinking somehow.
|
|
55
|
-
if @value.is_a?(StandardError) && @value != GraphQL::Execution::
|
|
55
|
+
if @value.is_a?(StandardError) && @value != GraphQL::Execution::SKIP
|
|
56
56
|
raise @value
|
|
57
57
|
else
|
|
58
58
|
@value
|
|
@@ -91,7 +91,7 @@ module GraphQL
|
|
|
91
91
|
def selection(field_name, selected_type: @selected_type, arguments: nil)
|
|
92
92
|
next_field_name = normalize_name(field_name)
|
|
93
93
|
|
|
94
|
-
next_field_defn =
|
|
94
|
+
next_field_defn = @query.get_field(selected_type, next_field_name)
|
|
95
95
|
if next_field_defn
|
|
96
96
|
next_nodes = []
|
|
97
97
|
@ast_nodes.each do |ast_node|
|
|
@@ -137,7 +137,7 @@ module GraphQL
|
|
|
137
137
|
|
|
138
138
|
subselections_by_type.each do |type, ast_nodes_by_response_key|
|
|
139
139
|
ast_nodes_by_response_key.each do |response_key, ast_nodes|
|
|
140
|
-
field_defn =
|
|
140
|
+
field_defn = @query.get_field(type, ast_nodes.first.name)
|
|
141
141
|
lookahead = Lookahead.new(query: @query, ast_nodes: ast_nodes, field: field_defn, owner_type: type)
|
|
142
142
|
subselections.push(lookahead)
|
|
143
143
|
end
|
|
@@ -213,17 +213,10 @@ module GraphQL
|
|
|
213
213
|
end
|
|
214
214
|
end
|
|
215
215
|
|
|
216
|
-
# Wrap get_field and ensure that it returns a GraphQL::Schema::Field.
|
|
217
|
-
# Remove this when legacy execution is removed.
|
|
218
|
-
def get_class_based_field(type, name)
|
|
219
|
-
f = @query.get_field(type, name)
|
|
220
|
-
f && f.type_class
|
|
221
|
-
end
|
|
222
|
-
|
|
223
216
|
def skipped_by_directive?(ast_selection)
|
|
224
217
|
ast_selection.directives.each do |directive|
|
|
225
218
|
dir_defn = @query.schema.directives.fetch(directive.name)
|
|
226
|
-
directive_class = dir_defn
|
|
219
|
+
directive_class = dir_defn
|
|
227
220
|
if directive_class
|
|
228
221
|
dir_args = @query.arguments_for(directive, dir_defn)
|
|
229
222
|
return true unless directive_class.static_include?(dir_args, @query.context)
|
|
@@ -244,7 +237,7 @@ module GraphQL
|
|
|
244
237
|
elsif arguments.nil? || arguments.empty?
|
|
245
238
|
selections_on_type[response_key] = [ast_selection]
|
|
246
239
|
else
|
|
247
|
-
field_defn =
|
|
240
|
+
field_defn = @query.get_field(selected_type, ast_selection.name)
|
|
248
241
|
if arguments_match?(arguments, field_defn, ast_selection)
|
|
249
242
|
selections_on_type[response_key] = [ast_selection]
|
|
250
243
|
end
|
|
@@ -254,14 +247,14 @@ module GraphQL
|
|
|
254
247
|
subselections_on_type = selections_on_type
|
|
255
248
|
if (t = ast_selection.type)
|
|
256
249
|
# Assuming this is valid, that `t` will be found.
|
|
257
|
-
on_type = @query.get_type(t.name)
|
|
250
|
+
on_type = @query.get_type(t.name)
|
|
258
251
|
subselections_on_type = subselections_by_type[on_type] ||= {}
|
|
259
252
|
end
|
|
260
253
|
find_selections(subselections_by_type, subselections_on_type, on_type, ast_selection.selections, arguments)
|
|
261
254
|
when GraphQL::Language::Nodes::FragmentSpread
|
|
262
255
|
frag_defn = @query.fragments[ast_selection.name] || raise("Invariant: Can't look ahead to nonexistent fragment #{ast_selection.name} (found: #{@query.fragments.keys})")
|
|
263
256
|
# Again, assuming a valid AST
|
|
264
|
-
on_type = @query.get_type(frag_defn.type.name)
|
|
257
|
+
on_type = @query.get_type(frag_defn.type.name)
|
|
265
258
|
subselections_on_type = subselections_by_type[on_type] ||= {}
|
|
266
259
|
find_selections(subselections_by_type, subselections_on_type, on_type, frag_defn.selections, arguments)
|
|
267
260
|
else
|