graphql 1.10.14 → 1.11.4
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/core.rb +8 -0
- data/lib/generators/graphql/templates/base_argument.erb +2 -0
- data/lib/generators/graphql/templates/base_enum.erb +2 -0
- data/lib/generators/graphql/templates/base_field.erb +2 -0
- data/lib/generators/graphql/templates/base_input_object.erb +2 -0
- data/lib/generators/graphql/templates/base_interface.erb +2 -0
- data/lib/generators/graphql/templates/base_mutation.erb +2 -0
- data/lib/generators/graphql/templates/base_object.erb +2 -0
- data/lib/generators/graphql/templates/base_scalar.erb +2 -0
- data/lib/generators/graphql/templates/base_union.erb +2 -0
- data/lib/generators/graphql/templates/enum.erb +2 -0
- data/lib/generators/graphql/templates/graphql_controller.erb +13 -9
- data/lib/generators/graphql/templates/interface.erb +2 -0
- data/lib/generators/graphql/templates/loader.erb +2 -0
- data/lib/generators/graphql/templates/mutation.erb +2 -0
- data/lib/generators/graphql/templates/mutation_type.erb +2 -0
- data/lib/generators/graphql/templates/object.erb +2 -0
- data/lib/generators/graphql/templates/query_type.erb +2 -0
- data/lib/generators/graphql/templates/scalar.erb +2 -0
- data/lib/generators/graphql/templates/schema.erb +2 -0
- data/lib/generators/graphql/templates/union.erb +2 -0
- data/lib/graphql.rb +3 -3
- data/lib/graphql/execution/interpreter.rb +1 -1
- data/lib/graphql/execution/interpreter/runtime.rb +26 -26
- data/lib/graphql/execution/multiplex.rb +1 -2
- data/lib/graphql/introspection/schema_type.rb +3 -3
- data/lib/graphql/invalid_null_error.rb +18 -0
- data/lib/graphql/language/nodes.rb +1 -0
- data/lib/graphql/language/visitor.rb +2 -2
- data/lib/graphql/pagination/connection.rb +18 -13
- data/lib/graphql/pagination/connections.rb +17 -4
- data/lib/graphql/query.rb +1 -2
- data/lib/graphql/query/context.rb +20 -1
- data/lib/graphql/query/fingerprint.rb +2 -0
- data/lib/graphql/query/validation_pipeline.rb +3 -0
- data/lib/graphql/schema.rb +26 -16
- data/lib/graphql/schema/build_from_definition.rb +7 -12
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +3 -1
- data/lib/graphql/schema/enum_value.rb +1 -0
- data/lib/graphql/schema/field.rb +63 -77
- data/lib/graphql/schema/field/connection_extension.rb +42 -32
- data/lib/graphql/schema/loader.rb +19 -1
- data/lib/graphql/schema/member/has_fields.rb +15 -5
- data/lib/graphql/schema/mutation.rb +4 -0
- data/lib/graphql/schema/object.rb +1 -1
- data/lib/graphql/schema/resolver.rb +20 -0
- data/lib/graphql/schema/resolver/has_payload_type.rb +2 -1
- data/lib/graphql/schema/subscription.rb +3 -13
- data/lib/graphql/schema/union.rb +29 -0
- data/lib/graphql/schema/warden.rb +2 -4
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +4 -2
- data/lib/graphql/subscriptions.rb +69 -24
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +66 -11
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +84 -0
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +21 -0
- data/lib/graphql/subscriptions/event.rb +16 -1
- data/lib/graphql/subscriptions/serialize.rb +22 -4
- data/lib/graphql/subscriptions/subscription_root.rb +3 -1
- data/lib/graphql/tracing.rb +1 -27
- data/lib/graphql/tracing/appoptics_tracing.rb +10 -2
- data/lib/graphql/tracing/platform_tracing.rb +25 -15
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/types/iso_8601_date_time.rb +2 -1
- data/lib/graphql/types/relay/base_connection.rb +6 -5
- data/lib/graphql/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5bf42de25927dab863bd600879d33d204c54bdf124b2b4cc5b27c4c16d4f28b
|
4
|
+
data.tar.gz: 58b21a4dd5ba80ec0f6c3362013a6adb07c2f1af243e5a851d4c3f08554fe09d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f199d24a190910e44b189340b6a3d2a3c121ab56ba10ec6cf44d8801107db8d73541f24788b00b13ee7dd357f7bfe6ecff7001f053fe417c777bca59db5851db
|
7
|
+
data.tar.gz: fd0955c7f67b20370ea376d6a286fdf0ac7272ac5b243d6c309d2159a780cd0b8f92fd0e06ca312a69a16b7c8ad0ebd7bb4587feac9dc77b27da507c9a44cd8f
|
@@ -1,3 +1,4 @@
|
|
1
|
+
<% module_namespacing_when_supported do -%>
|
1
2
|
class GraphqlController < ApplicationController
|
2
3
|
# If accessing from outside this domain, nullify the session
|
3
4
|
# This allows for outside API access while preventing CSRF attacks,
|
@@ -5,7 +6,7 @@ class GraphqlController < ApplicationController
|
|
5
6
|
# protect_from_forgery with: :null_session
|
6
7
|
|
7
8
|
def execute
|
8
|
-
variables =
|
9
|
+
variables = prepare_variables(params[:variables])
|
9
10
|
query = params[:query]
|
10
11
|
operation_name = params[:operationName]
|
11
12
|
context = {
|
@@ -21,21 +22,23 @@ class GraphqlController < ApplicationController
|
|
21
22
|
|
22
23
|
private
|
23
24
|
|
24
|
-
# Handle form data, JSON body, or a blank value
|
25
|
-
def
|
26
|
-
case
|
25
|
+
# Handle variables in form data, JSON body, or a blank value
|
26
|
+
def prepare_variables(variables_param)
|
27
|
+
case variables_param
|
27
28
|
when String
|
28
|
-
if
|
29
|
-
|
29
|
+
if variables_param.present?
|
30
|
+
JSON.parse(variables_param) || {}
|
30
31
|
else
|
31
32
|
{}
|
32
33
|
end
|
33
|
-
when Hash
|
34
|
-
|
34
|
+
when Hash
|
35
|
+
variables_param
|
36
|
+
when ActionController::Parameters
|
37
|
+
variables_param.to_unsafe_hash # GraphQL-Ruby will validate name and type of incoming variables.
|
35
38
|
when nil
|
36
39
|
{}
|
37
40
|
else
|
38
|
-
raise ArgumentError, "Unexpected parameter: #{
|
41
|
+
raise ArgumentError, "Unexpected parameter: #{variables_param}"
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
@@ -46,3 +49,4 @@ class GraphqlController < ApplicationController
|
|
46
49
|
render json: { errors: [{ message: e.message, backtrace: e.backtrace }], data: {} }, status: 500
|
47
50
|
end
|
48
51
|
end
|
52
|
+
<% end -%>
|
@@ -1,6 +1,8 @@
|
|
1
|
+
<% module_namespacing_when_supported do -%>
|
1
2
|
module Types
|
2
3
|
class <%= type_ruby_name.split('::')[-1] %> < Types::BaseObject
|
3
4
|
<% if options.node %> implements GraphQL::Relay::Node.interface
|
4
5
|
<% end %><% normalized_fields.each do |f| %> <%= f.to_ruby %>
|
5
6
|
<% end %> end
|
6
7
|
end
|
8
|
+
<% end -%>
|
data/lib/graphql.rb
CHANGED
@@ -91,13 +91,13 @@ require "graphql/analysis"
|
|
91
91
|
require "graphql/tracing"
|
92
92
|
require "graphql/dig"
|
93
93
|
require "graphql/execution"
|
94
|
+
require "graphql/runtime_type_error"
|
95
|
+
require "graphql/unresolved_type_error"
|
96
|
+
require "graphql/invalid_null_error"
|
94
97
|
require "graphql/schema"
|
95
98
|
require "graphql/query"
|
96
99
|
require "graphql/directive"
|
97
100
|
require "graphql/execution"
|
98
|
-
require "graphql/runtime_type_error"
|
99
|
-
require "graphql/unresolved_type_error"
|
100
|
-
require "graphql/invalid_null_error"
|
101
101
|
require "graphql/types"
|
102
102
|
require "graphql/relay"
|
103
103
|
require "graphql/boolean_type"
|
@@ -26,7 +26,7 @@ module GraphQL
|
|
26
26
|
schema_class.query_execution_strategy(GraphQL::Execution::Interpreter)
|
27
27
|
schema_class.mutation_execution_strategy(GraphQL::Execution::Interpreter)
|
28
28
|
schema_class.subscription_execution_strategy(GraphQL::Execution::Interpreter)
|
29
|
-
|
29
|
+
schema_class.add_subscription_extension_if_necessary
|
30
30
|
GraphQL::Schema::Object.include(HandlesRawValue)
|
31
31
|
end
|
32
32
|
|
@@ -170,13 +170,13 @@ module GraphQL
|
|
170
170
|
begin
|
171
171
|
kwarg_arguments = arguments(object, field_defn, ast_node)
|
172
172
|
rescue GraphQL::ExecutionError => e
|
173
|
-
continue_value(next_path, e, field_defn, return_type.non_null?, ast_node)
|
173
|
+
continue_value(next_path, e, owner_type, field_defn, return_type.non_null?, ast_node)
|
174
174
|
next
|
175
175
|
end
|
176
176
|
|
177
177
|
after_lazy(kwarg_arguments, owner: owner_type, field: field_defn, path: next_path, scoped_context: context.scoped_context, owner_object: object, arguments: kwarg_arguments) do |resolved_arguments|
|
178
178
|
if resolved_arguments.is_a? GraphQL::ExecutionError
|
179
|
-
continue_value(next_path, resolved_arguments, field_defn, return_type.non_null?, ast_node)
|
179
|
+
continue_value(next_path, resolved_arguments, owner_type, field_defn, return_type.non_null?, ast_node)
|
180
180
|
next
|
181
181
|
end
|
182
182
|
|
@@ -228,12 +228,12 @@ module GraphQL
|
|
228
228
|
err
|
229
229
|
end
|
230
230
|
after_lazy(app_result, owner: owner_type, field: field_defn, path: next_path, scoped_context: context.scoped_context, owner_object: object, arguments: kwarg_arguments) do |inner_result|
|
231
|
-
continue_value = continue_value(next_path, inner_result, field_defn, return_type.non_null?, ast_node)
|
231
|
+
continue_value = continue_value(next_path, inner_result, owner_type, field_defn, return_type.non_null?, ast_node)
|
232
232
|
if RawValue === continue_value
|
233
233
|
# Write raw value directly to the response without resolving nested objects
|
234
234
|
write_in_response(next_path, continue_value.resolve)
|
235
235
|
elsif HALT != continue_value
|
236
|
-
continue_field(next_path, continue_value, field_defn, return_type, ast_node, next_selections, false, object, kwarg_arguments)
|
236
|
+
continue_field(next_path, continue_value, owner_type, field_defn, return_type, ast_node, next_selections, false, object, kwarg_arguments)
|
237
237
|
end
|
238
238
|
end
|
239
239
|
end
|
@@ -251,10 +251,10 @@ module GraphQL
|
|
251
251
|
end
|
252
252
|
|
253
253
|
HALT = Object.new
|
254
|
-
def continue_value(path, value, field, is_non_null, ast_node)
|
254
|
+
def continue_value(path, value, parent_type, field, is_non_null, ast_node)
|
255
255
|
if value.nil?
|
256
256
|
if is_non_null
|
257
|
-
err =
|
257
|
+
err = parent_type::InvalidNullError.new(parent_type, field, value)
|
258
258
|
write_invalid_null_in_response(path, err)
|
259
259
|
else
|
260
260
|
write_in_response(path, nil)
|
@@ -281,7 +281,7 @@ module GraphQL
|
|
281
281
|
err
|
282
282
|
end
|
283
283
|
|
284
|
-
continue_value(path, next_value, field, is_non_null, ast_node)
|
284
|
+
continue_value(path, next_value, parent_type, field, is_non_null, ast_node)
|
285
285
|
elsif GraphQL::Execution::Execute::SKIP == value
|
286
286
|
HALT
|
287
287
|
else
|
@@ -297,49 +297,49 @@ module GraphQL
|
|
297
297
|
# Location information from `path` and `ast_node`.
|
298
298
|
#
|
299
299
|
# @return [Lazy, Array, Hash, Object] Lazy, Array, and Hash are all traversed to resolve lazy values later
|
300
|
-
def continue_field(path, value, field,
|
301
|
-
case
|
300
|
+
def continue_field(path, value, owner_type, field, current_type, ast_node, next_selections, is_non_null, owner_object, arguments) # rubocop:disable Metrics/ParameterLists
|
301
|
+
case current_type.kind.name
|
302
302
|
when "SCALAR", "ENUM"
|
303
|
-
r =
|
303
|
+
r = current_type.coerce_result(value, context)
|
304
304
|
write_in_response(path, r)
|
305
305
|
r
|
306
306
|
when "UNION", "INTERFACE"
|
307
|
-
resolved_type_or_lazy, resolved_value = resolve_type(
|
307
|
+
resolved_type_or_lazy, resolved_value = resolve_type(current_type, value, path)
|
308
308
|
resolved_value ||= value
|
309
309
|
|
310
|
-
after_lazy(resolved_type_or_lazy, owner:
|
311
|
-
possible_types = query.possible_types(
|
310
|
+
after_lazy(resolved_type_or_lazy, owner: current_type, path: path, scoped_context: context.scoped_context, field: field, owner_object: owner_object, arguments: arguments, trace: false) do |resolved_type|
|
311
|
+
possible_types = query.possible_types(current_type)
|
312
312
|
|
313
313
|
if !possible_types.include?(resolved_type)
|
314
|
-
parent_type = field.
|
315
|
-
err_class =
|
314
|
+
parent_type = field.owner_type
|
315
|
+
err_class = current_type::UnresolvedTypeError
|
316
316
|
type_error = err_class.new(resolved_value, field, parent_type, resolved_type, possible_types)
|
317
317
|
schema.type_error(type_error, context)
|
318
318
|
write_in_response(path, nil)
|
319
319
|
nil
|
320
320
|
else
|
321
|
-
continue_field(path, resolved_value, field, resolved_type, ast_node, next_selections, is_non_null, owner_object, arguments)
|
321
|
+
continue_field(path, resolved_value, owner_type, field, resolved_type, ast_node, next_selections, is_non_null, owner_object, arguments)
|
322
322
|
end
|
323
323
|
end
|
324
324
|
when "OBJECT"
|
325
325
|
object_proxy = begin
|
326
|
-
authorized_new(
|
326
|
+
authorized_new(current_type, value, context, path)
|
327
327
|
rescue GraphQL::ExecutionError => err
|
328
328
|
err
|
329
329
|
end
|
330
|
-
after_lazy(object_proxy, owner:
|
331
|
-
continue_value = continue_value(path, inner_object, field, is_non_null, ast_node)
|
330
|
+
after_lazy(object_proxy, owner: current_type, path: path, scoped_context: context.scoped_context, field: field, owner_object: owner_object, arguments: arguments, trace: false) do |inner_object|
|
331
|
+
continue_value = continue_value(path, inner_object, owner_type, field, is_non_null, ast_node)
|
332
332
|
if HALT != continue_value
|
333
333
|
response_hash = {}
|
334
334
|
write_in_response(path, response_hash)
|
335
|
-
evaluate_selections(path, context.scoped_context, continue_value,
|
335
|
+
evaluate_selections(path, context.scoped_context, continue_value, current_type, next_selections)
|
336
336
|
response_hash
|
337
337
|
end
|
338
338
|
end
|
339
339
|
when "LIST"
|
340
340
|
response_list = []
|
341
341
|
write_in_response(path, response_list)
|
342
|
-
inner_type =
|
342
|
+
inner_type = current_type.of_type
|
343
343
|
idx = 0
|
344
344
|
scoped_context = context.scoped_context
|
345
345
|
begin
|
@@ -351,9 +351,9 @@ module GraphQL
|
|
351
351
|
set_type_at_path(next_path, inner_type)
|
352
352
|
# This will update `response_list` with the lazy
|
353
353
|
after_lazy(inner_value, owner: inner_type, path: next_path, scoped_context: scoped_context, field: field, owner_object: owner_object, arguments: arguments) do |inner_inner_value|
|
354
|
-
continue_value = continue_value(next_path, inner_inner_value, field, inner_type.non_null?, ast_node)
|
354
|
+
continue_value = continue_value(next_path, inner_inner_value, owner_type, field, inner_type.non_null?, ast_node)
|
355
355
|
if HALT != continue_value
|
356
|
-
continue_field(next_path, continue_value, field, inner_type, ast_node, next_selections, false, owner_object, arguments)
|
356
|
+
continue_field(next_path, continue_value, owner_type, field, inner_type, ast_node, next_selections, false, owner_object, arguments)
|
357
357
|
end
|
358
358
|
end
|
359
359
|
end
|
@@ -370,12 +370,12 @@ module GraphQL
|
|
370
370
|
|
371
371
|
response_list
|
372
372
|
when "NON_NULL"
|
373
|
-
inner_type =
|
373
|
+
inner_type = current_type.of_type
|
374
374
|
# Don't `set_type_at_path` because we want the static type,
|
375
375
|
# we're going to use that to determine whether a `nil` should be propagated or not.
|
376
|
-
continue_field(path, value, field, inner_type, ast_node, next_selections, true, owner_object, arguments)
|
376
|
+
continue_field(path, value, owner_type, field, inner_type, ast_node, next_selections, true, owner_object, arguments)
|
377
377
|
else
|
378
|
-
raise "Invariant: Unhandled type kind #{
|
378
|
+
raise "Invariant: Unhandled type kind #{current_type.kind} (#{current_type})"
|
379
379
|
end
|
380
380
|
end
|
381
381
|
|
@@ -34,8 +34,7 @@ module GraphQL
|
|
34
34
|
@schema = schema
|
35
35
|
@queries = queries
|
36
36
|
@context = context
|
37
|
-
|
38
|
-
@tracers = schema.tracers + GraphQL::Tracing.tracers + (context[:tracers] || [])
|
37
|
+
@tracers = schema.tracers + (context[:tracers] || [])
|
39
38
|
# Support `context: {backtrace: true}`
|
40
39
|
if context[:backtrace] && !@tracers.include?(GraphQL::Backtrace::Tracer)
|
41
40
|
@tracers << GraphQL::Backtrace::Tracer
|
@@ -9,9 +9,9 @@ module GraphQL
|
|
9
9
|
"query, mutation, and subscription operations."
|
10
10
|
|
11
11
|
field :types, [GraphQL::Schema::LateBoundType.new("__Type")], "A list of all types supported by this server.", null: false
|
12
|
-
field :
|
13
|
-
field :
|
14
|
-
field :
|
12
|
+
field :query_type, GraphQL::Schema::LateBoundType.new("__Type"), "The type that query operations will be rooted at.", null: false
|
13
|
+
field :mutation_type, GraphQL::Schema::LateBoundType.new("__Type"), "If this server supports mutation, the type that mutation operations will be rooted at.", null: true
|
14
|
+
field :subscription_type, GraphQL::Schema::LateBoundType.new("__Type"), "If this server support subscription, the type that subscription operations will be rooted at.", null: true
|
15
15
|
field :directives, [GraphQL::Schema::LateBoundType.new("__Directive")], "A list of all directives supported by this server.", null: false
|
16
16
|
|
17
17
|
def types
|