graphql 1.13.10 → 2.0.2
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/graphql/analysis/ast/max_query_complexity.rb +0 -1
- 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/dataloader/null_dataloader.rb +3 -1
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/errors.rb +1 -9
- data/lib/graphql/execution/interpreter/runtime.rb +17 -31
- 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/dynamic_fields.rb +3 -8
- data/lib/graphql/introspection/entry_points.rb +2 -15
- data/lib/graphql/language/document_from_schema_definition.rb +0 -17
- data/lib/graphql/pagination/connections.rb +2 -28
- data/lib/graphql/query/context.rb +97 -194
- data/lib/graphql/query/input_validation_result.rb +10 -1
- data/lib/graphql/query/validation_pipeline.rb +8 -37
- data/lib/graphql/query/variables.rb +22 -18
- data/lib/graphql/query.rb +5 -36
- data/lib/graphql/railtie.rb +0 -104
- data/lib/graphql/relay.rb +0 -15
- data/lib/graphql/schema/addition.rb +1 -8
- data/lib/graphql/schema/argument.rb +5 -26
- data/lib/graphql/schema/build_from_definition.rb +0 -1
- data/lib/graphql/schema/directive.rb +0 -21
- data/lib/graphql/schema/enum.rb +4 -23
- data/lib/graphql/schema/enum_value.rb +0 -22
- data/lib/graphql/schema/field.rb +70 -230
- data/lib/graphql/schema/input_object.rb +21 -68
- data/lib/graphql/schema/interface.rb +0 -25
- 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 +2 -7
- data/lib/graphql/schema/loader.rb +0 -1
- data/lib/graphql/schema/member/base_dsl_methods.rb +0 -5
- data/lib/graphql/schema/member/build_type.rb +4 -6
- data/lib/graphql/schema/member/has_arguments.rb +50 -24
- data/lib/graphql/schema/member/has_fields.rb +2 -2
- data/lib/graphql/schema/member/has_interfaces.rb +1 -3
- 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 +1 -7
- data/lib/graphql/schema/object.rb +7 -42
- data/lib/graphql/schema/relay_classic_mutation.rb +49 -42
- data/lib/graphql/schema/resolver/has_payload_type.rb +11 -1
- data/lib/graphql/schema/resolver.rb +23 -45
- data/lib/graphql/schema/scalar.rb +4 -19
- data/lib/graphql/schema/subscription.rb +0 -7
- data/lib/graphql/schema/union.rb +0 -16
- data/lib/graphql/schema/warden.rb +2 -2
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +106 -944
- 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 +14 -16
- data/lib/graphql/tracing/platform_tracing.rb +0 -23
- 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/version.rb +1 -1
- data/lib/graphql.rb +1 -65
- metadata +2 -128
- 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 -240
- 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/literal_input.rb +0 -136
- 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
|
@@ -4,8 +4,6 @@ module GraphQL
|
|
|
4
4
|
module Interface
|
|
5
5
|
include GraphQL::Schema::Member::GraphQLTypeNames
|
|
6
6
|
module DefinitionMethods
|
|
7
|
-
include GraphQL::Schema::Member::CachedGraphQLDefinition
|
|
8
|
-
include GraphQL::Relay::TypeExtensions
|
|
9
7
|
include GraphQL::Schema::Member::BaseDSLMethods
|
|
10
8
|
# ConfigurationExtension's responsibilities are in `def included` below
|
|
11
9
|
include GraphQL::Schema::Member::TypeSystemHelpers
|
|
@@ -100,34 +98,11 @@ module GraphQL
|
|
|
100
98
|
end
|
|
101
99
|
end
|
|
102
100
|
|
|
103
|
-
prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
|
104
|
-
|
|
105
|
-
def to_graphql
|
|
106
|
-
type_defn = GraphQL::InterfaceType.new
|
|
107
|
-
type_defn.name = graphql_name
|
|
108
|
-
type_defn.description = description
|
|
109
|
-
type_defn.orphan_types = orphan_types
|
|
110
|
-
type_defn.type_membership_class = self.type_membership_class
|
|
111
|
-
type_defn.ast_node = ast_node
|
|
112
|
-
fields.each do |field_name, field_inst| # rubocop:disable Development/ContextIsPassedCop -- legacy-related
|
|
113
|
-
field_defn = field_inst.graphql_definition(silence_deprecation_warning: true)
|
|
114
|
-
type_defn.fields[field_defn.name] = field_defn # rubocop:disable Development/ContextIsPassedCop -- legacy-related
|
|
115
|
-
end
|
|
116
|
-
type_defn.metadata[:type_class] = self
|
|
117
|
-
if respond_to?(:resolve_type)
|
|
118
|
-
type_defn.resolve_type = method(:resolve_type)
|
|
119
|
-
end
|
|
120
|
-
type_defn
|
|
121
|
-
end
|
|
122
|
-
|
|
123
101
|
def kind
|
|
124
102
|
GraphQL::TypeKinds::INTERFACE
|
|
125
103
|
end
|
|
126
104
|
end
|
|
127
105
|
|
|
128
|
-
# Extend this _after_ `DefinitionMethods` is defined, so it will be used
|
|
129
|
-
extend GraphQL::Schema::Member::AcceptsDefinition
|
|
130
|
-
|
|
131
106
|
extend DefinitionMethods
|
|
132
107
|
|
|
133
108
|
def unwrap
|
|
@@ -89,9 +89,9 @@ module GraphQL
|
|
|
89
89
|
case late_bound_type
|
|
90
90
|
when GraphQL::Schema::LateBoundType
|
|
91
91
|
@schema.get_type(late_bound_type.name)
|
|
92
|
-
when GraphQL::Schema::List
|
|
92
|
+
when GraphQL::Schema::List
|
|
93
93
|
resolve_late_binding(late_bound_type.of_type).to_list_type
|
|
94
|
-
when GraphQL::Schema::NonNull
|
|
94
|
+
when GraphQL::Schema::NonNull
|
|
95
95
|
resolve_late_binding(late_bound_type.of_type).to_non_null_type
|
|
96
96
|
when Module
|
|
97
97
|
# It's a normal type -- no change required
|
|
@@ -103,12 +103,7 @@ module GraphQL
|
|
|
103
103
|
|
|
104
104
|
def load_constant(class_name)
|
|
105
105
|
const = @custom_namespace.const_get(class_name)
|
|
106
|
-
|
|
107
|
-
dup_type_class(const)
|
|
108
|
-
else
|
|
109
|
-
# Use `.to_graphql` to get a freshly-made version, not shared between schemas
|
|
110
|
-
const.deprecated_to_graphql
|
|
111
|
-
end
|
|
106
|
+
dup_type_class(const)
|
|
112
107
|
rescue NameError
|
|
113
108
|
# Dup the built-in so that the cached fields aren't shared
|
|
114
109
|
dup_type_class(@built_in_namespace.const_get(class_name))
|
|
@@ -16,11 +16,11 @@ module GraphQL
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def to_non_null_type
|
|
19
|
-
@to_non_null_type ||= GraphQL::
|
|
19
|
+
@to_non_null_type ||= GraphQL::Schema::NonNull.new(self)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def to_list_type
|
|
23
|
-
@to_list_type ||= GraphQL::
|
|
23
|
+
@to_list_type ||= GraphQL::Schema::List.new(self)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def inspect
|
data/lib/graphql/schema/list.rb
CHANGED
|
@@ -8,12 +8,6 @@ module GraphQL
|
|
|
8
8
|
class List < GraphQL::Schema::Wrapper
|
|
9
9
|
include Schema::Member::ValidatesInput
|
|
10
10
|
|
|
11
|
-
prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
|
12
|
-
|
|
13
|
-
def to_graphql
|
|
14
|
-
@of_type.graphql_definition(silence_deprecation_warning: true).to_list_type
|
|
15
|
-
end
|
|
16
|
-
|
|
17
11
|
# @return [GraphQL::TypeKinds::LIST]
|
|
18
12
|
def kind
|
|
19
13
|
GraphQL::TypeKinds::LIST
|
|
@@ -52,10 +46,11 @@ module GraphQL
|
|
|
52
46
|
end
|
|
53
47
|
|
|
54
48
|
def validate_non_null_input(value, ctx)
|
|
55
|
-
result =
|
|
49
|
+
result = nil
|
|
56
50
|
ensure_array(value).each_with_index do |item, index|
|
|
57
51
|
item_result = of_type.validate_input(item, ctx)
|
|
58
52
|
if !item_result.valid?
|
|
53
|
+
result ||= GraphQL::Query::InputValidationResult.new
|
|
59
54
|
result.merge_result!(index, item_result)
|
|
60
55
|
end
|
|
61
56
|
end
|
|
@@ -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.
|
|
@@ -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]
|
|
@@ -78,23 +78,44 @@ module GraphQL
|
|
|
78
78
|
# @return [GraphQL::Schema::Argument]
|
|
79
79
|
def add_argument(arg_defn)
|
|
80
80
|
@own_arguments ||= {}
|
|
81
|
-
prev_defn = own_arguments[arg_defn.name]
|
|
81
|
+
prev_defn = @own_arguments[arg_defn.name]
|
|
82
82
|
case prev_defn
|
|
83
83
|
when nil
|
|
84
|
-
own_arguments[arg_defn.name] = arg_defn
|
|
84
|
+
@own_arguments[arg_defn.name] = arg_defn
|
|
85
85
|
when Array
|
|
86
86
|
prev_defn << arg_defn
|
|
87
87
|
when GraphQL::Schema::Argument
|
|
88
|
-
own_arguments[arg_defn.name] = [prev_defn, arg_defn]
|
|
88
|
+
@own_arguments[arg_defn.name] = [prev_defn, arg_defn]
|
|
89
89
|
else
|
|
90
90
|
raise "Invariant: unexpected `@own_arguments[#{arg_defn.name.inspect}]`: #{prev_defn.inspect}"
|
|
91
91
|
end
|
|
92
92
|
arg_defn
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
+
def remove_argument(arg_defn)
|
|
96
|
+
prev_defn = @own_arguments[arg_defn.name]
|
|
97
|
+
case prev_defn
|
|
98
|
+
when nil
|
|
99
|
+
# done
|
|
100
|
+
when Array
|
|
101
|
+
prev_defn.delete(arg_defn)
|
|
102
|
+
when GraphQL::Schema::Argument
|
|
103
|
+
@own_arguments.delete(arg_defn.name)
|
|
104
|
+
else
|
|
105
|
+
raise "Invariant: unexpected `@own_arguments[#{arg_defn.name.inspect}]`: #{prev_defn.inspect}"
|
|
106
|
+
end
|
|
107
|
+
nil
|
|
108
|
+
end
|
|
109
|
+
|
|
95
110
|
# @return [Hash<String => GraphQL::Schema::Argument] Arguments defined on this thing, keyed by name. Includes inherited definitions
|
|
96
111
|
def arguments(context = GraphQL::Query::NullContext)
|
|
97
|
-
inherited_arguments =
|
|
112
|
+
inherited_arguments = if self.is_a?(Class) && superclass.respond_to?(:arguments)
|
|
113
|
+
superclass.arguments(context)
|
|
114
|
+
elsif defined?(@resolver_class) && @resolver_class
|
|
115
|
+
@resolver_class.field_arguments(context)
|
|
116
|
+
else
|
|
117
|
+
nil
|
|
118
|
+
end
|
|
98
119
|
# Local definitions override inherited ones
|
|
99
120
|
if own_arguments.any?
|
|
100
121
|
own_arguments_that_apply = {}
|
|
@@ -125,6 +146,10 @@ module GraphQL
|
|
|
125
146
|
all_defns.merge!(ancestor.own_arguments)
|
|
126
147
|
end
|
|
127
148
|
end
|
|
149
|
+
elsif defined?(@resolver_class) && @resolver_class
|
|
150
|
+
all_defns = {}
|
|
151
|
+
all_defns.merge!(@resolver_class.own_field_arguments)
|
|
152
|
+
all_defns.merge!(own_arguments)
|
|
128
153
|
else
|
|
129
154
|
all_defns = own_arguments
|
|
130
155
|
end
|
|
@@ -137,8 +162,13 @@ module GraphQL
|
|
|
137
162
|
def get_argument(argument_name, context = GraphQL::Query::NullContext)
|
|
138
163
|
warden = Warden.from_context(context)
|
|
139
164
|
if !self.is_a?(Class)
|
|
140
|
-
|
|
141
|
-
|
|
165
|
+
if (arg_config = own_arguments[argument_name]) && (visible_arg = Warden.visible_entry?(:visible_argument?, arg_config, context, warden))
|
|
166
|
+
visible_arg
|
|
167
|
+
elsif defined?(@resolver_class) && @resolver_class
|
|
168
|
+
@resolver_class.get_field_argument(argument_name, context)
|
|
169
|
+
else
|
|
170
|
+
nil
|
|
171
|
+
end
|
|
142
172
|
else
|
|
143
173
|
for ancestor in ancestors
|
|
144
174
|
if ancestor.respond_to?(:own_arguments) &&
|
|
@@ -291,26 +321,22 @@ module GraphQL
|
|
|
291
321
|
# This object was loaded successfully
|
|
292
322
|
# and resolved to the right type,
|
|
293
323
|
# now apply the `.authorized?` class method if there is one
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
324
|
+
context.schema.after_lazy(application_object_type.authorized?(application_object, context)) do |authed|
|
|
325
|
+
if authed
|
|
326
|
+
application_object
|
|
327
|
+
else
|
|
328
|
+
err = GraphQL::UnauthorizedError.new(
|
|
329
|
+
object: application_object,
|
|
330
|
+
type: application_object_type,
|
|
331
|
+
context: context,
|
|
332
|
+
)
|
|
333
|
+
if self.respond_to?(:unauthorized_object)
|
|
334
|
+
err.set_backtrace(caller)
|
|
335
|
+
unauthorized_object(err)
|
|
298
336
|
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
|
|
337
|
+
raise err
|
|
310
338
|
end
|
|
311
339
|
end
|
|
312
|
-
else
|
|
313
|
-
application_object
|
|
314
340
|
end
|
|
315
341
|
end
|
|
316
342
|
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
|
|
|
@@ -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."
|
|
@@ -82,7 +80,7 @@ module GraphQL
|
|
|
82
80
|
visible_interfaces.concat(superclass.interfaces(context))
|
|
83
81
|
end
|
|
84
82
|
|
|
85
|
-
visible_interfaces
|
|
83
|
+
visible_interfaces.uniq
|
|
86
84
|
end
|
|
87
85
|
end
|
|
88
86
|
end
|
|
@@ -10,9 +10,9 @@ module GraphQL
|
|
|
10
10
|
|
|
11
11
|
def validate_input(val, ctx)
|
|
12
12
|
if val.nil?
|
|
13
|
-
|
|
13
|
+
Query::InputValidationResult::VALID
|
|
14
14
|
else
|
|
15
|
-
validate_non_null_input(val, ctx)
|
|
15
|
+
validate_non_null_input(val, ctx) || Query::InputValidationResult::VALID
|
|
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
|
|
@@ -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
|
|
|
@@ -99,48 +98,14 @@ module GraphQL
|
|
|
99
98
|
class << self
|
|
100
99
|
# Set up a type-specific invalid null error to use when this object's non-null fields wrongly return `nil`.
|
|
101
100
|
# It should help with debugging and bug tracker integrations.
|
|
102
|
-
def
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
|
101
|
+
def const_missing(name)
|
|
102
|
+
if name == :InvalidNullError
|
|
103
|
+
custom_err_class = GraphQL::InvalidNullError.subclass_for(self)
|
|
104
|
+
const_set(:InvalidNullError, custom_err_class)
|
|
105
|
+
custom_err_class
|
|
106
|
+
else
|
|
107
|
+
super
|
|
139
108
|
end
|
|
140
|
-
|
|
141
|
-
obj_type.metadata[:type_class] = self
|
|
142
|
-
|
|
143
|
-
obj_type
|
|
144
109
|
end
|
|
145
110
|
|
|
146
111
|
def kind
|
|
@@ -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,26 +60,42 @@ 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
|
|
|
83
72
|
class << self
|
|
73
|
+
def dummy
|
|
74
|
+
@dummy ||= begin
|
|
75
|
+
d = Class.new(GraphQL::Schema::Resolver)
|
|
76
|
+
d.argument_class(self.argument_class)
|
|
77
|
+
# TODO make this lazier?
|
|
78
|
+
d.argument(:input, input_type, description: "Parameters for #{self.graphql_name}")
|
|
79
|
+
d
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def field_arguments(context = GraphQL::Query::NullContext)
|
|
84
|
+
dummy.arguments(context)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def get_field_argument(name, context = GraphQL::Query::NullContext)
|
|
88
|
+
dummy.get_argument(name, context)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def own_field_arguments
|
|
92
|
+
dummy.own_arguments
|
|
93
|
+
end
|
|
84
94
|
|
|
85
95
|
# Also apply this argument to the input type:
|
|
86
|
-
def argument(*args, **kwargs, &block)
|
|
96
|
+
def argument(*args, own_argument: false, **kwargs, &block)
|
|
87
97
|
it = input_type # make sure any inherited arguments are already added to it
|
|
88
|
-
arg = super
|
|
98
|
+
arg = super(*args, **kwargs, &block)
|
|
89
99
|
|
|
90
100
|
# This definition might be overriding something inherited;
|
|
91
101
|
# if it is, remove the inherited definition so it's not confused at runtime as having multiple definitions
|
|
@@ -125,15 +135,6 @@ module GraphQL
|
|
|
125
135
|
@input_type ||= generate_input_type
|
|
126
136
|
end
|
|
127
137
|
|
|
128
|
-
# Extend {Schema::Mutation.field_options} to add the `input` argument
|
|
129
|
-
def field_options
|
|
130
|
-
sig = super
|
|
131
|
-
# Arguments were added at the root, but they should be nested
|
|
132
|
-
sig[:arguments].clear
|
|
133
|
-
sig[:arguments][:input] = { type: input_type, required: true, description: "Parameters for #{graphql_name}" }
|
|
134
|
-
sig
|
|
135
|
-
end
|
|
136
|
-
|
|
137
138
|
private
|
|
138
139
|
|
|
139
140
|
# Generate the input type for the `input:` argument
|
|
@@ -141,11 +142,17 @@ module GraphQL
|
|
|
141
142
|
# @return [Class] a subclass of {.input_object_class}
|
|
142
143
|
def generate_input_type
|
|
143
144
|
mutation_args = all_argument_definitions
|
|
144
|
-
mutation_name = graphql_name
|
|
145
145
|
mutation_class = self
|
|
146
146
|
Class.new(input_object_class) do
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
class << self
|
|
148
|
+
def default_graphql_name
|
|
149
|
+
"#{self.mutation.graphql_name}Input"
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def description(new_desc = nil)
|
|
153
|
+
super || "Autogenerated input type of #{self.mutation.graphql_name}"
|
|
154
|
+
end
|
|
155
|
+
end
|
|
149
156
|
mutation(mutation_class)
|
|
150
157
|
# these might be inherited:
|
|
151
158
|
mutation_args.each do |arg|
|
|
@@ -20,7 +20,17 @@ module GraphQL
|
|
|
20
20
|
@payload_type ||= generate_payload_type
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
def type(new_type = nil, null: nil)
|
|
24
|
+
if new_type
|
|
25
|
+
payload_type(new_type)
|
|
26
|
+
if !null.nil?
|
|
27
|
+
self.null(null)
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
super()
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
24
34
|
alias :type_expr :payload_type
|
|
25
35
|
|
|
26
36
|
def field_class(new_class = nil)
|