graphql 1.13.24 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of graphql might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/graphql/analysis/ast/query_complexity.rb +1 -1
- data/lib/graphql/analysis/ast/query_depth.rb +0 -1
- data/lib/graphql/analysis/ast/visitor.rb +1 -1
- data/lib/graphql/analysis/ast.rb +0 -10
- data/lib/graphql/analysis.rb +0 -7
- data/lib/graphql/backtrace/table.rb +0 -18
- data/lib/graphql/backtrace/tracer.rb +1 -2
- data/lib/graphql/backtrace.rb +2 -8
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/errors.rb +1 -9
- data/lib/graphql/execution/interpreter/runtime.rb +6 -13
- data/lib/graphql/execution/interpreter.rb +0 -22
- data/lib/graphql/execution/lazy.rb +1 -1
- data/lib/graphql/execution/lookahead.rb +6 -13
- data/lib/graphql/execution/multiplex.rb +50 -107
- data/lib/graphql/execution.rb +11 -3
- data/lib/graphql/introspection/directive_type.rb +2 -2
- data/lib/graphql/introspection/dynamic_fields.rb +3 -8
- data/lib/graphql/introspection/entry_points.rb +2 -15
- data/lib/graphql/introspection/field_type.rb +1 -1
- data/lib/graphql/introspection/schema_type.rb +2 -2
- data/lib/graphql/introspection/type_type.rb +5 -5
- data/lib/graphql/language/document_from_schema_definition.rb +0 -17
- data/lib/graphql/language/nodes.rb +0 -3
- data/lib/graphql/pagination/connections.rb +2 -28
- data/lib/graphql/query/context.rb +1 -185
- data/lib/graphql/query/input_validation_result.rb +0 -9
- data/lib/graphql/query/literal_input.rb +8 -13
- data/lib/graphql/query/validation_pipeline.rb +6 -34
- data/lib/graphql/query/variable_validation_error.rb +2 -2
- data/lib/graphql/query/variables.rb +8 -31
- data/lib/graphql/query.rb +5 -34
- data/lib/graphql/railtie.rb +0 -104
- data/lib/graphql/relay/range_add.rb +0 -4
- data/lib/graphql/relay.rb +0 -15
- data/lib/graphql/schema/addition.rb +1 -8
- data/lib/graphql/schema/argument.rb +6 -28
- data/lib/graphql/schema/build_from_definition.rb +7 -9
- data/lib/graphql/schema/directive.rb +1 -22
- data/lib/graphql/schema/enum.rb +3 -19
- data/lib/graphql/schema/enum_value.rb +1 -23
- data/lib/graphql/schema/field.rb +22 -221
- data/lib/graphql/schema/input_object.rb +17 -65
- data/lib/graphql/schema/interface.rb +1 -30
- data/lib/graphql/schema/introspection_system.rb +3 -8
- data/lib/graphql/schema/late_bound_type.rb +2 -2
- data/lib/graphql/schema/list.rb +3 -24
- data/lib/graphql/schema/loader.rb +0 -1
- data/lib/graphql/schema/member/base_dsl_methods.rb +1 -6
- data/lib/graphql/schema/member/build_type.rb +4 -6
- data/lib/graphql/schema/member/has_arguments.rb +16 -20
- data/lib/graphql/schema/member/has_fields.rb +3 -3
- data/lib/graphql/schema/member/has_interfaces.rb +1 -13
- data/lib/graphql/schema/member/validates_input.rb +2 -2
- data/lib/graphql/schema/member.rb +0 -6
- data/lib/graphql/schema/mutation.rb +0 -9
- data/lib/graphql/schema/non_null.rb +3 -9
- data/lib/graphql/schema/object.rb +0 -40
- data/lib/graphql/schema/relay_classic_mutation.rb +17 -28
- data/lib/graphql/schema/scalar.rb +1 -16
- data/lib/graphql/schema/union.rb +0 -16
- data/lib/graphql/schema/warden.rb +3 -12
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +106 -945
- data/lib/graphql/static_validation/base_visitor.rb +4 -21
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +12 -12
- data/lib/graphql/static_validation/validator.rb +2 -24
- data/lib/graphql/static_validation.rb +0 -2
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +38 -1
- data/lib/graphql/subscriptions/event.rb +1 -1
- data/lib/graphql/subscriptions/instrumentation.rb +0 -51
- data/lib/graphql/subscriptions.rb +4 -13
- data/lib/graphql/tracing/data_dog_tracing.rb +16 -20
- data/lib/graphql/tracing/platform_tracing.rb +4 -32
- data/lib/graphql/tracing.rb +0 -1
- data/lib/graphql/types/relay/connection_behaviors.rb +2 -6
- data/lib/graphql/types/relay/default_relay.rb +0 -10
- data/lib/graphql/types/relay/node_behaviors.rb +5 -1
- data/lib/graphql/types/relay.rb +0 -2
- data/lib/graphql/types/string.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +1 -66
- metadata +28 -164
- data/lib/graphql/analysis/analyze_query.rb +0 -98
- data/lib/graphql/analysis/field_usage.rb +0 -45
- data/lib/graphql/analysis/max_query_complexity.rb +0 -26
- data/lib/graphql/analysis/max_query_depth.rb +0 -26
- data/lib/graphql/analysis/query_complexity.rb +0 -88
- data/lib/graphql/analysis/query_depth.rb +0 -43
- data/lib/graphql/analysis/reducer_state.rb +0 -48
- data/lib/graphql/argument.rb +0 -131
- data/lib/graphql/authorization.rb +0 -82
- data/lib/graphql/backtrace/legacy_tracer.rb +0 -56
- data/lib/graphql/backwards_compatibility.rb +0 -61
- data/lib/graphql/base_type.rb +0 -232
- data/lib/graphql/boolean_type.rb +0 -2
- data/lib/graphql/compatibility/execution_specification/counter_schema.rb +0 -53
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +0 -200
- data/lib/graphql/compatibility/execution_specification.rb +0 -436
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
- data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -215
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -87
- data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -266
- data/lib/graphql/compatibility/schema_parser_specification.rb +0 -682
- data/lib/graphql/compatibility.rb +0 -5
- data/lib/graphql/define/assign_argument.rb +0 -12
- data/lib/graphql/define/assign_connection.rb +0 -13
- data/lib/graphql/define/assign_enum_value.rb +0 -18
- data/lib/graphql/define/assign_global_id_field.rb +0 -11
- data/lib/graphql/define/assign_mutation_function.rb +0 -34
- data/lib/graphql/define/assign_object_field.rb +0 -42
- data/lib/graphql/define/defined_object_proxy.rb +0 -53
- data/lib/graphql/define/instance_definable.rb +0 -255
- data/lib/graphql/define/no_definition_error.rb +0 -7
- data/lib/graphql/define/non_null_with_bang.rb +0 -16
- data/lib/graphql/define/type_definer.rb +0 -31
- data/lib/graphql/define.rb +0 -31
- data/lib/graphql/deprecated_dsl.rb +0 -55
- data/lib/graphql/directive/deprecated_directive.rb +0 -2
- data/lib/graphql/directive/include_directive.rb +0 -2
- data/lib/graphql/directive/skip_directive.rb +0 -2
- data/lib/graphql/directive.rb +0 -107
- data/lib/graphql/enum_type.rb +0 -133
- data/lib/graphql/execution/execute.rb +0 -333
- data/lib/graphql/execution/flatten.rb +0 -40
- data/lib/graphql/execution/typecast.rb +0 -50
- data/lib/graphql/field/resolve.rb +0 -59
- data/lib/graphql/field.rb +0 -226
- data/lib/graphql/float_type.rb +0 -2
- data/lib/graphql/function.rb +0 -128
- data/lib/graphql/id_type.rb +0 -2
- data/lib/graphql/input_object_type.rb +0 -138
- data/lib/graphql/int_type.rb +0 -2
- data/lib/graphql/interface_type.rb +0 -72
- data/lib/graphql/internal_representation/document.rb +0 -27
- data/lib/graphql/internal_representation/node.rb +0 -206
- data/lib/graphql/internal_representation/print.rb +0 -51
- data/lib/graphql/internal_representation/rewrite.rb +0 -184
- data/lib/graphql/internal_representation/scope.rb +0 -88
- data/lib/graphql/internal_representation/visit.rb +0 -36
- data/lib/graphql/internal_representation.rb +0 -7
- data/lib/graphql/list_type.rb +0 -80
- data/lib/graphql/non_null_type.rb +0 -71
- data/lib/graphql/object_type.rb +0 -130
- data/lib/graphql/query/arguments.rb +0 -189
- data/lib/graphql/query/arguments_cache.rb +0 -24
- data/lib/graphql/query/executor.rb +0 -52
- data/lib/graphql/query/serial_execution/field_resolution.rb +0 -92
- data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -19
- data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -23
- data/lib/graphql/query/serial_execution/value_resolution.rb +0 -87
- data/lib/graphql/query/serial_execution.rb +0 -40
- data/lib/graphql/relay/array_connection.rb +0 -83
- data/lib/graphql/relay/base_connection.rb +0 -189
- data/lib/graphql/relay/connection_instrumentation.rb +0 -54
- data/lib/graphql/relay/connection_resolve.rb +0 -43
- data/lib/graphql/relay/connection_type.rb +0 -54
- data/lib/graphql/relay/edge.rb +0 -27
- data/lib/graphql/relay/edge_type.rb +0 -19
- data/lib/graphql/relay/edges_instrumentation.rb +0 -39
- data/lib/graphql/relay/global_id_resolve.rb +0 -17
- data/lib/graphql/relay/mongo_relation_connection.rb +0 -50
- data/lib/graphql/relay/mutation/instrumentation.rb +0 -23
- data/lib/graphql/relay/mutation/resolve.rb +0 -56
- data/lib/graphql/relay/mutation/result.rb +0 -38
- data/lib/graphql/relay/mutation.rb +0 -106
- data/lib/graphql/relay/node.rb +0 -39
- data/lib/graphql/relay/page_info.rb +0 -7
- data/lib/graphql/relay/relation_connection.rb +0 -188
- data/lib/graphql/relay/type_extensions.rb +0 -32
- data/lib/graphql/scalar_type.rb +0 -91
- data/lib/graphql/schema/catchall_middleware.rb +0 -35
- data/lib/graphql/schema/default_parse_error.rb +0 -10
- data/lib/graphql/schema/default_type_error.rb +0 -17
- data/lib/graphql/schema/member/accepts_definition.rb +0 -164
- data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -58
- data/lib/graphql/schema/member/instrumentation.rb +0 -131
- data/lib/graphql/schema/middleware_chain.rb +0 -82
- data/lib/graphql/schema/possible_types.rb +0 -44
- data/lib/graphql/schema/rescue_middleware.rb +0 -60
- data/lib/graphql/schema/timeout_middleware.rb +0 -88
- data/lib/graphql/schema/traversal.rb +0 -228
- data/lib/graphql/schema/validation.rb +0 -313
- data/lib/graphql/static_validation/default_visitor.rb +0 -15
- data/lib/graphql/static_validation/no_validate_visitor.rb +0 -10
- data/lib/graphql/string_type.rb +0 -2
- data/lib/graphql/subscriptions/subscription_root.rb +0 -76
- data/lib/graphql/tracing/skylight_tracing.rb +0 -70
- data/lib/graphql/types/relay/node_field.rb +0 -24
- data/lib/graphql/types/relay/nodes_field.rb +0 -43
- data/lib/graphql/union_type.rb +0 -115
- data/lib/graphql/upgrader/member.rb +0 -937
- data/lib/graphql/upgrader/schema.rb +0 -38
@@ -94,11 +94,6 @@ module GraphQL
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
# @return [GraphQL::BaseType] Convert this type to a legacy-style object.
|
98
|
-
def to_graphql
|
99
|
-
raise GraphQL::RequiredImplementationMissingError
|
100
|
-
end
|
101
|
-
|
102
97
|
alias :unwrap :itself
|
103
98
|
|
104
99
|
# Creates the default name for a schema member.
|
@@ -108,7 +103,7 @@ module GraphQL
|
|
108
103
|
@default_graphql_name ||= begin
|
109
104
|
raise GraphQL::RequiredImplementationMissingError, 'Anonymous class should declare a `graphql_name`' if name.nil?
|
110
105
|
|
111
|
-
|
106
|
+
name.split("::").last.sub(/Type\Z/, "")
|
112
107
|
end
|
113
108
|
end
|
114
109
|
|
@@ -35,18 +35,16 @@ module GraphQL
|
|
35
35
|
else
|
36
36
|
maybe_type = constantize(type_expr)
|
37
37
|
case maybe_type
|
38
|
-
when GraphQL::BaseType
|
39
|
-
maybe_type
|
40
38
|
when Module
|
41
39
|
# This is a way to check that it's the right kind of module:
|
42
|
-
if maybe_type.respond_to?(:
|
40
|
+
if maybe_type.respond_to?(:kind)
|
43
41
|
maybe_type
|
44
42
|
else
|
45
43
|
raise ArgumentError, "Unexpected class/module found for GraphQL type: #{type_expr} (must be type definition class/module)"
|
46
44
|
end
|
47
45
|
end
|
48
46
|
end
|
49
|
-
when GraphQL::
|
47
|
+
when GraphQL::Schema::LateBoundType
|
50
48
|
type_expr
|
51
49
|
when Array
|
52
50
|
case type_expr.length
|
@@ -68,7 +66,7 @@ module GraphQL
|
|
68
66
|
type_expr
|
69
67
|
when Module
|
70
68
|
# This is a way to check that it's the right kind of module:
|
71
|
-
if type_expr.respond_to?(:
|
69
|
+
if type_expr.respond_to?(:kind)
|
72
70
|
type_expr
|
73
71
|
else
|
74
72
|
# Eg `String` => GraphQL::Types::String
|
@@ -100,7 +98,7 @@ module GraphQL
|
|
100
98
|
|
101
99
|
def to_type_name(something)
|
102
100
|
case something
|
103
|
-
when GraphQL::
|
101
|
+
when GraphQL::Schema::LateBoundType
|
104
102
|
something.unwrap.name
|
105
103
|
when Array
|
106
104
|
to_type_name(something.first)
|
@@ -14,7 +14,7 @@ module GraphQL
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# @see {GraphQL::Schema::Argument#initialize} for parameters
|
17
|
-
# @return [GraphQL::Schema::Argument] An instance of {
|
17
|
+
# @return [GraphQL::Schema::Argument] An instance of {argument_class}, created from `*args`
|
18
18
|
def argument(*args, **kwargs, &block)
|
19
19
|
kwargs[:owner] = self
|
20
20
|
loads = kwargs[:loads]
|
@@ -167,7 +167,7 @@ module GraphQL
|
|
167
167
|
# @return [Interpreter::Arguments, Execution::Lazy<Interpeter::Arguments>]
|
168
168
|
def coerce_arguments(parent_object, values, context, &block)
|
169
169
|
# Cache this hash to avoid re-merging it
|
170
|
-
arg_defns =
|
170
|
+
arg_defns = self.arguments(context)
|
171
171
|
total_args_count = arg_defns.size
|
172
172
|
|
173
173
|
finished_args = nil
|
@@ -181,7 +181,7 @@ module GraphQL
|
|
181
181
|
argument_values = {}
|
182
182
|
resolved_args_count = 0
|
183
183
|
raised_error = false
|
184
|
-
arg_defns.each do |arg_defn|
|
184
|
+
arg_defns.each do |arg_name, arg_defn|
|
185
185
|
context.dataloader.append_job do
|
186
186
|
begin
|
187
187
|
arg_defn.coerce_into_values(parent_object, values, context, argument_values)
|
@@ -291,26 +291,22 @@ module GraphQL
|
|
291
291
|
# This object was loaded successfully
|
292
292
|
# and resolved to the right type,
|
293
293
|
# now apply the `.authorized?` class method if there is one
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
294
|
+
context.schema.after_lazy(application_object_type.authorized?(application_object, context)) do |authed|
|
295
|
+
if authed
|
296
|
+
application_object
|
297
|
+
else
|
298
|
+
err = GraphQL::UnauthorizedError.new(
|
299
|
+
object: application_object,
|
300
|
+
type: application_object_type,
|
301
|
+
context: context,
|
302
|
+
)
|
303
|
+
if self.respond_to?(:unauthorized_object)
|
304
|
+
err.set_backtrace(caller)
|
305
|
+
unauthorized_object(err)
|
298
306
|
else
|
299
|
-
err
|
300
|
-
object: application_object,
|
301
|
-
type: class_based_type,
|
302
|
-
context: context,
|
303
|
-
)
|
304
|
-
if self.respond_to?(:unauthorized_object)
|
305
|
-
err.set_backtrace(caller)
|
306
|
-
unauthorized_object(err)
|
307
|
-
else
|
308
|
-
raise err
|
309
|
-
end
|
307
|
+
raise err
|
310
308
|
end
|
311
309
|
end
|
312
|
-
else
|
313
|
-
application_object
|
314
310
|
end
|
315
311
|
end
|
316
312
|
end
|
@@ -103,10 +103,10 @@ module GraphQL
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def global_id_field(field_name, **kwargs)
|
106
|
-
|
106
|
+
type = self
|
107
107
|
field field_name, "ID", **kwargs, null: false
|
108
108
|
define_method(field_name) do
|
109
|
-
|
109
|
+
context.schema.id_from_object(object, type, context)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -134,7 +134,7 @@ module GraphQL
|
|
134
134
|
if type.respond_to?(:kind) && type.kind.interface?
|
135
135
|
implements_this_interface = false
|
136
136
|
implementation_is_visible = false
|
137
|
-
|
137
|
+
interface_type_memberships.each do |tm|
|
138
138
|
if tm.abstract_type == type
|
139
139
|
implements_this_interface ||= true
|
140
140
|
if warden.visible_type_membership?(tm, context)
|
@@ -23,8 +23,6 @@ module GraphQL
|
|
23
23
|
int.interfaces.each do |next_interface|
|
24
24
|
implements(next_interface)
|
25
25
|
end
|
26
|
-
elsif int.is_a?(GraphQL::InterfaceType)
|
27
|
-
new_memberships << int.type_membership_class.new(int, self, **options)
|
28
26
|
elsif int.is_a?(String) || int.is_a?(GraphQL::Schema::LateBoundType)
|
29
27
|
if options.any?
|
30
28
|
raise ArgumentError, "`implements(...)` doesn't support options with late-loaded types yet. Remove #{options} and open an issue to request this feature."
|
@@ -57,17 +55,7 @@ module GraphQL
|
|
57
55
|
end
|
58
56
|
|
59
57
|
def interface_type_memberships
|
60
|
-
|
61
|
-
if (self.is_a?(Class) && superclass.respond_to?(:interface_type_memberships))
|
62
|
-
inherited_tms = superclass.interface_type_memberships
|
63
|
-
if inherited_tms.size > 0
|
64
|
-
own_tms + inherited_tms
|
65
|
-
else
|
66
|
-
own_tms
|
67
|
-
end
|
68
|
-
else
|
69
|
-
own_tms
|
70
|
-
end
|
58
|
+
own_interface_type_memberships + ((self.is_a?(Class) && superclass.respond_to?(:interface_type_memberships)) ? superclass.interface_type_memberships : [])
|
71
59
|
end
|
72
60
|
|
73
61
|
# param context [Query::Context] If omitted, skip filtering.
|
@@ -8,11 +8,11 @@ module GraphQL
|
|
8
8
|
validate_input(val, ctx).valid?
|
9
9
|
end
|
10
10
|
|
11
|
-
def validate_input(val, ctx
|
11
|
+
def validate_input(val, ctx)
|
12
12
|
if val.nil?
|
13
13
|
GraphQL::Query::InputValidationResult.new
|
14
14
|
else
|
15
|
-
validate_non_null_input(val, ctx
|
15
|
+
validate_non_null_input(val, ctx)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'graphql/schema/member/accepts_definition'
|
3
2
|
require 'graphql/schema/member/base_dsl_methods'
|
4
|
-
require 'graphql/schema/member/cached_graphql_definition'
|
5
3
|
require 'graphql/schema/member/graphql_type_names'
|
6
4
|
require 'graphql/schema/member/has_ast_node'
|
7
5
|
require 'graphql/schema/member/has_directives'
|
@@ -14,7 +12,6 @@ require 'graphql/schema/member/relay_shortcuts'
|
|
14
12
|
require 'graphql/schema/member/scoped'
|
15
13
|
require 'graphql/schema/member/type_system_helpers'
|
16
14
|
require 'graphql/schema/member/validates_input'
|
17
|
-
require "graphql/relay/type_extensions"
|
18
15
|
|
19
16
|
module GraphQL
|
20
17
|
class Schema
|
@@ -24,8 +21,6 @@ module GraphQL
|
|
24
21
|
# @api private
|
25
22
|
class Member
|
26
23
|
include GraphQLTypeNames
|
27
|
-
extend CachedGraphQLDefinition
|
28
|
-
extend GraphQL::Relay::TypeExtensions
|
29
24
|
extend BaseDSLMethods
|
30
25
|
extend BaseDSLMethods::ConfigurationExtension
|
31
26
|
introspection(false)
|
@@ -41,5 +36,4 @@ end
|
|
41
36
|
|
42
37
|
require 'graphql/schema/member/has_arguments'
|
43
38
|
require 'graphql/schema/member/has_fields'
|
44
|
-
require 'graphql/schema/member/instrumentation'
|
45
39
|
require 'graphql/schema/member/build_type'
|
@@ -63,15 +63,6 @@ module GraphQL
|
|
63
63
|
extend GraphQL::Schema::Resolver::HasPayloadType
|
64
64
|
|
65
65
|
class << self
|
66
|
-
# Override this method to handle legacy-style usages of `MyMutation.field`
|
67
|
-
def field(*args, **kwargs, &block)
|
68
|
-
if args.empty?
|
69
|
-
raise ArgumentError, "#{name}.field is used for adding fields to this mutation. Use `mutation: #{name}` to attach this mutation instead."
|
70
|
-
else
|
71
|
-
super
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
66
|
def visible?(context)
|
76
67
|
true
|
77
68
|
end
|
@@ -8,13 +8,7 @@ module GraphQL
|
|
8
8
|
class NonNull < GraphQL::Schema::Wrapper
|
9
9
|
include Schema::Member::ValidatesInput
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
def to_graphql
|
14
|
-
@of_type.graphql_definition(silence_deprecation_warning: true).to_non_null_type
|
15
|
-
end
|
16
|
-
|
17
|
-
# @return [GraphQL::TypeKinds::NON_NULL]
|
11
|
+
# @return [GraphQL::TypeKinds::NON_NULL]
|
18
12
|
def kind
|
19
13
|
GraphQL::TypeKinds::NON_NULL
|
20
14
|
end
|
@@ -37,13 +31,13 @@ module GraphQL
|
|
37
31
|
"#<#{self.class.name} @of_type=#{@of_type.inspect}>"
|
38
32
|
end
|
39
33
|
|
40
|
-
def validate_input(value, ctx
|
34
|
+
def validate_input(value, ctx)
|
41
35
|
if value.nil?
|
42
36
|
result = GraphQL::Query::InputValidationResult.new
|
43
37
|
result.add_problem("Expected value to not be null")
|
44
38
|
result
|
45
39
|
else
|
46
|
-
of_type.validate_input(value, ctx
|
40
|
+
of_type.validate_input(value, ctx)
|
47
41
|
end
|
48
42
|
end
|
49
43
|
|
@@ -5,7 +5,6 @@ require "graphql/query/null_context"
|
|
5
5
|
module GraphQL
|
6
6
|
class Schema
|
7
7
|
class Object < GraphQL::Schema::Member
|
8
|
-
extend GraphQL::Schema::Member::AcceptsDefinition
|
9
8
|
extend GraphQL::Schema::Member::HasFields
|
10
9
|
extend GraphQL::Schema::Member::HasInterfaces
|
11
10
|
|
@@ -104,45 +103,6 @@ module GraphQL
|
|
104
103
|
super
|
105
104
|
end
|
106
105
|
|
107
|
-
# @return [Hash<String => GraphQL::Schema::Field>] All of this object's fields, indexed by name
|
108
|
-
# @see get_field A faster way to find one field by name ({#fields} merges hashes of inherited fields; {#get_field} just looks up one field.)
|
109
|
-
def fields(context = GraphQL::Query::NullContext)
|
110
|
-
all_fields = super
|
111
|
-
# This adds fields from legacy-style interfaces only.
|
112
|
-
# Multi-fields are not supported here.
|
113
|
-
interfaces.each do |int|
|
114
|
-
if int.is_a?(GraphQL::InterfaceType)
|
115
|
-
int_f = {}
|
116
|
-
int.fields.each do |name, legacy_field| # rubocop:disable Development/ContextIsPassedCop -- legacy-related
|
117
|
-
int_f[name] = field_class.from_options(name, field: legacy_field)
|
118
|
-
end
|
119
|
-
all_fields = int_f.merge(all_fields)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
all_fields
|
123
|
-
end
|
124
|
-
|
125
|
-
prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
126
|
-
|
127
|
-
# @return [GraphQL::ObjectType]
|
128
|
-
def to_graphql
|
129
|
-
obj_type = GraphQL::ObjectType.new
|
130
|
-
obj_type.name = graphql_name
|
131
|
-
obj_type.description = description
|
132
|
-
obj_type.structural_interface_type_memberships = interface_type_memberships
|
133
|
-
obj_type.introspection = introspection
|
134
|
-
obj_type.mutation = mutation
|
135
|
-
obj_type.ast_node = ast_node
|
136
|
-
fields.each do |field_name, field_inst| # rubocop:disable Development/ContextIsPassedCop -- legacy-related
|
137
|
-
field_defn = field_inst.to_graphql(silence_deprecation_warning: true)
|
138
|
-
obj_type.fields[field_defn.name] = field_defn # rubocop:disable Development/ContextIsPassedCop -- legacy-related
|
139
|
-
end
|
140
|
-
|
141
|
-
obj_type.metadata[:type_class] = self
|
142
|
-
|
143
|
-
obj_type
|
144
|
-
end
|
145
|
-
|
146
106
|
def kind
|
147
107
|
GraphQL::TypeKinds::OBJECT
|
148
108
|
end
|
@@ -29,25 +29,19 @@ module GraphQL
|
|
29
29
|
# Override {GraphQL::Schema::Resolver#resolve_with_support} to
|
30
30
|
# delete `client_mutation_id` from the kwargs.
|
31
31
|
def resolve_with_support(**inputs)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
#
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
# don't re-add it if it wasn't given here.
|
45
|
-
if inputs.key?(ext)
|
46
|
-
input[ext] = inputs[ext]
|
47
|
-
end
|
32
|
+
input = inputs[:input].to_kwargs
|
33
|
+
|
34
|
+
new_extras = field ? field.extras : []
|
35
|
+
all_extras = self.class.extras + new_extras
|
36
|
+
|
37
|
+
# Transfer these from the top-level hash to the
|
38
|
+
# shortcutted `input:` object
|
39
|
+
all_extras.each do |ext|
|
40
|
+
# It's possible that the `extra` was not passed along by this point,
|
41
|
+
# don't re-add it if it wasn't given here.
|
42
|
+
if inputs.key?(ext)
|
43
|
+
input[ext] = inputs[ext]
|
48
44
|
end
|
49
|
-
else
|
50
|
-
input = inputs
|
51
45
|
end
|
52
46
|
|
53
47
|
if input
|
@@ -66,17 +60,12 @@ module GraphQL
|
|
66
60
|
super()
|
67
61
|
end
|
68
62
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
if return_hash.is_a?(Hash)
|
74
|
-
return_hash[:client_mutation_id] = client_mutation_id
|
75
|
-
end
|
76
|
-
return_hash
|
63
|
+
context.schema.after_lazy(return_value) do |return_hash|
|
64
|
+
# It might be an error
|
65
|
+
if return_hash.is_a?(Hash)
|
66
|
+
return_hash[:client_mutation_id] = client_mutation_id
|
77
67
|
end
|
78
|
-
|
79
|
-
return_value
|
68
|
+
return_hash
|
80
69
|
end
|
81
70
|
end
|
82
71
|
|
@@ -2,7 +2,6 @@
|
|
2
2
|
module GraphQL
|
3
3
|
class Schema
|
4
4
|
class Scalar < GraphQL::Schema::Member
|
5
|
-
extend GraphQL::Schema::Member::AcceptsDefinition
|
6
5
|
extend GraphQL::Schema::Member::ValidatesInput
|
7
6
|
|
8
7
|
class << self
|
@@ -14,20 +13,6 @@ module GraphQL
|
|
14
13
|
val
|
15
14
|
end
|
16
15
|
|
17
|
-
prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
18
|
-
|
19
|
-
def to_graphql
|
20
|
-
type_defn = GraphQL::ScalarType.new
|
21
|
-
type_defn.name = graphql_name
|
22
|
-
type_defn.description = description
|
23
|
-
type_defn.coerce_result = method(:coerce_result)
|
24
|
-
type_defn.coerce_input = method(:coerce_input)
|
25
|
-
type_defn.metadata[:type_class] = self
|
26
|
-
type_defn.default_scalar = default_scalar
|
27
|
-
type_defn.ast_node = ast_node
|
28
|
-
type_defn
|
29
|
-
end
|
30
|
-
|
31
16
|
def kind
|
32
17
|
GraphQL::TypeKinds::SCALAR
|
33
18
|
end
|
@@ -55,7 +40,7 @@ module GraphQL
|
|
55
40
|
@default_scalar ||= false
|
56
41
|
end
|
57
42
|
|
58
|
-
def validate_non_null_input(value, ctx
|
43
|
+
def validate_non_null_input(value, ctx)
|
59
44
|
result = Query::InputValidationResult.new
|
60
45
|
coerced_result = begin
|
61
46
|
ctx.query.with_error_handling do
|
data/lib/graphql/schema/union.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
module GraphQL
|
3
3
|
class Schema
|
4
4
|
class Union < GraphQL::Schema::Member
|
5
|
-
extend GraphQL::Schema::Member::AcceptsDefinition
|
6
5
|
extend GraphQL::Schema::Member::HasUnresolvedTypeError
|
7
6
|
|
8
7
|
class << self
|
@@ -33,21 +32,6 @@ module GraphQL
|
|
33
32
|
type_memberships.map(&:object_type)
|
34
33
|
end
|
35
34
|
|
36
|
-
prepend GraphQL::Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
37
|
-
|
38
|
-
def to_graphql
|
39
|
-
type_defn = GraphQL::UnionType.new
|
40
|
-
type_defn.name = graphql_name
|
41
|
-
type_defn.description = description
|
42
|
-
type_defn.ast_node = ast_node
|
43
|
-
type_defn.type_memberships = type_memberships
|
44
|
-
if respond_to?(:resolve_type)
|
45
|
-
type_defn.resolve_type = method(:resolve_type)
|
46
|
-
end
|
47
|
-
type_defn.metadata[:type_class] = self
|
48
|
-
type_defn
|
49
|
-
end
|
50
|
-
|
51
35
|
def type_membership_class(membership_class = nil)
|
52
36
|
if membership_class
|
53
37
|
@type_membership_class = membership_class
|
@@ -78,8 +78,6 @@ module GraphQL
|
|
78
78
|
def visible_type?(type, ctx); type.visible?(ctx); end
|
79
79
|
def visible_enum_value?(ev, ctx); ev.visible?(ctx); end
|
80
80
|
def visible_type_membership?(tm, ctx); tm.visible?(ctx); end
|
81
|
-
def interface_type_memberships(obj_t, ctx); obj_t.interface_type_memberships; end
|
82
|
-
def arguments(owner, ctx); owner.arguments(ctx); end
|
83
81
|
end
|
84
82
|
end
|
85
83
|
|
@@ -87,7 +85,7 @@ module GraphQL
|
|
87
85
|
# @param context [GraphQL::Query::Context]
|
88
86
|
# @param schema [GraphQL::Schema]
|
89
87
|
def initialize(filter, context:, schema:)
|
90
|
-
@schema = schema
|
88
|
+
@schema = schema
|
91
89
|
# Cache these to avoid repeated hits to the inheritance chain when one isn't present
|
92
90
|
@query = @schema.query
|
93
91
|
@mutation = @schema.mutation
|
@@ -174,8 +172,8 @@ module GraphQL
|
|
174
172
|
|
175
173
|
# @param argument_owner [GraphQL::Field, GraphQL::InputObjectType]
|
176
174
|
# @return [Array<GraphQL::Argument>] Visible arguments on `argument_owner`
|
177
|
-
def arguments(argument_owner
|
178
|
-
@visible_arguments ||= read_through { |o| o.arguments(@context).each_value.select { |a| visible_argument?(a
|
175
|
+
def arguments(argument_owner)
|
176
|
+
@visible_arguments ||= read_through { |o| o.arguments(@context).each_value.select { |a| visible_argument?(a) } }
|
179
177
|
@visible_arguments[argument_owner]
|
180
178
|
end
|
181
179
|
|
@@ -233,13 +231,6 @@ module GraphQL
|
|
233
231
|
visible?(type_membership)
|
234
232
|
end
|
235
233
|
|
236
|
-
def interface_type_memberships(obj_type, _ctx = nil)
|
237
|
-
@type_memberships ||= read_through do |obj_t|
|
238
|
-
obj_t.interface_type_memberships
|
239
|
-
end
|
240
|
-
@type_memberships[obj_type]
|
241
|
-
end
|
242
|
-
|
243
234
|
private
|
244
235
|
|
245
236
|
def visible_and_reachable_type?(type_defn)
|
@@ -3,7 +3,6 @@
|
|
3
3
|
module GraphQL
|
4
4
|
class Schema
|
5
5
|
class Wrapper
|
6
|
-
include GraphQL::Schema::Member::CachedGraphQLDefinition
|
7
6
|
include GraphQL::Schema::Member::TypeSystemHelpers
|
8
7
|
|
9
8
|
# @return [Class, Module] The inner type of this wrapping type, the type of which one or more objects may be present.
|
@@ -13,10 +12,6 @@ module GraphQL
|
|
13
12
|
@of_type = of_type
|
14
13
|
end
|
15
14
|
|
16
|
-
def to_graphql
|
17
|
-
raise GraphQL::RequiredImplementationMissingError
|
18
|
-
end
|
19
|
-
|
20
15
|
def unwrap
|
21
16
|
@of_type.unwrap
|
22
17
|
end
|