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
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<% content_for(:title, "Subscriptions - Topics") %>
|
|
2
|
+
<div class="row mt-3 justify-content-between">
|
|
3
|
+
<div class="col-auto">
|
|
4
|
+
<h3>
|
|
5
|
+
<%= pluralize(@all_topics_count, "Subscription Topic") %>
|
|
6
|
+
</h3>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="col-auto">
|
|
9
|
+
<%= button_tag "Clear All", class: "btn btn-outline-danger", data: { subscriptions_delete_all: graphql_dashboard.subscriptions_clear_all_path } %>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<table class="table table-striped">
|
|
14
|
+
<thead>
|
|
15
|
+
<tr>
|
|
16
|
+
<th>Name</th>
|
|
17
|
+
<th># Subscriptions</th>
|
|
18
|
+
<th>Last Triggered At</th>
|
|
19
|
+
</tr>
|
|
20
|
+
</thead>
|
|
21
|
+
<tbody>
|
|
22
|
+
<% if @all_topics_count == 0 %>
|
|
23
|
+
<tr>
|
|
24
|
+
<td colspan="3" class="text-center">
|
|
25
|
+
<em>There aren't any subscriptions right now.</em>
|
|
26
|
+
</td>
|
|
27
|
+
</tr>
|
|
28
|
+
<% else %>
|
|
29
|
+
<% @topics.each do |topic| %>
|
|
30
|
+
<tr>
|
|
31
|
+
<td><%= link_to(topic.name, graphql_dashboard.subscriptions_topic_path(name: topic.name)) %></td>
|
|
32
|
+
<td><%= topic.subscriptions_count %></td>
|
|
33
|
+
<td><%= topic.last_triggered_at || "--" %></td>
|
|
34
|
+
</tr>
|
|
35
|
+
<% end %>
|
|
36
|
+
<% end %>
|
|
37
|
+
</tbody>
|
|
38
|
+
</table>
|
|
39
|
+
|
|
40
|
+
<div class="row">
|
|
41
|
+
<div class="col-auto">
|
|
42
|
+
<% if @page > 1 %>
|
|
43
|
+
<%= link_to("« prev", graphql_dashboard.subscriptions_topics_path(per_page: params[:per_page], page: @page - 1), class: "btn btn-outline-secondary") %>
|
|
44
|
+
<% else %>
|
|
45
|
+
<button class="btn btn-outline-secondary" disabled>« prev</button>
|
|
46
|
+
<% end %>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="col-auto">
|
|
49
|
+
<% if @has_next_page %>
|
|
50
|
+
<%= link_to("next »", graphql_dashboard.subscriptions_topics_path(per_page: params[:per_page], page: @page + 1), class: "btn btn-outline-secondary") %>
|
|
51
|
+
<% else %>
|
|
52
|
+
<button class="btn btn-outline-secondary" disabled>next »</button>
|
|
53
|
+
<% end %>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<%= content_for(:title, "Subscriptions - #{params[:name]}") %>
|
|
2
|
+
<div class="row mt-3">
|
|
3
|
+
<div class="col">
|
|
4
|
+
<h3>Topic: <code><%= params[:name] %></code></h3>
|
|
5
|
+
</div>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<div class="row">
|
|
9
|
+
<div class="col">
|
|
10
|
+
<p>Last triggered: <%= @topic_last_triggered_at || "none" %></p>
|
|
11
|
+
<p><%= pluralize(@subscriptions_count, "Subscription") %></p>
|
|
12
|
+
<div>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div class="row">
|
|
16
|
+
<div class="col">
|
|
17
|
+
<table class="table table-striped">
|
|
18
|
+
<thead>
|
|
19
|
+
<tr>
|
|
20
|
+
<th>Subscription ID</th>
|
|
21
|
+
<th>Created At</th>
|
|
22
|
+
<th>Subscribed?</th>
|
|
23
|
+
<th>Broadcast?</th>
|
|
24
|
+
<% if @show_broadcast_subscribers_count %><th>Subscribers</th><% end %>
|
|
25
|
+
</tr>
|
|
26
|
+
</thead>
|
|
27
|
+
<tbody>
|
|
28
|
+
<% @subscriptions.each do |subscription| %>
|
|
29
|
+
<tr>
|
|
30
|
+
<td><%= link_to(subscription[:id], graphql_dashboard.subscriptions_subscription_path(subscription[:id])) %></td>
|
|
31
|
+
<td><%= subscription[:created_at] %></td>
|
|
32
|
+
<td><code><%= subscription[:still_subscribed] ? "YES" : "NO" %></code></td>
|
|
33
|
+
<td><code><%= subscription[:is_broadcast] ? "YES" : "NO" %></code></td>
|
|
34
|
+
<% if @show_broadcast_subscribers_count %><td><%= subscription[:subscribers_count] %></td><% end %>
|
|
35
|
+
</tr>
|
|
36
|
+
<% end %>
|
|
37
|
+
</tbody>
|
|
38
|
+
</table>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" class="h-100" >
|
|
3
|
+
<head>
|
|
4
|
+
<link rel="icon" type="image/png" href="<%= graphql_dashboard.static_path("icon.png") %>" />
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
<title>GraphQL Dashboard <%= content_for?(:title) ? " · #{content_for(:title)}" : "" %> </title>
|
|
8
|
+
<%= stylesheet_link_tag graphql_dashboard.static_path("bootstrap-5.3.3.min.css") %>
|
|
9
|
+
<%= stylesheet_link_tag graphql_dashboard.static_path("charts.min.css") %>
|
|
10
|
+
<%= stylesheet_link_tag graphql_dashboard.static_path("dashboard.css") %>
|
|
11
|
+
<%= javascript_include_tag graphql_dashboard.static_path("bootstrap-5.3.3.min.js") %>
|
|
12
|
+
<%= javascript_include_tag graphql_dashboard.static_path("dashboard.js") %>
|
|
13
|
+
<%= csrf_meta_tags %>
|
|
14
|
+
</head>
|
|
15
|
+
<body class="h-100 d-flex flex-column">
|
|
16
|
+
<main class="flex-shrink-0">
|
|
17
|
+
<div class="container-fluid">
|
|
18
|
+
<div class="row">
|
|
19
|
+
<div class="col gx-0">
|
|
20
|
+
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
21
|
+
<div class="container-fluid">
|
|
22
|
+
<%= link_to graphql_dashboard.root_path, class: "navbar-brand" do %>
|
|
23
|
+
<img id="header-icon" src="<%= graphql_dashboard.static_path("header-icon.png") %>" alt="GraphQL-Ruby" />
|
|
24
|
+
<% end %>
|
|
25
|
+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
|
26
|
+
<span class="navbar-toggler-icon"></span>
|
|
27
|
+
</button>
|
|
28
|
+
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
|
29
|
+
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
30
|
+
<li class="nav-item">
|
|
31
|
+
<%= link_to "Traces", graphql_dashboard.detailed_traces_traces_path, class: "nav-link #{params[:controller] == "graphql/dashboard/detailed_traces" ? "active" : ""}" %>
|
|
32
|
+
</li>
|
|
33
|
+
<li class="nav-item dropdown">
|
|
34
|
+
<a class="nav-link dropdown-toggle <%= params[:controller].include?("operation_store") ? "active" : "" %>" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
35
|
+
Persisted Operations
|
|
36
|
+
</a>
|
|
37
|
+
<ul class="dropdown-menu">
|
|
38
|
+
<li>
|
|
39
|
+
<%= link_to "Clients", graphql_dashboard.operation_store_clients_path, class: "dropdown-item" %>
|
|
40
|
+
</li>
|
|
41
|
+
<li>
|
|
42
|
+
<%= link_to "Operations", graphql_dashboard.operation_store_operations_path, class: "dropdown-item" %>
|
|
43
|
+
</li>
|
|
44
|
+
<li>
|
|
45
|
+
<%= link_to "Index", graphql_dashboard.operation_store_index_entries_path, class: "dropdown-item" %>
|
|
46
|
+
</li>
|
|
47
|
+
</ul>
|
|
48
|
+
</li>
|
|
49
|
+
<li class="nav-item">
|
|
50
|
+
<%= link_to "Subscriptions", graphql_dashboard.subscriptions_topics_path, class: "nav-link #{params[:controller] == "graphql/dashboard/subscriptions" ? "active" : ""}" %>
|
|
51
|
+
</li>
|
|
52
|
+
<li class="nav-item dropdown">
|
|
53
|
+
<a class="nav-link dropdown-toggle <%= params[:controller].include?("limiters") ? "active" : "" %>" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
54
|
+
Rate Limiters
|
|
55
|
+
</a>
|
|
56
|
+
<ul class="dropdown-menu">
|
|
57
|
+
<li>
|
|
58
|
+
<%= link_to "Runtime", graphql_dashboard.limiters_limiter_path("runtime", chart: params[:chart]), class: "dropdown-item" %>
|
|
59
|
+
</li>
|
|
60
|
+
<li>
|
|
61
|
+
<%= link_to "Active Operations", graphql_dashboard.limiters_limiter_path("active_operations", chart: params[:chart]), class: "dropdown-item" %>
|
|
62
|
+
</li>
|
|
63
|
+
<% if schema_class.respond_to?(:enterprise_mutation_limiter) && schema_class.enterprise_mutation_limiter %>
|
|
64
|
+
<li>
|
|
65
|
+
<%= link_to "Mutations", graphql_dashboard.limiters_limiter_path("mutations", chart: params[:chart]), class: "dropdown-item" %>
|
|
66
|
+
</li>
|
|
67
|
+
<% end %>
|
|
68
|
+
</ul>
|
|
69
|
+
</li>
|
|
70
|
+
</ul>
|
|
71
|
+
<span class="navbar-text pe-2">
|
|
72
|
+
<%= link_to ".", "#", class: "nav-link", id: "themeToggle" %>
|
|
73
|
+
</span>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</nav>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
<% flash.each do |flash_type, flash_message| %>
|
|
80
|
+
<div class="row mt-2">
|
|
81
|
+
<div class="col">
|
|
82
|
+
<div class="alert alert-<%= flash_type %> alert-dismissible fade show" role="alert">
|
|
83
|
+
<%= flash_message %>
|
|
84
|
+
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
<% end %>
|
|
89
|
+
</div>
|
|
90
|
+
<div class="container-fluid">
|
|
91
|
+
<%= yield %>
|
|
92
|
+
</div>
|
|
93
|
+
</main>
|
|
94
|
+
<footer class="mt-auto">
|
|
95
|
+
<div class="container-fluid">
|
|
96
|
+
<div class="sticky-bottom">
|
|
97
|
+
<div class="row bg-body-tertiary">
|
|
98
|
+
<div class="col gx-0 px-4">
|
|
99
|
+
<p class="fs-6 text-center pt-2 text-muted">
|
|
100
|
+
<em>GraphQL-Ruby v<%= GraphQL::VERSION %></em> · <code><%= schema_class %></code>
|
|
101
|
+
</p>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</footer>
|
|
107
|
+
</body>
|
|
108
|
+
</html>
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'rails/engine'
|
|
3
|
+
module Graphql
|
|
4
|
+
# `GraphQL::Dashboard` is a `Rails::Engine`-based dashboard for viewing metadata about your GraphQL schema.
|
|
5
|
+
#
|
|
6
|
+
# Pass the class name of your schema when mounting it.
|
|
7
|
+
# @see GraphQL::Tracing::DetailedTrace DetailedTrace for viewing production traces in the Dashboard
|
|
8
|
+
#
|
|
9
|
+
# @example Mounting the Dashboard in your app
|
|
10
|
+
# mount GraphQL::Dashboard, at: "graphql_dashboard", schema: "MySchema"
|
|
11
|
+
#
|
|
12
|
+
# @example Authenticating the Dashboard with HTTP Basic Auth
|
|
13
|
+
# # config/initializers/graphql_dashboard.rb
|
|
14
|
+
# GraphQL::Dashboard.middleware.use(Rack::Auth::Basic) do |username, password|
|
|
15
|
+
# # Compare the provided username/password to an application setting:
|
|
16
|
+
# ActiveSupport::SecurityUtils.secure_compare(Rails.application.credentials.graphql_dashboard_username, username) &&
|
|
17
|
+
# ActiveSupport::SecurityUtils.secure_compare(Rails.application.credentials.graphql_dashboard_username, password)
|
|
18
|
+
# end
|
|
19
|
+
#
|
|
20
|
+
# @example Custom Rails authentication
|
|
21
|
+
# # config/initializers/graphql_dashboard.rb
|
|
22
|
+
# ActiveSupport.on_load(:graphql_dashboard_application_controller) do
|
|
23
|
+
# # context here is GraphQL::Dashboard::ApplicationController
|
|
24
|
+
#
|
|
25
|
+
# before_action do
|
|
26
|
+
# raise ActionController::RoutingError.new('Not Found') unless current_user&.admin?
|
|
27
|
+
# end
|
|
28
|
+
#
|
|
29
|
+
# def current_user
|
|
30
|
+
# # load current user
|
|
31
|
+
# end
|
|
32
|
+
# end
|
|
33
|
+
#
|
|
34
|
+
class Dashboard < Rails::Engine
|
|
35
|
+
engine_name "graphql_dashboard"
|
|
36
|
+
isolate_namespace(Graphql::Dashboard)
|
|
37
|
+
routes.draw do
|
|
38
|
+
root "landings#show"
|
|
39
|
+
resources :statics, only: :show, constraints: { id: /[0-9A-Za-z\-.]+/ }
|
|
40
|
+
|
|
41
|
+
namespace :detailed_traces do
|
|
42
|
+
resources :traces, only: [:index, :show, :destroy] do
|
|
43
|
+
collection do
|
|
44
|
+
delete :delete_all, to: "traces#delete_all", as: :delete_all
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
namespace :limiters do
|
|
50
|
+
resources :limiters, only: [:show, :update], param: :name
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
namespace :operation_store do
|
|
54
|
+
resources :clients, param: :name do
|
|
55
|
+
resources :operations, param: :digest, only: [:index] do
|
|
56
|
+
collection do
|
|
57
|
+
get :archived, to: "operations#index", archived_status: :archived, as: :archived
|
|
58
|
+
post :archive, to: "operations#update", modification: :archive, as: :archive
|
|
59
|
+
post :unarchive, to: "operations#update", modification: :unarchive, as: :unarchive
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
resources :operations, param: :digest, only: [:index, :show] do
|
|
65
|
+
collection do
|
|
66
|
+
get :archived, to: "operations#index", archived_status: :archived, as: :archived
|
|
67
|
+
post :archive, to: "operations#update", modification: :archive, as: :archive
|
|
68
|
+
post :unarchive, to: "operations#update", modification: :unarchive, as: :unarchive
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
resources :index_entries, only: [:index, :show], param: :name, constraints: { name: /[A-Za-z0-9_.]+/}
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
namespace :subscriptions do
|
|
75
|
+
resources :topics, only: [:index, :show], param: :name, constraints: { name: /.*/ }
|
|
76
|
+
resources :subscriptions, only: [:show], constraints: { id: /[a-zA-Z0-9\-]+/ }
|
|
77
|
+
post "/subscriptions/clear_all", to: "subscriptions#clear_all", as: :clear_all
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
class ApplicationController < ActionController::Base
|
|
82
|
+
protect_from_forgery with: :exception
|
|
83
|
+
prepend_view_path(File.join(__FILE__, "../dashboard/views"))
|
|
84
|
+
|
|
85
|
+
content_security_policy do |policy|
|
|
86
|
+
policy.default_src(:self) if policy.default_src(*policy.default_src).blank?
|
|
87
|
+
policy.connect_src(:self) if policy.connect_src(*policy.connect_src).blank?
|
|
88
|
+
policy.base_uri(:none) if policy.base_uri(*policy.base_uri).blank?
|
|
89
|
+
policy.font_src(:self) if policy.font_src(*policy.font_src).blank?
|
|
90
|
+
policy.img_src(:self, :data) if policy.img_src(*policy.img_src).blank?
|
|
91
|
+
policy.object_src(:none) if policy.object_src(*policy.object_src).blank?
|
|
92
|
+
policy.script_src(:self) if policy.script_src(*policy.script_src).blank?
|
|
93
|
+
policy.style_src(:self) if policy.style_src(*policy.style_src).blank?
|
|
94
|
+
policy.form_action(:self) if policy.form_action(*policy.form_action).blank?
|
|
95
|
+
policy.frame_ancestors(:none) if policy.frame_ancestors(*policy.frame_ancestors).blank?
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def schema_class
|
|
99
|
+
@schema_class ||= begin
|
|
100
|
+
schema_param = request.query_parameters["schema"] || params[:schema]
|
|
101
|
+
case schema_param
|
|
102
|
+
when Class
|
|
103
|
+
schema_param
|
|
104
|
+
when String
|
|
105
|
+
schema_param.constantize
|
|
106
|
+
else
|
|
107
|
+
raise "Missing `params[:schema]`, please provide a class or string to `mount GraphQL::Dashboard, schema: ...`"
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
helper_method :schema_class
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
class LandingsController < ApplicationController
|
|
115
|
+
def show
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
class StaticsController < ApplicationController
|
|
120
|
+
skip_after_action :verify_same_origin_request
|
|
121
|
+
# Use an explicit list of files to avoid any chance of reading other files from disk
|
|
122
|
+
STATICS = {}
|
|
123
|
+
|
|
124
|
+
[
|
|
125
|
+
"icon.png",
|
|
126
|
+
"header-icon.png",
|
|
127
|
+
"charts.min.css",
|
|
128
|
+
"dashboard.css",
|
|
129
|
+
"dashboard.js",
|
|
130
|
+
"bootstrap-5.3.3.min.css",
|
|
131
|
+
"bootstrap-5.3.3.min.js",
|
|
132
|
+
].each do |static_file|
|
|
133
|
+
STATICS[static_file] = File.expand_path("../dashboard/statics/#{static_file}", __FILE__)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def show
|
|
137
|
+
expires_in 1.year, public: true
|
|
138
|
+
if (filepath = STATICS[params[:id]])
|
|
139
|
+
render file: filepath
|
|
140
|
+
else
|
|
141
|
+
head :not_found
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
require 'graphql/dashboard/detailed_traces'
|
|
149
|
+
require 'graphql/dashboard/limiters'
|
|
150
|
+
require 'graphql/dashboard/operation_store'
|
|
151
|
+
require 'graphql/dashboard/subscriptions'
|
|
152
|
+
|
|
153
|
+
# Rails expects the engine to be called `Graphql::Dashboard`,
|
|
154
|
+
# but `GraphQL::Dashboard` is consistent with this gem's naming.
|
|
155
|
+
# So define both constants to refer to the same class.
|
|
156
|
+
GraphQL::Dashboard = Graphql::Dashboard
|
|
157
|
+
|
|
158
|
+
ActiveSupport.run_load_hooks(:graphql_dashboard_application_controller, GraphQL::Dashboard::ApplicationController)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "graphql/dataloader/source"
|
|
3
|
+
require "graphql/dataloader/active_record_source"
|
|
4
|
+
|
|
5
|
+
module GraphQL
|
|
6
|
+
class Dataloader
|
|
7
|
+
class ActiveRecordAssociationSource < GraphQL::Dataloader::Source
|
|
8
|
+
RECORD_SOURCE_CLASS = ActiveRecordSource
|
|
9
|
+
|
|
10
|
+
def initialize(association, scope = nil)
|
|
11
|
+
@association = association
|
|
12
|
+
@scope = scope
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.batch_key_for(association, scope = nil)
|
|
16
|
+
if scope
|
|
17
|
+
[association, scope.to_sql]
|
|
18
|
+
else
|
|
19
|
+
[association]
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def load(record)
|
|
24
|
+
if (assoc = record.association(@association)).loaded?
|
|
25
|
+
assoc.target
|
|
26
|
+
else
|
|
27
|
+
super
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def fetch(records)
|
|
32
|
+
record_classes = Set.new.compare_by_identity
|
|
33
|
+
associated_classes = Set.new.compare_by_identity
|
|
34
|
+
scoped_fetch = !@scope.nil?
|
|
35
|
+
records.each do |record|
|
|
36
|
+
if scoped_fetch
|
|
37
|
+
assoc = record.association(@association)
|
|
38
|
+
assoc.reset
|
|
39
|
+
end
|
|
40
|
+
if record_classes.add?(record.class)
|
|
41
|
+
reflection = record.class.reflect_on_association(@association)
|
|
42
|
+
if !reflection.polymorphic? && reflection.klass
|
|
43
|
+
associated_classes.add(reflection.klass)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
available_records = []
|
|
49
|
+
associated_classes.each do |assoc_class|
|
|
50
|
+
already_loaded_records = dataloader.with(RECORD_SOURCE_CLASS, assoc_class).results.values
|
|
51
|
+
available_records.concat(already_loaded_records)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
::ActiveRecord::Associations::Preloader.new(records: records, associations: @association, available_records: available_records, scope: @scope).call
|
|
55
|
+
|
|
56
|
+
loaded_associated_records = records.map { |r|
|
|
57
|
+
assoc = r.association(@association)
|
|
58
|
+
lar = assoc.target
|
|
59
|
+
if scoped_fetch
|
|
60
|
+
assoc.reset
|
|
61
|
+
end
|
|
62
|
+
lar
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if !scoped_fetch
|
|
66
|
+
# Don't cache records loaded via scope because they might have reduced `SELECT`s
|
|
67
|
+
# Could check .select_values here?
|
|
68
|
+
records_by_model = {}
|
|
69
|
+
loaded_associated_records.flatten.each do |record|
|
|
70
|
+
if record
|
|
71
|
+
updates = records_by_model[record.class] ||= {}
|
|
72
|
+
updates[record.id] = record
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
records_by_model.each do |model_class, updates|
|
|
76
|
+
dataloader.with(RECORD_SOURCE_CLASS, model_class).merge(updates)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
loaded_associated_records
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "graphql/dataloader/source"
|
|
3
|
+
|
|
4
|
+
module GraphQL
|
|
5
|
+
class Dataloader
|
|
6
|
+
class ActiveRecordSource < GraphQL::Dataloader::Source
|
|
7
|
+
def initialize(model_class, find_by: model_class.primary_key)
|
|
8
|
+
@model_class = model_class
|
|
9
|
+
@find_by = find_by
|
|
10
|
+
@find_by_many = find_by.is_a?(Array)
|
|
11
|
+
if @find_by_many
|
|
12
|
+
@type_for_column = @find_by.map { |fb| @model_class.type_for_attribute(fb) }
|
|
13
|
+
else
|
|
14
|
+
@type_for_column = @model_class.type_for_attribute(@find_by)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def result_key_for(requested_key)
|
|
19
|
+
normalize_fetch_key(requested_key)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def normalize_fetch_key(requested_key)
|
|
23
|
+
if @find_by_many
|
|
24
|
+
requested_key.each_with_index.map do |k, idx|
|
|
25
|
+
@type_for_column[idx].cast(k)
|
|
26
|
+
end
|
|
27
|
+
else
|
|
28
|
+
@type_for_column.cast(requested_key)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def fetch(record_ids)
|
|
33
|
+
records = @model_class.where(@find_by => record_ids)
|
|
34
|
+
record_lookup = {}
|
|
35
|
+
if @find_by_many
|
|
36
|
+
records.each do |r|
|
|
37
|
+
key = @find_by.map { |fb| r.public_send(fb) }
|
|
38
|
+
record_lookup[key] = r
|
|
39
|
+
end
|
|
40
|
+
else
|
|
41
|
+
records.each { |r| record_lookup[r.public_send(@find_by)] = r }
|
|
42
|
+
end
|
|
43
|
+
record_ids.map { |id| record_lookup[id] }
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -2,16 +2,21 @@
|
|
|
2
2
|
module GraphQL
|
|
3
3
|
class Dataloader
|
|
4
4
|
class AsyncDataloader < Dataloader
|
|
5
|
-
def yield
|
|
6
|
-
|
|
5
|
+
def yield(source = Fiber[:__graphql_current_dataloader_source])
|
|
6
|
+
trace = Fiber[:__graphql_current_multiplex]&.current_trace
|
|
7
|
+
trace&.dataloader_fiber_yield(source)
|
|
8
|
+
if (condition = Fiber[:graphql_dataloader_next_tick])
|
|
7
9
|
condition.wait
|
|
8
10
|
else
|
|
9
11
|
Fiber.yield
|
|
10
12
|
end
|
|
13
|
+
trace&.dataloader_fiber_resume(source)
|
|
11
14
|
nil
|
|
12
15
|
end
|
|
13
16
|
|
|
14
|
-
def run
|
|
17
|
+
def run(trace_query_lazy: nil)
|
|
18
|
+
trace = Fiber[:__graphql_current_multiplex]&.current_trace
|
|
19
|
+
jobs_fiber_limit, total_fiber_limit = calculate_fiber_limit
|
|
15
20
|
job_fibers = []
|
|
16
21
|
next_job_fibers = []
|
|
17
22
|
source_tasks = []
|
|
@@ -19,23 +24,17 @@ module GraphQL
|
|
|
19
24
|
first_pass = true
|
|
20
25
|
sources_condition = Async::Condition.new
|
|
21
26
|
manager = spawn_fiber do
|
|
22
|
-
|
|
27
|
+
trace&.begin_dataloader(self)
|
|
28
|
+
while first_pass || !job_fibers.empty?
|
|
23
29
|
first_pass = false
|
|
30
|
+
fiber_vars = get_fiber_variables
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
if f.alive?
|
|
27
|
-
finished = run_fiber(f)
|
|
28
|
-
if !finished
|
|
29
|
-
next_job_fibers << f
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
job_fibers.concat(next_job_fibers)
|
|
34
|
-
next_job_fibers.clear
|
|
32
|
+
run_pending_steps(job_fibers, next_job_fibers, source_tasks, jobs_fiber_limit, trace)
|
|
35
33
|
|
|
36
34
|
Sync do |root_task|
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
set_fiber_variables(fiber_vars)
|
|
36
|
+
while !source_tasks.empty? || @source_cache.each_value.any? { |group_sources| group_sources.each_value.any?(&:pending?) }
|
|
37
|
+
while (task = (source_tasks.shift || (((job_fibers.size + next_job_fibers.size + source_tasks.size + next_source_tasks.size) < total_fiber_limit) && spawn_source_task(root_task, sources_condition, trace))))
|
|
39
38
|
if task.alive?
|
|
40
39
|
root_task.yield # give the source task a chance to run
|
|
41
40
|
next_source_tasks << task
|
|
@@ -46,7 +45,15 @@ module GraphQL
|
|
|
46
45
|
next_source_tasks.clear
|
|
47
46
|
end
|
|
48
47
|
end
|
|
48
|
+
|
|
49
|
+
if !@lazies_at_depth.empty?
|
|
50
|
+
with_trace_query_lazy(trace_query_lazy) do
|
|
51
|
+
run_next_pending_lazies(job_fibers, trace)
|
|
52
|
+
run_pending_steps(job_fibers, next_job_fibers, source_tasks, jobs_fiber_limit, trace)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
49
55
|
end
|
|
56
|
+
trace&.end_dataloader(self)
|
|
50
57
|
end
|
|
51
58
|
|
|
52
59
|
manager.resume
|
|
@@ -60,7 +67,20 @@ module GraphQL
|
|
|
60
67
|
|
|
61
68
|
private
|
|
62
69
|
|
|
63
|
-
def
|
|
70
|
+
def run_pending_steps(job_fibers, next_job_fibers, source_tasks, jobs_fiber_limit, trace)
|
|
71
|
+
while (f = (job_fibers.shift || (((job_fibers.size + next_job_fibers.size + source_tasks.size) < jobs_fiber_limit) && spawn_job_fiber(trace))))
|
|
72
|
+
if f.alive?
|
|
73
|
+
finished = run_fiber(f)
|
|
74
|
+
if !finished
|
|
75
|
+
next_job_fibers << f
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
job_fibers.concat(next_job_fibers)
|
|
80
|
+
next_job_fibers.clear
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def spawn_source_task(parent_task, condition, trace)
|
|
64
84
|
pending_sources = nil
|
|
65
85
|
@source_cache.each_value do |source_by_batch_params|
|
|
66
86
|
source_by_batch_params.each_value do |source|
|
|
@@ -74,9 +94,16 @@ module GraphQL
|
|
|
74
94
|
if pending_sources
|
|
75
95
|
fiber_vars = get_fiber_variables
|
|
76
96
|
parent_task.async do
|
|
97
|
+
trace&.dataloader_spawn_source_fiber(pending_sources)
|
|
77
98
|
set_fiber_variables(fiber_vars)
|
|
78
|
-
|
|
79
|
-
pending_sources.each
|
|
99
|
+
Fiber[:graphql_dataloader_next_tick] = condition
|
|
100
|
+
pending_sources.each do |s|
|
|
101
|
+
trace&.begin_dataloader_source(s)
|
|
102
|
+
s.run_pending_keys
|
|
103
|
+
trace&.end_dataloader_source(s)
|
|
104
|
+
end
|
|
105
|
+
cleanup_fiber
|
|
106
|
+
trace&.dataloader_fiber_exit
|
|
80
107
|
end
|
|
81
108
|
end
|
|
82
109
|
end
|