graphql 2.0.27 → 2.1.0
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/graphql/execution/interpreter/runtime.rb +23 -21
- data/lib/graphql/language/document_from_schema_definition.rb +6 -16
- data/lib/graphql/language/nodes.rb +1 -1
- data/lib/graphql/language/printer.rb +233 -145
- data/lib/graphql/language/sanitized_printer.rb +14 -21
- data/lib/graphql/language/visitor.rb +18 -81
- data/lib/graphql/pagination/connection.rb +23 -1
- data/lib/graphql/query.rb +2 -19
- data/lib/graphql/rake_task.rb +3 -12
- data/lib/graphql/schema/field/scope_extension.rb +7 -1
- data/lib/graphql/schema/member/scoped.rb +19 -0
- data/lib/graphql/schema/object.rb +8 -0
- data/lib/graphql/schema/printer.rb +8 -7
- data/lib/graphql/schema/subscription.rb +11 -4
- data/lib/graphql/schema/warden.rb +3 -34
- data/lib/graphql/schema.rb +4 -20
- data/lib/graphql/static_validation/validation_context.rb +0 -3
- data/lib/graphql/static_validation.rb +0 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +2 -1
- data/lib/graphql/subscriptions.rb +11 -6
- data/lib/graphql/types/relay/connection_behaviors.rb +19 -2
- data/lib/graphql/types/relay/edge_behaviors.rb +7 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +0 -1
- metadata +1 -3
- data/lib/graphql/filter.rb +0 -59
- data/lib/graphql/static_validation/type_stack.rb +0 -216
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 785d064bf9279c1c66291e629607bbfe14f33ea0a8ad3e22549d253116159f81
|
4
|
+
data.tar.gz: a66884908e066f99293c3171aa1856977ba01fde58dca3a65a978ef025de8f32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f27e18f66f871cde5a6aedfea89621e57014c02062736b55aa86ebc4f64bdec83de93dca83c4aaede60c321113f4099efeab362cc3d4a2047d725e5ec2e7d73b
|
7
|
+
data.tar.gz: 4071a8921d60279b5ffc3ba11bb653e07596a9a97c0bab783c6a183558ff632996431d365052c27ea571b0b0c3a6a267f3cc10d1d4eff202eec513fc469f094e
|
@@ -15,10 +15,11 @@ module GraphQL
|
|
15
15
|
@current_arguments = nil
|
16
16
|
@current_result_name = nil
|
17
17
|
@current_result = nil
|
18
|
+
@was_authorized_by_scope_items = nil
|
18
19
|
end
|
19
20
|
|
20
21
|
attr_accessor :current_result, :current_result_name,
|
21
|
-
:current_arguments, :current_field, :current_object
|
22
|
+
:current_arguments, :current_field, :current_object, :was_authorized_by_scope_items
|
22
23
|
end
|
23
24
|
|
24
25
|
module GraphQLResult
|
@@ -244,6 +245,7 @@ module GraphQL
|
|
244
245
|
root_operation = query.selected_operation
|
245
246
|
root_op_type = root_operation.operation_type || "query"
|
246
247
|
root_type = schema.root_type_for_operation(root_op_type)
|
248
|
+
|
247
249
|
st = get_current_runtime_state
|
248
250
|
st.current_object = query.root_value
|
249
251
|
st.current_result = @response
|
@@ -426,12 +428,6 @@ module GraphQL
|
|
426
428
|
end
|
427
429
|
end
|
428
430
|
|
429
|
-
return_type = field_defn.type
|
430
|
-
|
431
|
-
# This seems janky, but we need to know
|
432
|
-
# the field's return type at this path in order
|
433
|
-
# to propagate `null`
|
434
|
-
return_type_non_null = return_type.non_null?
|
435
431
|
# Set this before calling `run_with_directives`, so that the directive can have the latest path
|
436
432
|
st = get_current_runtime_state
|
437
433
|
st.current_field = field_defn
|
@@ -441,26 +437,27 @@ module GraphQL
|
|
441
437
|
if is_introspection
|
442
438
|
owner_object = field_defn.owner.wrap(owner_object, context)
|
443
439
|
end
|
444
|
-
|
440
|
+
return_type = field_defn.type
|
445
441
|
total_args_count = field_defn.arguments(context).size
|
446
442
|
if total_args_count == 0
|
447
443
|
resolved_arguments = GraphQL::Execution::Interpreter::Arguments::EMPTY
|
448
444
|
if field_defn.extras.size == 0
|
449
445
|
evaluate_selection_with_resolved_keyword_args(
|
450
|
-
NO_ARGS, resolved_arguments, field_defn, ast_node, field_ast_nodes, owner_type, owner_object, is_eager_field, result_name, selections_result, parent_object, return_type,
|
446
|
+
NO_ARGS, resolved_arguments, field_defn, ast_node, field_ast_nodes, owner_type, owner_object, is_eager_field, result_name, selections_result, parent_object, return_type, return_type.non_null?
|
451
447
|
)
|
452
448
|
else
|
453
|
-
evaluate_selection_with_args(resolved_arguments, field_defn, ast_node, field_ast_nodes, owner_type, owner_object, is_eager_field, result_name, selections_result, parent_object, return_type
|
449
|
+
evaluate_selection_with_args(resolved_arguments, field_defn, ast_node, field_ast_nodes, owner_type, owner_object, is_eager_field, result_name, selections_result, parent_object, return_type)
|
454
450
|
end
|
455
451
|
else
|
456
452
|
@query.arguments_cache.dataload_for(ast_node, field_defn, owner_object) do |resolved_arguments|
|
457
|
-
evaluate_selection_with_args(resolved_arguments, field_defn, ast_node, field_ast_nodes, owner_type, owner_object, is_eager_field, result_name, selections_result, parent_object, return_type
|
453
|
+
evaluate_selection_with_args(resolved_arguments, field_defn, ast_node, field_ast_nodes, owner_type, owner_object, is_eager_field, result_name, selections_result, parent_object, return_type)
|
458
454
|
end
|
459
455
|
end
|
460
456
|
end
|
461
457
|
|
462
|
-
def evaluate_selection_with_args(arguments, field_defn, ast_node, field_ast_nodes, owner_type, object, is_eager_field, result_name, selection_result, parent_object, return_type
|
458
|
+
def evaluate_selection_with_args(arguments, field_defn, ast_node, field_ast_nodes, owner_type, object, is_eager_field, result_name, selection_result, parent_object, return_type) # rubocop:disable Metrics/ParameterLists
|
463
459
|
after_lazy(arguments, field: field_defn, ast_node: ast_node, owner_object: object, arguments: arguments, result_name: result_name, result: selection_result) do |resolved_arguments|
|
460
|
+
return_type_non_null = return_type.non_null?
|
464
461
|
if resolved_arguments.is_a?(GraphQL::ExecutionError) || resolved_arguments.is_a?(GraphQL::UnauthorizedError)
|
465
462
|
continue_value(resolved_arguments, owner_type, field_defn, return_type_non_null, ast_node, result_name, selection_result)
|
466
463
|
next
|
@@ -553,7 +550,10 @@ module GraphQL
|
|
553
550
|
after_lazy(app_result, field: field_defn, ast_node: ast_node, owner_object: object, arguments: resolved_arguments, result_name: result_name, result: selection_result) do |inner_result|
|
554
551
|
continue_value = continue_value(inner_result, owner_type, field_defn, return_type_non_null, ast_node, result_name, selection_result)
|
555
552
|
if HALT != continue_value
|
556
|
-
|
553
|
+
st = get_current_runtime_state
|
554
|
+
was_scoped = st.was_authorized_by_scope_items
|
555
|
+
st.was_authorized_by_scope_items = nil
|
556
|
+
continue_field(continue_value, owner_type, field_defn, return_type, ast_node, next_selections, false, object, resolved_arguments, result_name, selection_result, was_scoped)
|
557
557
|
end
|
558
558
|
end
|
559
559
|
end
|
@@ -733,7 +733,7 @@ module GraphQL
|
|
733
733
|
# Location information from `path` and `ast_node`.
|
734
734
|
#
|
735
735
|
# @return [Lazy, Array, Hash, Object] Lazy, Array, and Hash are all traversed to resolve lazy values later
|
736
|
-
def continue_field(value, owner_type, field, current_type, ast_node, next_selections, is_non_null, owner_object, arguments, result_name, selection_result) # rubocop:disable Metrics/ParameterLists
|
736
|
+
def continue_field(value, owner_type, field, current_type, ast_node, next_selections, is_non_null, owner_object, arguments, result_name, selection_result, was_scoped) # rubocop:disable Metrics/ParameterLists
|
737
737
|
if current_type.non_null?
|
738
738
|
current_type = current_type.of_type
|
739
739
|
is_non_null = true
|
@@ -767,12 +767,12 @@ module GraphQL
|
|
767
767
|
set_result(selection_result, result_name, nil, false, is_non_null)
|
768
768
|
nil
|
769
769
|
else
|
770
|
-
continue_field(resolved_value, owner_type, field, resolved_type, ast_node, next_selections, is_non_null, owner_object, arguments, result_name, selection_result)
|
770
|
+
continue_field(resolved_value, owner_type, field, resolved_type, ast_node, next_selections, is_non_null, owner_object, arguments, result_name, selection_result, was_scoped)
|
771
771
|
end
|
772
772
|
end
|
773
773
|
when "OBJECT"
|
774
774
|
object_proxy = begin
|
775
|
-
current_type.wrap(value, context)
|
775
|
+
was_scoped ? current_type.wrap_scoped(value, context) : current_type.wrap(value, context)
|
776
776
|
rescue GraphQL::ExecutionError => err
|
777
777
|
err
|
778
778
|
end
|
@@ -804,7 +804,6 @@ module GraphQL
|
|
804
804
|
st.current_object = continue_value
|
805
805
|
st.current_result_name = nil
|
806
806
|
st.current_result = this_result
|
807
|
-
|
808
807
|
# This is a less-frequent case; use a fast check since it's often not there.
|
809
808
|
if (directives = selections[:graphql_directives])
|
810
809
|
selections.delete(:graphql_directives)
|
@@ -839,10 +838,10 @@ module GraphQL
|
|
839
838
|
idx += 1
|
840
839
|
if use_dataloader_job
|
841
840
|
@dataloader.append_job do
|
842
|
-
resolve_list_item(inner_value, inner_type, inner_type_non_null, ast_node, field, owner_object, arguments, this_idx, response_list, next_selections, owner_type)
|
841
|
+
resolve_list_item(inner_value, inner_type, inner_type_non_null, ast_node, field, owner_object, arguments, this_idx, response_list, next_selections, owner_type, was_scoped)
|
843
842
|
end
|
844
843
|
else
|
845
|
-
resolve_list_item(inner_value, inner_type, inner_type_non_null, ast_node, field, owner_object, arguments, this_idx, response_list, next_selections, owner_type)
|
844
|
+
resolve_list_item(inner_value, inner_type, inner_type_non_null, ast_node, field, owner_object, arguments, this_idx, response_list, next_selections, owner_type, was_scoped)
|
846
845
|
end
|
847
846
|
end
|
848
847
|
|
@@ -873,7 +872,7 @@ module GraphQL
|
|
873
872
|
end
|
874
873
|
end
|
875
874
|
|
876
|
-
def resolve_list_item(inner_value, inner_type, inner_type_non_null, ast_node, field, owner_object, arguments, this_idx, response_list, next_selections, owner_type) # rubocop:disable Metrics/ParameterLists
|
875
|
+
def resolve_list_item(inner_value, inner_type, inner_type_non_null, ast_node, field, owner_object, arguments, this_idx, response_list, next_selections, owner_type, was_scoped) # rubocop:disable Metrics/ParameterLists
|
877
876
|
st = get_current_runtime_state
|
878
877
|
st.current_result_name = this_idx
|
879
878
|
st.current_result = response_list
|
@@ -882,7 +881,7 @@ module GraphQL
|
|
882
881
|
after_lazy(inner_value, ast_node: ast_node, field: field, owner_object: owner_object, arguments: arguments, result_name: this_idx, result: response_list) do |inner_inner_value|
|
883
882
|
continue_value = continue_value(inner_inner_value, owner_type, field, inner_type_non_null, ast_node, this_idx, response_list)
|
884
883
|
if HALT != continue_value
|
885
|
-
continue_field(continue_value, owner_type, field, inner_type, ast_node, next_selections, false, owner_object, arguments, this_idx, response_list)
|
884
|
+
continue_field(continue_value, owner_type, field, inner_type, ast_node, next_selections, false, owner_object, arguments, this_idx, response_list, was_scoped)
|
886
885
|
end
|
887
886
|
end
|
888
887
|
end
|
@@ -962,6 +961,8 @@ module GraphQL
|
|
962
961
|
def after_lazy(lazy_obj, field:, owner_object:, arguments:, ast_node:, result:, result_name:, eager: false, trace: true, &block)
|
963
962
|
if lazy?(lazy_obj)
|
964
963
|
orig_result = result
|
964
|
+
st = get_current_runtime_state
|
965
|
+
was_authorized_by_scope_items = st.was_authorized_by_scope_items
|
965
966
|
lazy = GraphQL::Execution::Lazy.new(field: field) do
|
966
967
|
st = get_current_runtime_state
|
967
968
|
st.current_object = owner_object
|
@@ -969,6 +970,7 @@ module GraphQL
|
|
969
970
|
st.current_arguments = arguments
|
970
971
|
st.current_result_name = result_name
|
971
972
|
st.current_result = orig_result
|
973
|
+
st.was_authorized_by_scope_items = was_authorized_by_scope_items
|
972
974
|
# Wrap the execution of _this_ method with tracing,
|
973
975
|
# but don't wrap the continuation below
|
974
976
|
inner_obj = begin
|
@@ -14,7 +14,7 @@ module GraphQL
|
|
14
14
|
# @param include_built_in_directives [Boolean] Whether or not to include built in directives in the AST
|
15
15
|
class DocumentFromSchemaDefinition
|
16
16
|
def initialize(
|
17
|
-
schema, context: nil,
|
17
|
+
schema, context: nil, include_introspection_types: false,
|
18
18
|
include_built_in_directives: false, include_built_in_scalars: false, always_include_schema: false
|
19
19
|
)
|
20
20
|
@schema = schema
|
@@ -26,21 +26,11 @@ module GraphQL
|
|
26
26
|
|
27
27
|
schema_context = schema.context_class.new(query: nil, object: nil, schema: schema, values: context)
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
filter,
|
35
|
-
schema: @schema,
|
36
|
-
context: schema_context,
|
37
|
-
)
|
38
|
-
else
|
39
|
-
@schema.warden_class.new(
|
40
|
-
schema: @schema,
|
41
|
-
context: schema_context,
|
42
|
-
)
|
43
|
-
end
|
29
|
+
|
30
|
+
@warden = @schema.warden_class.new(
|
31
|
+
schema: @schema,
|
32
|
+
context: schema_context,
|
33
|
+
)
|
44
34
|
|
45
35
|
schema_context.warden = @warden
|
46
36
|
end
|
@@ -535,7 +535,7 @@ module GraphQL
|
|
535
535
|
# @example Creating a custom string from a document
|
536
536
|
# class VariableScrubber < GraphQL::Language::Printer
|
537
537
|
# def print_argument(arg)
|
538
|
-
# "#{arg.name}: <HIDDEN>"
|
538
|
+
# print_string("#{arg.name}: <HIDDEN>")
|
539
539
|
# end
|
540
540
|
# end
|
541
541
|
#
|