graphql 2.5.19 → 2.5.21

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/dashboard/application_controller.rb +41 -0
  3. data/lib/graphql/dashboard/landings_controller.rb +9 -0
  4. data/lib/graphql/dashboard/statics_controller.rb +31 -0
  5. data/lib/graphql/dashboard/subscriptions.rb +2 -1
  6. data/lib/graphql/dashboard/views/layouts/graphql/dashboard/application.html.erb +3 -3
  7. data/lib/graphql/dashboard.rb +9 -74
  8. data/lib/graphql/dataloader/null_dataloader.rb +7 -3
  9. data/lib/graphql/execution/multiplex.rb +1 -1
  10. data/lib/graphql/execution/next/field_resolve_step.rb +690 -0
  11. data/lib/graphql/execution/next/load_argument_step.rb +60 -0
  12. data/lib/graphql/execution/next/prepare_object_step.rb +129 -0
  13. data/lib/graphql/execution/next/runner.rb +389 -0
  14. data/lib/graphql/execution/next/selections_step.rb +37 -0
  15. data/lib/graphql/execution/next.rb +69 -0
  16. data/lib/graphql/execution.rb +1 -0
  17. data/lib/graphql/execution_error.rb +13 -10
  18. data/lib/graphql/introspection/directive_type.rb +7 -3
  19. data/lib/graphql/introspection/dynamic_fields.rb +5 -1
  20. data/lib/graphql/introspection/entry_points.rb +11 -3
  21. data/lib/graphql/introspection/enum_value_type.rb +5 -5
  22. data/lib/graphql/introspection/field_type.rb +13 -5
  23. data/lib/graphql/introspection/input_value_type.rb +21 -13
  24. data/lib/graphql/introspection/type_type.rb +64 -28
  25. data/lib/graphql/invalid_null_error.rb +11 -5
  26. data/lib/graphql/pagination/connection.rb +2 -0
  27. data/lib/graphql/pagination/connections.rb +32 -0
  28. data/lib/graphql/query/context.rb +3 -2
  29. data/lib/graphql/query/null_context.rb +9 -3
  30. data/lib/graphql/schema/argument.rb +5 -0
  31. data/lib/graphql/schema/build_from_definition.rb +7 -0
  32. data/lib/graphql/schema/field/connection_extension.rb +15 -35
  33. data/lib/graphql/schema/field/scope_extension.rb +22 -13
  34. data/lib/graphql/schema/field.rb +70 -1
  35. data/lib/graphql/schema/field_extension.rb +33 -0
  36. data/lib/graphql/schema/member/base_dsl_methods.rb +1 -1
  37. data/lib/graphql/schema/member/has_authorization.rb +35 -0
  38. data/lib/graphql/schema/member/has_dataloader.rb +17 -0
  39. data/lib/graphql/schema/member/has_fields.rb +5 -1
  40. data/lib/graphql/schema/member.rb +5 -0
  41. data/lib/graphql/schema/object.rb +1 -0
  42. data/lib/graphql/schema/resolver.rb +45 -1
  43. data/lib/graphql/schema/visibility.rb +1 -1
  44. data/lib/graphql/schema.rb +33 -7
  45. data/lib/graphql/subscriptions.rb +1 -1
  46. data/lib/graphql/tracing/perfetto_trace.rb +1 -1
  47. data/lib/graphql/types/relay/connection_behaviors.rb +8 -6
  48. data/lib/graphql/types/relay/edge_behaviors.rb +4 -3
  49. data/lib/graphql/types/relay/has_node_field.rb +13 -8
  50. data/lib/graphql/types/relay/has_nodes_field.rb +13 -8
  51. data/lib/graphql/types/relay/node_behaviors.rb +13 -2
  52. data/lib/graphql/unauthorized_error.rb +5 -1
  53. data/lib/graphql/version.rb +1 -1
  54. data/lib/graphql.rb +3 -0
  55. metadata +12 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a94d75c592000805bf9fd18507343c0b3428f1cf1d9a1828edc921828fd2735
4
- data.tar.gz: 2984583eb702965d43e45f58f1ac29b6a782b8ecf02b4ee1953b5c5bbb6ec872
3
+ metadata.gz: a3389acc9cdde64e7a96d73e206c1e97b6d2e55e2b11c97672435682ba7b4324
4
+ data.tar.gz: cc6ceaf0af5a61ccbd3c2c38eb8d87035ba04ca23e40cc14eee60cd1093332d3
5
5
  SHA512:
6
- metadata.gz: 743bd603f22bb38bdff984c75b37eea32d460aeafd50617fc52dc9c4b93fe1d3265df196b728432a7b2d6494a6ba20c47b658ee84b387377037ea173844c654b
7
- data.tar.gz: 12354210f6208443a5ec0dc931606440de29bfe0bdb7c6468e7faf9bc013a67671eab62fcc3bd88405d1ffb840a5c0e04be337d9a6707d511a2046d315722f63
6
+ metadata.gz: 472188116841eba00d2e98c216fb1c381c306c83d51dd283dff9feb62849cb9e72b5cb23d86125ddcbdd2e8975df2ab686b69af7864a3ffae88227517e709aa7
7
+ data.tar.gz: ae9573fcaa2271c3e4351f067cd992db0adbf50b38d98aab92300d0f08b8756ecf5c9d44f274feeead5d9d99f9721ade833cfe96471966d03bd70fae6add7fb5
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+ require "action_controller"
3
+
4
+ module Graphql
5
+ class Dashboard < Rails::Engine
6
+ class ApplicationController < ActionController::Base
7
+ protect_from_forgery with: :exception
8
+ prepend_view_path(File.expand_path("../views", __FILE__))
9
+
10
+ content_security_policy do |policy|
11
+ policy.default_src(:self) if policy.default_src(*policy.default_src).blank?
12
+ policy.connect_src(:self) if policy.connect_src(*policy.connect_src).blank?
13
+ policy.base_uri(:none) if policy.base_uri(*policy.base_uri).blank?
14
+ policy.font_src(:self) if policy.font_src(*policy.font_src).blank?
15
+ policy.img_src(:self, :data) if policy.img_src(*policy.img_src).blank?
16
+ policy.object_src(:none) if policy.object_src(*policy.object_src).blank?
17
+ policy.script_src(:self) if policy.script_src(*policy.script_src).blank?
18
+ policy.style_src(:self) if policy.style_src(*policy.style_src).blank?
19
+ policy.form_action(:self) if policy.form_action(*policy.form_action).blank?
20
+ policy.frame_ancestors(:none) if policy.frame_ancestors(*policy.frame_ancestors).blank?
21
+ end
22
+
23
+ def schema_class
24
+ @schema_class ||= begin
25
+ schema_param = request.query_parameters["schema"] || params[:schema]
26
+ case schema_param
27
+ when Class
28
+ schema_param
29
+ when String
30
+ schema_param.constantize
31
+ else
32
+ raise "Missing `params[:schema]`, please provide a class or string to `mount GraphQL::Dashboard, schema: ...`"
33
+ end
34
+ end
35
+ end
36
+ helper_method :schema_class
37
+ end
38
+ end
39
+ end
40
+
41
+ ActiveSupport.run_load_hooks(:graphql_dashboard_application_controller, GraphQL::Dashboard::ApplicationController)
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ module Graphql
3
+ class Dashboard < Rails::Engine
4
+ class LandingsController < ApplicationController
5
+ def show
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ module Graphql
3
+ class Dashboard < Rails::Engine
4
+ class StaticsController < ApplicationController
5
+ skip_forgery_protection
6
+ # Use an explicit list of files to avoid any chance of reading other files from disk
7
+ STATICS = {}
8
+
9
+ [
10
+ "icon.png",
11
+ "header-icon.png",
12
+ "charts.min.css",
13
+ "dashboard.css",
14
+ "dashboard.js",
15
+ "bootstrap-5.3.3.min.css",
16
+ "bootstrap-5.3.3.min.js",
17
+ ].each do |static_file|
18
+ STATICS[static_file] = File.expand_path("../statics/#{static_file}", __FILE__)
19
+ end
20
+
21
+ def show
22
+ expires_in 1.year, public: true
23
+ if (filepath = STATICS[params[:id]])
24
+ render file: filepath
25
+ else
26
+ head :not_found
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require_relative "./installable"
2
3
  module Graphql
3
4
  class Dashboard < Rails::Engine
4
5
  module Subscriptions
@@ -6,7 +7,7 @@ module Graphql
6
7
  include Installable
7
8
 
8
9
  def feature_installed?
9
- schema_class.subscriptions.is_a?(GraphQL::Pro::Subscriptions)
10
+ defined?(GraphQL::Pro::Subscriptions) && schema_class.subscriptions.is_a?(GraphQL::Pro::Subscriptions)
10
11
  end
11
12
 
12
13
  INSTALLABLE_COMPONENT_HEADER_HTML = "GraphQL-Pro Subscriptions aren't installed on this schema yet.".html_safe
@@ -5,9 +5,9 @@
5
5
  <meta charset="utf-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1">
7
7
  <title>GraphQL Dashboard <%= content_for?(:title) ? " · #{content_for(:title)}" : "" %> </title>
8
- <link rel="stylesheet" href="<%= graphql_dashboard.static_path("bootstrap-5.3.3.min.css") %>" media="screen" />
9
- <link rel="stylesheet" href="<%= graphql_dashboard.static_path("charts.min.css") %>" media="screen" />
10
- <link rel="stylesheet" href="<%= graphql_dashboard.static_path("dashboard.css") %>" media="screen" />
8
+ <link rel="stylesheet" href="<%= graphql_dashboard.static_path("bootstrap-5.3.3.min.css") %>" media="screen">
9
+ <link rel="stylesheet" href="<%= graphql_dashboard.static_path("charts.min.css") %>" media="screen">
10
+ <link rel="stylesheet" href="<%= graphql_dashboard.static_path("dashboard.css") %>" media="screen">
11
11
  <script src="<%= graphql_dashboard.static_path("bootstrap-5.3.3.min.js") %>"></script>
12
12
  <script src="<%= graphql_dashboard.static_path("dashboard.js") %>"></script>
13
13
  <%= csrf_meta_tags %>
@@ -35,6 +35,15 @@ module Graphql
35
35
  class Dashboard < Rails::Engine
36
36
  engine_name "graphql_dashboard"
37
37
  isolate_namespace(Graphql::Dashboard)
38
+
39
+ autoload :ApplicationController, "graphql/dashboard/application_controller"
40
+ autoload :LandingsController, "graphql/dashboard/landings_controller"
41
+ autoload :StaticsController, "graphql/dashboard/statics_controller"
42
+ autoload :DetailedTraces, "graphql/dashboard/detailed_traces"
43
+ autoload :Subscriptions, "graphql/dashboard/subscriptions"
44
+ autoload :OperationStore, "graphql/dashboard/operation_store"
45
+ autoload :Limiters, "graphql/dashboard/limiters"
46
+
38
47
  routes do
39
48
  root "landings#show"
40
49
  resources :statics, only: :show, constraints: { id: /[0-9A-Za-z\-.]+/ }
@@ -77,85 +86,11 @@ module Graphql
77
86
  resources :subscriptions, only: [:show], constraints: { id: /[a-zA-Z0-9\-]+/ }
78
87
  post "/subscriptions/clear_all", to: "subscriptions#clear_all", as: :clear_all
79
88
  end
80
-
81
- ApplicationController.include(Dashboard.routes.url_helpers)
82
- end
83
-
84
- class ApplicationController < ActionController::Base
85
- protect_from_forgery with: :exception
86
- prepend_view_path(File.join(__FILE__, "../dashboard/views"))
87
-
88
- content_security_policy do |policy|
89
- policy.default_src(:self) if policy.default_src(*policy.default_src).blank?
90
- policy.connect_src(:self) if policy.connect_src(*policy.connect_src).blank?
91
- policy.base_uri(:none) if policy.base_uri(*policy.base_uri).blank?
92
- policy.font_src(:self) if policy.font_src(*policy.font_src).blank?
93
- policy.img_src(:self, :data) if policy.img_src(*policy.img_src).blank?
94
- policy.object_src(:none) if policy.object_src(*policy.object_src).blank?
95
- policy.script_src(:self) if policy.script_src(*policy.script_src).blank?
96
- policy.style_src(:self) if policy.style_src(*policy.style_src).blank?
97
- policy.form_action(:self) if policy.form_action(*policy.form_action).blank?
98
- policy.frame_ancestors(:none) if policy.frame_ancestors(*policy.frame_ancestors).blank?
99
- end
100
-
101
- def schema_class
102
- @schema_class ||= begin
103
- schema_param = request.query_parameters["schema"] || params[:schema]
104
- case schema_param
105
- when Class
106
- schema_param
107
- when String
108
- schema_param.constantize
109
- else
110
- raise "Missing `params[:schema]`, please provide a class or string to `mount GraphQL::Dashboard, schema: ...`"
111
- end
112
- end
113
- end
114
- helper_method :schema_class
115
- end
116
-
117
- class LandingsController < ApplicationController
118
- def show
119
- end
120
- end
121
-
122
- class StaticsController < ApplicationController
123
- skip_forgery_protection
124
- # Use an explicit list of files to avoid any chance of reading other files from disk
125
- STATICS = {}
126
-
127
- [
128
- "icon.png",
129
- "header-icon.png",
130
- "charts.min.css",
131
- "dashboard.css",
132
- "dashboard.js",
133
- "bootstrap-5.3.3.min.css",
134
- "bootstrap-5.3.3.min.js",
135
- ].each do |static_file|
136
- STATICS[static_file] = File.expand_path("../dashboard/statics/#{static_file}", __FILE__)
137
- end
138
-
139
- def show
140
- expires_in 1.year, public: true
141
- if (filepath = STATICS[params[:id]])
142
- render file: filepath
143
- else
144
- head :not_found
145
- end
146
- end
147
89
  end
148
90
  end
149
91
  end
150
92
 
151
- require 'graphql/dashboard/detailed_traces'
152
- require 'graphql/dashboard/limiters'
153
- require 'graphql/dashboard/operation_store'
154
- require 'graphql/dashboard/subscriptions'
155
-
156
93
  # Rails expects the engine to be called `Graphql::Dashboard`,
157
94
  # but `GraphQL::Dashboard` is consistent with this gem's naming.
158
95
  # So define both constants to refer to the same class.
159
96
  GraphQL::Dashboard = Graphql::Dashboard
160
-
161
- ActiveSupport.run_load_hooks(:graphql_dashboard_application_controller, GraphQL::Dashboard::ApplicationController)
@@ -37,13 +37,17 @@ module GraphQL
37
37
  end
38
38
 
39
39
  def run_isolated
40
- new_dl = self.class.new
40
+ # Reuse this instance because execution code may already have a reference to _this_ `dataloader` inside the given block.
41
+ prev_lazies_at_depth = @lazies_at_depth
42
+ @lazies_at_depth = @lazies_at_depth.dup.clear
41
43
  res = nil
42
- new_dl.append_job {
44
+ append_job {
43
45
  res = yield
44
46
  }
45
- new_dl.run
47
+ run
46
48
  res
49
+ ensure
50
+ @lazies_at_depth = prev_lazies_at_depth
47
51
  end
48
52
 
49
53
  def clear_cache; end
@@ -33,7 +33,7 @@ module GraphQL
33
33
  @queries.each { |q| q.multiplex = self }
34
34
  @context = context
35
35
  @dataloader = @context[:dataloader] ||= @schema.dataloader_class.new
36
- @tracers = schema.tracers + (context[:tracers] || [])
36
+ @tracers = schema.tracers + (context[:tracers] || EmptyObjects::EMPTY_ARRAY)
37
37
  @max_complexity = max_complexity
38
38
  @current_trace = context[:trace] ||= schema.new_trace(multiplex: self)
39
39
  @logger = nil