graphql 2.2.17 → 2.5.16
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/generators/graphql/install/mutation_root_generator.rb +2 -2
- data/lib/generators/graphql/install_generator.rb +46 -0
- data/lib/generators/graphql/orm_mutations_base.rb +1 -1
- data/lib/generators/graphql/templates/base_resolver.erb +2 -0
- data/lib/generators/graphql/templates/schema.erb +3 -0
- data/lib/generators/graphql/type_generator.rb +1 -1
- data/lib/graphql/analysis/analyzer.rb +90 -0
- data/lib/graphql/analysis/field_usage.rb +82 -0
- data/lib/graphql/analysis/max_query_complexity.rb +20 -0
- data/lib/graphql/analysis/max_query_depth.rb +20 -0
- data/lib/graphql/analysis/query_complexity.rb +263 -0
- data/lib/graphql/analysis/{ast/query_depth.rb → query_depth.rb} +23 -25
- data/lib/graphql/analysis/visitor.rb +280 -0
- data/lib/graphql/analysis.rb +95 -1
- data/lib/graphql/autoload.rb +38 -0
- data/lib/graphql/backtrace/table.rb +118 -55
- data/lib/graphql/backtrace.rb +1 -19
- data/lib/graphql/current.rb +57 -0
- data/lib/graphql/dashboard/detailed_traces.rb +47 -0
- data/lib/graphql/dashboard/installable.rb +22 -0
- data/lib/graphql/dashboard/limiters.rb +93 -0
- data/lib/graphql/dashboard/operation_store.rb +199 -0
- data/lib/graphql/dashboard/statics/bootstrap-5.3.3.min.css +6 -0
- data/lib/graphql/dashboard/statics/bootstrap-5.3.3.min.js +7 -0
- data/lib/graphql/dashboard/statics/charts.min.css +1 -0
- data/lib/graphql/dashboard/statics/dashboard.css +30 -0
- data/lib/graphql/dashboard/statics/dashboard.js +143 -0
- data/lib/graphql/dashboard/statics/header-icon.png +0 -0
- data/lib/graphql/dashboard/statics/icon.png +0 -0
- data/lib/graphql/dashboard/subscriptions.rb +96 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/detailed_traces/traces/index.html.erb +45 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/landings/show.html.erb +18 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/limiters/limiters/show.html.erb +62 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/not_installed.html.erb +18 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/clients/_form.html.erb +23 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/clients/edit.html.erb +21 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/clients/index.html.erb +69 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/clients/new.html.erb +7 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/index_entries/index.html.erb +39 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/index_entries/show.html.erb +32 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/operations/index.html.erb +81 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/operations/show.html.erb +71 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/subscriptions/subscriptions/show.html.erb +41 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/subscriptions/topics/index.html.erb +55 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/subscriptions/topics/show.html.erb +40 -0
- data/lib/graphql/dashboard/views/layouts/graphql/dashboard/application.html.erb +108 -0
- data/lib/graphql/dashboard.rb +158 -0
- data/lib/graphql/dataloader/active_record_association_source.rb +84 -0
- data/lib/graphql/dataloader/active_record_source.rb +47 -0
- data/lib/graphql/dataloader/async_dataloader.rb +46 -19
- data/lib/graphql/dataloader/null_dataloader.rb +51 -10
- data/lib/graphql/dataloader/source.rb +20 -9
- data/lib/graphql/dataloader.rb +153 -45
- data/lib/graphql/date_encoding_error.rb +1 -1
- data/lib/graphql/dig.rb +2 -1
- data/lib/graphql/execution/interpreter/argument_value.rb +5 -1
- data/lib/graphql/execution/interpreter/arguments_cache.rb +5 -10
- data/lib/graphql/execution/interpreter/resolve.rb +23 -25
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +63 -5
- data/lib/graphql/execution/interpreter/runtime.rb +321 -222
- data/lib/graphql/execution/interpreter.rb +23 -30
- data/lib/graphql/execution/lookahead.rb +18 -11
- data/lib/graphql/execution/multiplex.rb +6 -5
- data/lib/graphql/introspection/directive_location_enum.rb +1 -1
- data/lib/graphql/introspection/directive_type.rb +1 -1
- data/lib/graphql/introspection/entry_points.rb +2 -2
- data/lib/graphql/introspection/field_type.rb +1 -1
- data/lib/graphql/introspection/schema_type.rb +6 -11
- data/lib/graphql/introspection/type_type.rb +5 -5
- data/lib/graphql/invalid_name_error.rb +1 -1
- data/lib/graphql/invalid_null_error.rb +20 -17
- data/lib/graphql/language/cache.rb +13 -0
- data/lib/graphql/language/comment.rb +18 -0
- data/lib/graphql/language/document_from_schema_definition.rb +64 -35
- data/lib/graphql/language/lexer.rb +72 -42
- data/lib/graphql/language/nodes.rb +93 -52
- data/lib/graphql/language/parser.rb +168 -61
- data/lib/graphql/language/printer.rb +31 -15
- data/lib/graphql/language/sanitized_printer.rb +1 -1
- data/lib/graphql/language.rb +61 -1
- data/lib/graphql/pagination/connection.rb +1 -1
- data/lib/graphql/query/context/scoped_context.rb +1 -1
- data/lib/graphql/query/context.rb +46 -47
- data/lib/graphql/query/null_context.rb +3 -5
- data/lib/graphql/query/partial.rb +179 -0
- data/lib/graphql/query/validation_pipeline.rb +2 -2
- data/lib/graphql/query/variable_validation_error.rb +1 -1
- data/lib/graphql/query.rb +123 -69
- data/lib/graphql/railtie.rb +7 -0
- data/lib/graphql/rubocop/graphql/base_cop.rb +1 -1
- data/lib/graphql/rubocop/graphql/field_type_in_block.rb +144 -0
- data/lib/graphql/rubocop/graphql/root_types_in_block.rb +38 -0
- data/lib/graphql/rubocop.rb +2 -0
- data/lib/graphql/schema/addition.rb +26 -13
- data/lib/graphql/schema/always_visible.rb +7 -2
- data/lib/graphql/schema/argument.rb +57 -8
- data/lib/graphql/schema/build_from_definition.rb +116 -49
- data/lib/graphql/schema/directive/flagged.rb +4 -2
- data/lib/graphql/schema/directive.rb +54 -2
- data/lib/graphql/schema/enum.rb +107 -24
- data/lib/graphql/schema/enum_value.rb +10 -2
- data/lib/graphql/schema/field/connection_extension.rb +1 -1
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +134 -45
- data/lib/graphql/schema/field_extension.rb +1 -1
- data/lib/graphql/schema/has_single_input_argument.rb +6 -2
- data/lib/graphql/schema/input_object.rb +122 -64
- data/lib/graphql/schema/interface.rb +23 -5
- data/lib/graphql/schema/introspection_system.rb +6 -17
- data/lib/graphql/schema/late_bound_type.rb +4 -0
- data/lib/graphql/schema/list.rb +3 -3
- data/lib/graphql/schema/loader.rb +3 -2
- data/lib/graphql/schema/member/base_dsl_methods.rb +15 -0
- data/lib/graphql/schema/member/has_arguments.rb +44 -58
- data/lib/graphql/schema/member/has_dataloader.rb +62 -0
- data/lib/graphql/schema/member/has_deprecation_reason.rb +15 -0
- data/lib/graphql/schema/member/has_directives.rb +4 -4
- data/lib/graphql/schema/member/has_fields.rb +26 -6
- data/lib/graphql/schema/member/has_interfaces.rb +6 -6
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +5 -1
- data/lib/graphql/schema/member/has_validators.rb +1 -1
- data/lib/graphql/schema/member/relay_shortcuts.rb +1 -1
- data/lib/graphql/schema/member/type_system_helpers.rb +17 -4
- data/lib/graphql/schema/member.rb +1 -0
- data/lib/graphql/schema/mutation.rb +7 -0
- data/lib/graphql/schema/object.rb +25 -8
- data/lib/graphql/schema/printer.rb +1 -0
- data/lib/graphql/schema/ractor_shareable.rb +79 -0
- data/lib/graphql/schema/relay_classic_mutation.rb +0 -1
- data/lib/graphql/schema/resolver.rb +29 -23
- data/lib/graphql/schema/scalar.rb +1 -6
- data/lib/graphql/schema/subscription.rb +52 -6
- data/lib/graphql/schema/timeout.rb +19 -2
- data/lib/graphql/schema/type_expression.rb +2 -2
- data/lib/graphql/schema/union.rb +1 -1
- data/lib/graphql/schema/validator/all_validator.rb +62 -0
- data/lib/graphql/schema/validator/required_validator.rb +92 -11
- data/lib/graphql/schema/validator.rb +3 -1
- data/lib/graphql/schema/visibility/migration.rb +188 -0
- data/lib/graphql/schema/visibility/profile.rb +445 -0
- data/lib/graphql/schema/visibility/visit.rb +190 -0
- data/lib/graphql/schema/visibility.rb +311 -0
- data/lib/graphql/schema/warden.rb +190 -20
- data/lib/graphql/schema.rb +695 -167
- data/lib/graphql/static_validation/all_rules.rb +2 -2
- data/lib/graphql/static_validation/base_visitor.rb +6 -5
- data/lib/graphql/static_validation/literal_validator.rb +4 -4
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +1 -1
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +1 -1
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +3 -2
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +3 -3
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +2 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +12 -2
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +47 -13
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +88 -25
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +10 -2
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +12 -2
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +1 -1
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +1 -1
- data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +1 -1
- data/lib/graphql/static_validation/rules/not_single_subscription_error.rb +25 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +1 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -4
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +3 -3
- data/lib/graphql/static_validation/rules/subscription_root_exists_and_single_subscription_selection.rb +26 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +7 -3
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +18 -27
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +1 -1
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +2 -2
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +11 -2
- data/lib/graphql/static_validation/validation_context.rb +18 -2
- data/lib/graphql/static_validation/validator.rb +6 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +5 -3
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +11 -5
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +12 -10
- data/lib/graphql/subscriptions/event.rb +13 -2
- data/lib/graphql/subscriptions/serialize.rb +1 -1
- data/lib/graphql/subscriptions.rb +7 -5
- data/lib/graphql/testing/helpers.rb +48 -16
- data/lib/graphql/testing/mock_action_cable.rb +111 -0
- data/lib/graphql/testing.rb +1 -0
- data/lib/graphql/tracing/active_support_notifications_trace.rb +14 -3
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +1 -1
- data/lib/graphql/tracing/appoptics_trace.rb +5 -1
- data/lib/graphql/tracing/appoptics_tracing.rb +7 -0
- data/lib/graphql/tracing/appsignal_trace.rb +32 -59
- data/lib/graphql/tracing/appsignal_tracing.rb +2 -0
- data/lib/graphql/tracing/call_legacy_tracers.rb +66 -0
- data/lib/graphql/tracing/data_dog_trace.rb +46 -162
- data/lib/graphql/tracing/data_dog_tracing.rb +2 -0
- data/lib/graphql/tracing/detailed_trace/memory_backend.rb +60 -0
- data/lib/graphql/tracing/detailed_trace/redis_backend.rb +72 -0
- data/lib/graphql/tracing/detailed_trace.rb +141 -0
- data/lib/graphql/tracing/legacy_hooks_trace.rb +1 -0
- data/lib/graphql/tracing/legacy_trace.rb +4 -61
- data/lib/graphql/tracing/monitor_trace.rb +283 -0
- data/lib/graphql/tracing/new_relic_trace.rb +47 -54
- data/lib/graphql/tracing/new_relic_tracing.rb +2 -0
- data/lib/graphql/tracing/notifications_trace.rb +183 -37
- data/lib/graphql/tracing/notifications_tracing.rb +2 -0
- data/lib/graphql/tracing/null_trace.rb +9 -0
- data/lib/graphql/tracing/perfetto_trace/trace.proto +141 -0
- data/lib/graphql/tracing/perfetto_trace/trace_pb.rb +33 -0
- data/lib/graphql/tracing/perfetto_trace.rb +818 -0
- data/lib/graphql/tracing/platform_tracing.rb +1 -1
- data/lib/graphql/tracing/prometheus_trace/graphql_collector.rb +2 -0
- data/lib/graphql/tracing/prometheus_trace.rb +73 -73
- data/lib/graphql/tracing/prometheus_tracing.rb +2 -0
- data/lib/graphql/tracing/scout_trace.rb +32 -58
- data/lib/graphql/tracing/scout_tracing.rb +2 -0
- data/lib/graphql/tracing/sentry_trace.rb +64 -98
- data/lib/graphql/tracing/statsd_trace.rb +33 -45
- data/lib/graphql/tracing/statsd_tracing.rb +2 -0
- data/lib/graphql/tracing/trace.rb +111 -1
- data/lib/graphql/tracing.rb +31 -30
- data/lib/graphql/type_kinds.rb +2 -1
- data/lib/graphql/types/relay/connection_behaviors.rb +12 -2
- data/lib/graphql/types/relay/edge_behaviors.rb +11 -1
- data/lib/graphql/types/relay/page_info_behaviors.rb +4 -0
- data/lib/graphql/types.rb +18 -11
- data/lib/graphql/unauthorized_enum_value_error.rb +13 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +64 -54
- metadata +197 -22
- data/lib/graphql/analysis/ast/analyzer.rb +0 -91
- data/lib/graphql/analysis/ast/field_usage.rb +0 -82
- data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -22
- data/lib/graphql/analysis/ast/max_query_depth.rb +0 -22
- data/lib/graphql/analysis/ast/query_complexity.rb +0 -182
- data/lib/graphql/analysis/ast/visitor.rb +0 -276
- data/lib/graphql/analysis/ast.rb +0 -94
- data/lib/graphql/backtrace/inspect_result.rb +0 -50
- data/lib/graphql/backtrace/trace.rb +0 -93
- data/lib/graphql/backtrace/tracer.rb +0 -80
- data/lib/graphql/language/token.rb +0 -34
- data/lib/graphql/schema/invalid_type_error.rb +0 -7
- data/lib/graphql/schema/null_mask.rb +0 -11
- data/lib/graphql/static_validation/rules/subscription_root_exists.rb +0 -17
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "graphql/tracing"
|
|
4
|
+
|
|
2
5
|
module GraphQL
|
|
3
6
|
module Tracing
|
|
4
7
|
# This is the base class for a `trace` instance whose methods are called during query execution.
|
|
5
8
|
# "Trace modes" are subclasses of this with custom tracing modules mixed in.
|
|
6
9
|
#
|
|
7
10
|
# A trace module may implement any of the methods on `Trace`, being sure to call `super`
|
|
8
|
-
# to continue any tracing hooks and call the actual runtime behavior.
|
|
11
|
+
# to continue any tracing hooks and call the actual runtime behavior.
|
|
9
12
|
#
|
|
10
13
|
class Trace
|
|
11
14
|
# @param multiplex [GraphQL::Execution::Multiplex, nil]
|
|
@@ -20,6 +23,8 @@ module GraphQL
|
|
|
20
23
|
yield
|
|
21
24
|
end
|
|
22
25
|
|
|
26
|
+
# @param query_string [String]
|
|
27
|
+
# @return [void]
|
|
23
28
|
def parse(query_string:)
|
|
24
29
|
yield
|
|
25
30
|
end
|
|
@@ -28,6 +33,22 @@ module GraphQL
|
|
|
28
33
|
yield
|
|
29
34
|
end
|
|
30
35
|
|
|
36
|
+
def begin_validate(query, validate)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def end_validate(query, validate, errors)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @param multiplex [GraphQL::Execution::Multiplex]
|
|
43
|
+
# @param analyzers [Array<Class>]
|
|
44
|
+
# @return [void]
|
|
45
|
+
def begin_analyze_multiplex(multiplex, analyzers); end
|
|
46
|
+
# @param multiplex [GraphQL::Execution::Multiplex]
|
|
47
|
+
# @param analyzers [Array<Class>]
|
|
48
|
+
# @return [void]
|
|
49
|
+
def end_analyze_multiplex(multiplex, analyzers); end
|
|
50
|
+
# @param multiplex [GraphQL::Execution::Multiplex]
|
|
51
|
+
# @return [void]
|
|
31
52
|
def analyze_multiplex(multiplex:)
|
|
32
53
|
yield
|
|
33
54
|
end
|
|
@@ -36,6 +57,9 @@ module GraphQL
|
|
|
36
57
|
yield
|
|
37
58
|
end
|
|
38
59
|
|
|
60
|
+
# This wraps an entire `.execute` call.
|
|
61
|
+
# @param multiplex [GraphQL::Execution::Multiplex]
|
|
62
|
+
# @return [void]
|
|
39
63
|
def execute_multiplex(multiplex:)
|
|
40
64
|
yield
|
|
41
65
|
end
|
|
@@ -48,6 +72,20 @@ module GraphQL
|
|
|
48
72
|
yield
|
|
49
73
|
end
|
|
50
74
|
|
|
75
|
+
# GraphQL is about to resolve this field
|
|
76
|
+
# @param field [GraphQL::Schema::Field]
|
|
77
|
+
# @param object [GraphQL::Schema::Object]
|
|
78
|
+
# @param arguments [Hash]
|
|
79
|
+
# @param query [GraphQL::Query]
|
|
80
|
+
def begin_execute_field(field, object, arguments, query); end
|
|
81
|
+
# GraphQL just finished resolving this field
|
|
82
|
+
# @param field [GraphQL::Schema::Field]
|
|
83
|
+
# @param object [GraphQL::Schema::Object]
|
|
84
|
+
# @param arguments [Hash]
|
|
85
|
+
# @param query [GraphQL::Query]
|
|
86
|
+
# @param result [Object]
|
|
87
|
+
def end_execute_field(field, object, arguments, query, result); end
|
|
88
|
+
|
|
51
89
|
def execute_field(field:, query:, ast_node:, arguments:, object:)
|
|
52
90
|
yield
|
|
53
91
|
end
|
|
@@ -60,6 +98,22 @@ module GraphQL
|
|
|
60
98
|
yield
|
|
61
99
|
end
|
|
62
100
|
|
|
101
|
+
# A call to `.authorized?` is starting
|
|
102
|
+
# @param type [Class<GraphQL::Schema::Object>]
|
|
103
|
+
# @param object [Object]
|
|
104
|
+
# @param context [GraphQL::Query::Context]
|
|
105
|
+
# @return [void]
|
|
106
|
+
def begin_authorized(type, object, context)
|
|
107
|
+
end
|
|
108
|
+
# A call to `.authorized?` just finished
|
|
109
|
+
# @param type [Class<GraphQL::Schema::Object>]
|
|
110
|
+
# @param object [Object]
|
|
111
|
+
# @param context [GraphQL::Query::Context]
|
|
112
|
+
# @param authorized_result [Boolean]
|
|
113
|
+
# @return [void]
|
|
114
|
+
def end_authorized(type, object, context, authorized_result)
|
|
115
|
+
end
|
|
116
|
+
|
|
63
117
|
def authorized_lazy(query:, type:, object:)
|
|
64
118
|
yield
|
|
65
119
|
end
|
|
@@ -71,6 +125,62 @@ module GraphQL
|
|
|
71
125
|
def resolve_type_lazy(query:, type:, object:)
|
|
72
126
|
yield
|
|
73
127
|
end
|
|
128
|
+
|
|
129
|
+
# A call to `.resolve_type` is starting
|
|
130
|
+
# @param type [Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface>]
|
|
131
|
+
# @param value [Object]
|
|
132
|
+
# @param context [GraphQL::Query::Context]
|
|
133
|
+
# @return [void]
|
|
134
|
+
def begin_resolve_type(type, value, context)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# A call to `.resolve_type` just ended
|
|
138
|
+
# @param type [Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface>]
|
|
139
|
+
# @param value [Object]
|
|
140
|
+
# @param context [GraphQL::Query::Context]
|
|
141
|
+
# @param resolved_type [Class<GraphQL::Schema::Object>]
|
|
142
|
+
# @return [void]
|
|
143
|
+
def end_resolve_type(type, value, context, resolved_type)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# A dataloader run is starting
|
|
147
|
+
# @param dataloader [GraphQL::Dataloader]
|
|
148
|
+
# @return [void]
|
|
149
|
+
def begin_dataloader(dataloader); end
|
|
150
|
+
# A dataloader run has ended
|
|
151
|
+
# @param dataloder [GraphQL::Dataloader]
|
|
152
|
+
# @return [void]
|
|
153
|
+
def end_dataloader(dataloader); end
|
|
154
|
+
|
|
155
|
+
# A source with pending keys is about to fetch
|
|
156
|
+
# @param source [GraphQL::Dataloader::Source]
|
|
157
|
+
# @return [void]
|
|
158
|
+
def begin_dataloader_source(source); end
|
|
159
|
+
# A fetch call has just ended
|
|
160
|
+
# @param source [GraphQL::Dataloader::Source]
|
|
161
|
+
# @return [void]
|
|
162
|
+
def end_dataloader_source(source); end
|
|
163
|
+
|
|
164
|
+
# Called when Dataloader spins up a new fiber for GraphQL execution
|
|
165
|
+
# @param jobs [Array<#call>] Execution steps to run
|
|
166
|
+
# @return [void]
|
|
167
|
+
def dataloader_spawn_execution_fiber(jobs); end
|
|
168
|
+
# Called when Dataloader spins up a new fiber for fetching data
|
|
169
|
+
# @param pending_sources [GraphQL::Dataloader::Source] Instances with pending keys
|
|
170
|
+
# @return [void]
|
|
171
|
+
def dataloader_spawn_source_fiber(pending_sources); end
|
|
172
|
+
# Called when an execution or source fiber terminates
|
|
173
|
+
# @return [void]
|
|
174
|
+
def dataloader_fiber_exit; end
|
|
175
|
+
|
|
176
|
+
# Called when a Dataloader fiber is paused to wait for data
|
|
177
|
+
# @param source [GraphQL::Dataloader::Source] The Source whose `load` call initiated this `yield`
|
|
178
|
+
# @return [void]
|
|
179
|
+
def dataloader_fiber_yield(source); end
|
|
180
|
+
# Called when a Dataloader fiber is resumed because data has been loaded
|
|
181
|
+
# @param source [GraphQL::Dataloader::Source] The Source whose `load` call previously caused this Fiber to wait
|
|
182
|
+
# @return [void]
|
|
183
|
+
def dataloader_fiber_resume(source); end
|
|
74
184
|
end
|
|
75
185
|
end
|
|
76
186
|
end
|
data/lib/graphql/tracing.rb
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
require "graphql/tracing/trace"
|
|
3
|
-
require "graphql/tracing/legacy_trace"
|
|
4
|
-
require "graphql/tracing/legacy_hooks_trace"
|
|
5
2
|
|
|
6
|
-
# Legacy tracing:
|
|
7
|
-
require "graphql/tracing/active_support_notifications_tracing"
|
|
8
|
-
require "graphql/tracing/platform_tracing"
|
|
9
|
-
require "graphql/tracing/appoptics_tracing"
|
|
10
|
-
require "graphql/tracing/appsignal_tracing"
|
|
11
|
-
require "graphql/tracing/data_dog_tracing"
|
|
12
|
-
require "graphql/tracing/new_relic_tracing"
|
|
13
|
-
require "graphql/tracing/scout_tracing"
|
|
14
|
-
require "graphql/tracing/statsd_tracing"
|
|
15
|
-
require "graphql/tracing/prometheus_tracing"
|
|
16
|
-
|
|
17
|
-
# New Tracing:
|
|
18
|
-
require "graphql/tracing/active_support_notifications_trace"
|
|
19
|
-
require "graphql/tracing/platform_trace"
|
|
20
|
-
require "graphql/tracing/appoptics_trace"
|
|
21
|
-
require "graphql/tracing/appsignal_trace"
|
|
22
|
-
require "graphql/tracing/data_dog_trace"
|
|
23
|
-
require "graphql/tracing/new_relic_trace"
|
|
24
|
-
require "graphql/tracing/notifications_trace"
|
|
25
|
-
require "graphql/tracing/sentry_trace"
|
|
26
|
-
require "graphql/tracing/scout_trace"
|
|
27
|
-
require "graphql/tracing/statsd_trace"
|
|
28
|
-
require "graphql/tracing/prometheus_trace"
|
|
29
|
-
if defined?(PrometheusExporter::Server)
|
|
30
|
-
require "graphql/tracing/prometheus_trace/graphql_collector"
|
|
31
|
-
end
|
|
32
3
|
|
|
33
4
|
module GraphQL
|
|
34
5
|
module Tracing
|
|
35
|
-
|
|
6
|
+
autoload :Trace, "graphql/tracing/trace"
|
|
7
|
+
autoload :CallLegacyTracers, "graphql/tracing/call_legacy_tracers"
|
|
8
|
+
autoload :LegacyTrace, "graphql/tracing/legacy_trace"
|
|
9
|
+
autoload :LegacyHooksTrace, "graphql/tracing/legacy_hooks_trace"
|
|
10
|
+
autoload :NullTrace, "graphql/tracing/null_trace"
|
|
11
|
+
|
|
12
|
+
autoload :ActiveSupportNotificationsTracing, "graphql/tracing/active_support_notifications_tracing"
|
|
13
|
+
autoload :PlatformTracing, "graphql/tracing/platform_tracing"
|
|
14
|
+
autoload :AppOpticsTracing, "graphql/tracing/appoptics_tracing"
|
|
15
|
+
autoload :AppsignalTracing, "graphql/tracing/appsignal_tracing"
|
|
16
|
+
autoload :DataDogTracing, "graphql/tracing/data_dog_tracing"
|
|
17
|
+
autoload :NewRelicTracing, "graphql/tracing/new_relic_tracing"
|
|
18
|
+
autoload :NotificationsTracing, "graphql/tracing/notifications_tracing"
|
|
19
|
+
autoload :ScoutTracing, "graphql/tracing/scout_tracing"
|
|
20
|
+
autoload :StatsdTracing, "graphql/tracing/statsd_tracing"
|
|
21
|
+
autoload :PrometheusTracing, "graphql/tracing/prometheus_tracing"
|
|
22
|
+
|
|
23
|
+
autoload :ActiveSupportNotificationsTrace, "graphql/tracing/active_support_notifications_trace"
|
|
24
|
+
autoload :PlatformTrace, "graphql/tracing/platform_trace"
|
|
25
|
+
autoload :AppOpticsTrace, "graphql/tracing/appoptics_trace"
|
|
26
|
+
autoload :AppsignalTrace, "graphql/tracing/appsignal_trace"
|
|
27
|
+
autoload :DataDogTrace, "graphql/tracing/data_dog_trace"
|
|
28
|
+
autoload :MonitorTrace, "graphql/tracing/monitor_trace"
|
|
29
|
+
autoload :NewRelicTrace, "graphql/tracing/new_relic_trace"
|
|
30
|
+
autoload :NotificationsTrace, "graphql/tracing/notifications_trace"
|
|
31
|
+
autoload :SentryTrace, "graphql/tracing/sentry_trace"
|
|
32
|
+
autoload :ScoutTrace, "graphql/tracing/scout_trace"
|
|
33
|
+
autoload :StatsdTrace, "graphql/tracing/statsd_trace"
|
|
34
|
+
autoload :PrometheusTrace, "graphql/tracing/prometheus_trace"
|
|
35
|
+
autoload :PerfettoTrace, "graphql/tracing/perfetto_trace"
|
|
36
|
+
autoload :DetailedTrace, "graphql/tracing/detailed_trace"
|
|
36
37
|
|
|
37
38
|
# Objects may include traceable to gain a `.trace(...)` method.
|
|
38
39
|
# The object must have a `@tracers` ivar of type `Array<<#trace(k, d, &b)>>`.
|
data/lib/graphql/type_kinds.rb
CHANGED
|
@@ -14,9 +14,10 @@ module GraphQL
|
|
|
14
14
|
@leaf = leaf
|
|
15
15
|
@composite = fields? || abstract?
|
|
16
16
|
@description = description
|
|
17
|
+
freeze
|
|
17
18
|
end
|
|
18
19
|
|
|
19
|
-
# Does this TypeKind have multiple possible
|
|
20
|
+
# Does this TypeKind have multiple possible implementers?
|
|
20
21
|
# @deprecated Use `abstract?` instead of `resolves?`.
|
|
21
22
|
def resolves?; @abstract; end
|
|
22
23
|
# Is this TypeKind abstract?
|
|
@@ -18,6 +18,7 @@ module GraphQL
|
|
|
18
18
|
self.node_type = nil
|
|
19
19
|
self.edge_class = nil
|
|
20
20
|
}
|
|
21
|
+
child_class.default_broadcastable(nil)
|
|
21
22
|
add_page_info_field(child_class)
|
|
22
23
|
end
|
|
23
24
|
|
|
@@ -31,12 +32,21 @@ module GraphQL
|
|
|
31
32
|
child_class.edge_type = nil
|
|
32
33
|
child_class.node_type = nil
|
|
33
34
|
child_class.edge_class = nil
|
|
35
|
+
child_class.default_broadcastable(default_broadcastable?)
|
|
34
36
|
end
|
|
35
37
|
|
|
36
38
|
def default_relay?
|
|
37
39
|
true
|
|
38
40
|
end
|
|
39
41
|
|
|
42
|
+
def default_broadcastable?
|
|
43
|
+
@default_broadcastable
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def default_broadcastable(new_value)
|
|
47
|
+
@default_broadcastable = new_value
|
|
48
|
+
end
|
|
49
|
+
|
|
40
50
|
# @return [Class]
|
|
41
51
|
attr_reader :node_type
|
|
42
52
|
|
|
@@ -186,7 +196,7 @@ module GraphQL
|
|
|
186
196
|
def edges
|
|
187
197
|
# Assume that whatever authorization needed to happen
|
|
188
198
|
# already happened at the connection level.
|
|
189
|
-
current_runtime_state =
|
|
199
|
+
current_runtime_state = Fiber[:__graphql_runtime_info]
|
|
190
200
|
query_runtime_state = current_runtime_state[context.query]
|
|
191
201
|
query_runtime_state.was_authorized_by_scope_items = @object.was_authorized_by_scope_items?
|
|
192
202
|
@object.edges
|
|
@@ -195,7 +205,7 @@ module GraphQL
|
|
|
195
205
|
def nodes
|
|
196
206
|
# Assume that whatever authorization needed to happen
|
|
197
207
|
# already happened at the connection level.
|
|
198
|
-
current_runtime_state =
|
|
208
|
+
current_runtime_state = Fiber[:__graphql_runtime_info]
|
|
199
209
|
query_runtime_state = current_runtime_state[context.query]
|
|
200
210
|
query_runtime_state.was_authorized_by_scope_items = @object.was_authorized_by_scope_items?
|
|
201
211
|
@object.nodes
|
|
@@ -10,10 +10,11 @@ module GraphQL
|
|
|
10
10
|
child_class.extend(ClassMethods)
|
|
11
11
|
child_class.class_exec { self.node_type = nil }
|
|
12
12
|
child_class.node_nullable(true)
|
|
13
|
+
child_class.default_broadcastable(nil)
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def node
|
|
16
|
-
current_runtime_state =
|
|
17
|
+
current_runtime_state = Fiber[:__graphql_runtime_info]
|
|
17
18
|
query_runtime_state = current_runtime_state[context.query]
|
|
18
19
|
query_runtime_state.was_authorized_by_scope_items = @object.was_authorized_by_scope_items?
|
|
19
20
|
@object.node
|
|
@@ -24,12 +25,21 @@ module GraphQL
|
|
|
24
25
|
super
|
|
25
26
|
child_class.node_type = nil
|
|
26
27
|
child_class.node_nullable = nil
|
|
28
|
+
child_class.default_broadcastable(default_broadcastable?)
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def default_relay?
|
|
30
32
|
true
|
|
31
33
|
end
|
|
32
34
|
|
|
35
|
+
def default_broadcastable?
|
|
36
|
+
@default_broadcastable
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def default_broadcastable(new_value)
|
|
40
|
+
@default_broadcastable = new_value
|
|
41
|
+
end
|
|
42
|
+
|
|
33
43
|
# Get or set the Object type that this edge wraps.
|
|
34
44
|
#
|
|
35
45
|
# @param node_type [Class] A `Schema::Object` subclass
|
data/lib/graphql/types.rb
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
|
|
3
|
+
module GraphQL
|
|
4
|
+
module Types
|
|
5
|
+
extend Autoload
|
|
6
|
+
|
|
7
|
+
autoload :Boolean, "graphql/types/boolean"
|
|
8
|
+
autoload :BigInt, "graphql/types/big_int"
|
|
9
|
+
autoload :Float, "graphql/types/float"
|
|
10
|
+
autoload :ID, "graphql/types/id"
|
|
11
|
+
autoload :Int, "graphql/types/int"
|
|
12
|
+
autoload :JSON, "graphql/types/json"
|
|
13
|
+
autoload :String, "graphql/types/string"
|
|
14
|
+
autoload :ISO8601Date, "graphql/types/iso_8601_date"
|
|
15
|
+
autoload :ISO8601DateTime, "graphql/types/iso_8601_date_time"
|
|
16
|
+
autoload :ISO8601Duration, "graphql/types/iso_8601_duration"
|
|
17
|
+
autoload :Relay, "graphql/types/relay"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module GraphQL
|
|
3
|
+
class UnauthorizedEnumValueError < GraphQL::UnauthorizedError
|
|
4
|
+
# @return [GraphQL::Schema::EnumValue] The value whose `#authorized?` check returned false
|
|
5
|
+
attr_accessor :enum_value
|
|
6
|
+
|
|
7
|
+
def initialize(type:, context:, enum_value:)
|
|
8
|
+
@enum_value = enum_value
|
|
9
|
+
message ||= "#{enum_value.path} failed authorization"
|
|
10
|
+
super(message, object: enum_value.value, type: type, context: context)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/graphql/version.rb
CHANGED
data/lib/graphql.rb
CHANGED
|
@@ -4,14 +4,18 @@ require "json"
|
|
|
4
4
|
require "set"
|
|
5
5
|
require "singleton"
|
|
6
6
|
require "forwardable"
|
|
7
|
+
require "fiber/storage" if RUBY_VERSION < "3.2.0"
|
|
8
|
+
require "graphql/autoload"
|
|
7
9
|
|
|
8
10
|
module GraphQL
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
extend Autoload
|
|
12
|
+
|
|
13
|
+
# Load all `autoload`-configured classes, and also eager-load dependents who have autoloads of their own.
|
|
14
|
+
def self.eager_load!
|
|
15
|
+
super
|
|
16
|
+
Query.eager_load!
|
|
17
|
+
Types.eager_load!
|
|
18
|
+
Schema.eager_load!
|
|
15
19
|
end
|
|
16
20
|
|
|
17
21
|
class Error < StandardError
|
|
@@ -42,8 +46,8 @@ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: http
|
|
|
42
46
|
# Turn a query string or schema definition into an AST
|
|
43
47
|
# @param graphql_string [String] a GraphQL query string or schema definition
|
|
44
48
|
# @return [GraphQL::Language::Nodes::Document]
|
|
45
|
-
def self.parse(graphql_string, trace: GraphQL::Tracing::NullTrace, filename: nil)
|
|
46
|
-
default_parser.parse(graphql_string, trace: trace, filename: filename)
|
|
49
|
+
def self.parse(graphql_string, trace: GraphQL::Tracing::NullTrace, filename: nil, max_tokens: nil)
|
|
50
|
+
default_parser.parse(graphql_string, trace: trace, filename: filename, max_tokens: max_tokens)
|
|
47
51
|
end
|
|
48
52
|
|
|
49
53
|
# Read the contents of `filename` and parse them as GraphQL
|
|
@@ -68,57 +72,63 @@ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: http
|
|
|
68
72
|
GraphQL::Language::Lexer.tokenize(graphql_string)
|
|
69
73
|
end
|
|
70
74
|
|
|
71
|
-
NOT_CONFIGURED = Object.new
|
|
75
|
+
NOT_CONFIGURED = Object.new.freeze
|
|
72
76
|
private_constant :NOT_CONFIGURED
|
|
73
77
|
module EmptyObjects
|
|
74
78
|
EMPTY_HASH = {}.freeze
|
|
75
79
|
EMPTY_ARRAY = [].freeze
|
|
76
80
|
end
|
|
77
|
-
end
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
82
|
+
class << self
|
|
83
|
+
# If true, the parser should raise when an integer or float is followed immediately by an identifier (instead of a space or punctuation)
|
|
84
|
+
attr_accessor :reject_numbers_followed_by_names
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
self.reject_numbers_followed_by_names = false
|
|
88
|
+
|
|
89
|
+
autoload :ExecutionError, "graphql/execution_error"
|
|
90
|
+
autoload :RuntimeTypeError, "graphql/runtime_type_error"
|
|
91
|
+
autoload :UnresolvedTypeError, "graphql/unresolved_type_error"
|
|
92
|
+
autoload :InvalidNullError, "graphql/invalid_null_error"
|
|
93
|
+
autoload :AnalysisError, "graphql/analysis_error"
|
|
94
|
+
autoload :CoercionError, "graphql/coercion_error"
|
|
95
|
+
autoload :InvalidNameError, "graphql/invalid_name_error"
|
|
96
|
+
autoload :IntegerDecodingError, "graphql/integer_decoding_error"
|
|
97
|
+
autoload :IntegerEncodingError, "graphql/integer_encoding_error"
|
|
98
|
+
autoload :StringEncodingError, "graphql/string_encoding_error"
|
|
99
|
+
autoload :DateEncodingError, "graphql/date_encoding_error"
|
|
100
|
+
autoload :DurationEncodingError, "graphql/duration_encoding_error"
|
|
101
|
+
autoload :TypeKinds, "graphql/type_kinds"
|
|
102
|
+
autoload :NameValidator, "graphql/name_validator"
|
|
103
|
+
autoload :Language, "graphql/language"
|
|
104
|
+
|
|
105
|
+
autoload :Analysis, "graphql/analysis"
|
|
106
|
+
autoload :Tracing, "graphql/tracing"
|
|
107
|
+
autoload :Dig, "graphql/dig"
|
|
108
|
+
autoload :Execution, "graphql/execution"
|
|
109
|
+
autoload :Pagination, "graphql/pagination"
|
|
110
|
+
autoload :Schema, "graphql/schema"
|
|
111
|
+
autoload :Query, "graphql/query"
|
|
112
|
+
autoload :Dataloader, "graphql/dataloader"
|
|
113
|
+
autoload :Types, "graphql/types"
|
|
114
|
+
autoload :StaticValidation, "graphql/static_validation"
|
|
115
|
+
autoload :Execution, "graphql/execution"
|
|
116
|
+
autoload :Introspection, "graphql/introspection"
|
|
117
|
+
autoload :Relay, "graphql/relay"
|
|
118
|
+
autoload :Subscriptions, "graphql/subscriptions"
|
|
119
|
+
autoload :ParseError, "graphql/parse_error"
|
|
120
|
+
autoload :Backtrace, "graphql/backtrace"
|
|
121
|
+
|
|
122
|
+
autoload :UnauthorizedError, "graphql/unauthorized_error"
|
|
123
|
+
autoload :UnauthorizedEnumValueError, "graphql/unauthorized_enum_value_error"
|
|
124
|
+
autoload :UnauthorizedFieldError, "graphql/unauthorized_field_error"
|
|
125
|
+
autoload :LoadApplicationObjectFailedError, "graphql/load_application_object_failed_error"
|
|
126
|
+
autoload :Testing, "graphql/testing"
|
|
127
|
+
autoload :Current, "graphql/current"
|
|
128
|
+
if defined?(::Rails::Engine)
|
|
129
|
+
autoload :Dashboard, 'graphql/dashboard'
|
|
130
|
+
end
|
|
131
|
+
end
|
|
115
132
|
|
|
116
133
|
require "graphql/version"
|
|
117
|
-
require "graphql/
|
|
118
|
-
require "graphql/parse_error"
|
|
119
|
-
require "graphql/backtrace"
|
|
120
|
-
|
|
121
|
-
require "graphql/unauthorized_error"
|
|
122
|
-
require "graphql/unauthorized_field_error"
|
|
123
|
-
require "graphql/load_application_object_failed_error"
|
|
124
|
-
require "graphql/testing"
|
|
134
|
+
require "graphql/railtie" if defined? Rails::Railtie
|