graphql 1.12.16 → 1.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/graphql/core.rb +3 -1
- data/lib/generators/graphql/install_generator.rb +9 -2
- data/lib/generators/graphql/mutation_generator.rb +1 -1
- data/lib/generators/graphql/object_generator.rb +2 -1
- data/lib/generators/graphql/relay.rb +19 -11
- data/lib/generators/graphql/templates/schema.erb +14 -2
- data/lib/generators/graphql/type_generator.rb +0 -1
- data/lib/graphql/analysis/ast/field_usage.rb +3 -3
- data/lib/graphql/analysis/ast/query_complexity.rb +10 -14
- data/lib/graphql/analysis/ast/visitor.rb +4 -4
- data/lib/graphql/backtrace/table.rb +1 -1
- data/lib/graphql/base_type.rb +4 -2
- data/lib/graphql/boolean_type.rb +1 -1
- data/lib/graphql/dataloader/source.rb +50 -2
- data/lib/graphql/dataloader.rb +93 -37
- data/lib/graphql/define/instance_definable.rb +1 -1
- data/lib/graphql/deprecated_dsl.rb +11 -3
- data/lib/graphql/deprecation.rb +1 -5
- data/lib/graphql/directive/deprecated_directive.rb +1 -1
- data/lib/graphql/directive/include_directive.rb +1 -1
- data/lib/graphql/directive/skip_directive.rb +1 -1
- data/lib/graphql/directive.rb +0 -4
- data/lib/graphql/enum_type.rb +5 -1
- data/lib/graphql/execution/errors.rb +1 -0
- data/lib/graphql/execution/interpreter/arguments.rb +1 -1
- data/lib/graphql/execution/interpreter/arguments_cache.rb +2 -2
- data/lib/graphql/execution/interpreter/runtime.rb +39 -23
- data/lib/graphql/execution/lookahead.rb +2 -2
- data/lib/graphql/execution/multiplex.rb +4 -1
- data/lib/graphql/float_type.rb +1 -1
- data/lib/graphql/id_type.rb +1 -1
- data/lib/graphql/int_type.rb +1 -1
- data/lib/graphql/integer_encoding_error.rb +18 -2
- data/lib/graphql/introspection/directive_type.rb +1 -1
- data/lib/graphql/introspection/entry_points.rb +2 -2
- data/lib/graphql/introspection/enum_value_type.rb +2 -2
- data/lib/graphql/introspection/field_type.rb +2 -2
- data/lib/graphql/introspection/input_value_type.rb +10 -4
- data/lib/graphql/introspection/schema_type.rb +2 -2
- data/lib/graphql/introspection/type_type.rb +10 -10
- data/lib/graphql/language/block_string.rb +2 -6
- data/lib/graphql/language/document_from_schema_definition.rb +4 -2
- data/lib/graphql/language/lexer.rb +0 -3
- data/lib/graphql/language/lexer.rl +0 -4
- data/lib/graphql/language/nodes.rb +12 -2
- data/lib/graphql/language/parser.rb +442 -434
- data/lib/graphql/language/parser.y +5 -4
- data/lib/graphql/language/printer.rb +6 -1
- data/lib/graphql/language/sanitized_printer.rb +5 -5
- data/lib/graphql/language/token.rb +0 -4
- data/lib/graphql/name_validator.rb +0 -4
- data/lib/graphql/pagination/connections.rb +35 -16
- data/lib/graphql/query/arguments.rb +1 -1
- data/lib/graphql/query/arguments_cache.rb +1 -1
- data/lib/graphql/query/context.rb +15 -2
- data/lib/graphql/query/literal_input.rb +1 -1
- data/lib/graphql/query/null_context.rb +12 -7
- data/lib/graphql/query/serial_execution/field_resolution.rb +1 -1
- data/lib/graphql/query/validation_pipeline.rb +1 -1
- data/lib/graphql/query/variables.rb +5 -1
- data/lib/graphql/query.rb +4 -0
- data/lib/graphql/relay/edges_instrumentation.rb +0 -1
- data/lib/graphql/relay/global_id_resolve.rb +1 -1
- data/lib/graphql/relay/page_info.rb +1 -1
- data/lib/graphql/rubocop/graphql/base_cop.rb +36 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +43 -0
- data/lib/graphql/rubocop/graphql/default_required_true.rb +43 -0
- data/lib/graphql/rubocop.rb +4 -0
- data/lib/graphql/schema/addition.rb +37 -28
- data/lib/graphql/schema/argument.rb +79 -34
- data/lib/graphql/schema/build_from_definition.rb +5 -5
- data/lib/graphql/schema/directive/feature.rb +1 -1
- data/lib/graphql/schema/directive/flagged.rb +2 -2
- data/lib/graphql/schema/directive/include.rb +1 -1
- data/lib/graphql/schema/directive/skip.rb +1 -1
- data/lib/graphql/schema/directive/transform.rb +1 -1
- data/lib/graphql/schema/directive.rb +7 -3
- data/lib/graphql/schema/enum.rb +60 -10
- data/lib/graphql/schema/enum_value.rb +6 -0
- data/lib/graphql/schema/field/connection_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +140 -42
- data/lib/graphql/schema/field_extension.rb +52 -2
- data/lib/graphql/schema/find_inherited_value.rb +1 -0
- data/lib/graphql/schema/finder.rb +5 -5
- data/lib/graphql/schema/input_object.rb +13 -14
- data/lib/graphql/schema/interface.rb +11 -20
- data/lib/graphql/schema/introspection_system.rb +1 -1
- data/lib/graphql/schema/list.rb +3 -1
- data/lib/graphql/schema/member/accepts_definition.rb +15 -3
- data/lib/graphql/schema/member/build_type.rb +0 -4
- data/lib/graphql/schema/member/cached_graphql_definition.rb +29 -2
- data/lib/graphql/schema/member/has_arguments.rb +145 -57
- data/lib/graphql/schema/member/has_deprecation_reason.rb +1 -1
- data/lib/graphql/schema/member/has_fields.rb +76 -18
- data/lib/graphql/schema/member/has_interfaces.rb +90 -0
- data/lib/graphql/schema/member.rb +1 -0
- data/lib/graphql/schema/non_null.rb +3 -1
- data/lib/graphql/schema/object.rb +10 -75
- data/lib/graphql/schema/printer.rb +1 -1
- data/lib/graphql/schema/relay_classic_mutation.rb +37 -3
- data/lib/graphql/schema/resolver/has_payload_type.rb +27 -2
- data/lib/graphql/schema/resolver.rb +49 -64
- data/lib/graphql/schema/scalar.rb +2 -0
- data/lib/graphql/schema/subscription.rb +17 -9
- data/lib/graphql/schema/traversal.rb +1 -1
- data/lib/graphql/schema/type_expression.rb +1 -1
- data/lib/graphql/schema/type_membership.rb +18 -4
- data/lib/graphql/schema/union.rb +8 -1
- data/lib/graphql/schema/validator/allow_blank_validator.rb +29 -0
- data/lib/graphql/schema/validator/allow_null_validator.rb +26 -0
- data/lib/graphql/schema/validator/exclusion_validator.rb +3 -1
- data/lib/graphql/schema/validator/format_validator.rb +4 -5
- data/lib/graphql/schema/validator/inclusion_validator.rb +3 -1
- data/lib/graphql/schema/validator/length_validator.rb +5 -3
- data/lib/graphql/schema/validator/numericality_validator.rb +13 -2
- data/lib/graphql/schema/validator.rb +33 -25
- data/lib/graphql/schema/warden.rb +116 -52
- data/lib/graphql/schema.rb +124 -27
- data/lib/graphql/static_validation/base_visitor.rb +8 -5
- data/lib/graphql/static_validation/definition_dependencies.rb +0 -1
- data/lib/graphql/static_validation/error.rb +3 -1
- data/lib/graphql/static_validation/literal_validator.rb +1 -1
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +1 -1
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +52 -26
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +25 -4
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +2 -2
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +3 -1
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +4 -4
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +7 -7
- data/lib/graphql/static_validation/validation_context.rb +8 -2
- data/lib/graphql/static_validation/validator.rb +15 -12
- data/lib/graphql/string_encoding_error.rb +13 -3
- data/lib/graphql/string_type.rb +1 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +15 -5
- data/lib/graphql/subscriptions/event.rb +66 -13
- data/lib/graphql/subscriptions/serialize.rb +1 -1
- data/lib/graphql/subscriptions.rb +17 -19
- data/lib/graphql/tracing/appsignal_tracing.rb +15 -0
- data/lib/graphql/types/int.rb +1 -1
- data/lib/graphql/types/relay/connection_behaviors.rb +26 -9
- data/lib/graphql/types/relay/default_relay.rb +5 -1
- data/lib/graphql/types/relay/edge_behaviors.rb +13 -2
- data/lib/graphql/types/relay/has_node_field.rb +1 -1
- data/lib/graphql/types/relay/has_nodes_field.rb +1 -1
- data/lib/graphql/types/string.rb +1 -1
- data/lib/graphql/unauthorized_error.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +10 -32
- data/readme.md +1 -1
- metadata +13 -6
@@ -2,10 +2,6 @@
|
|
2
2
|
module GraphQL
|
3
3
|
class Schema
|
4
4
|
class Argument
|
5
|
-
if !String.method_defined?(:-@)
|
6
|
-
using GraphQL::StringDedupBackport
|
7
|
-
end
|
8
|
-
|
9
5
|
include GraphQL::Schema::Member::CachedGraphQLDefinition
|
10
6
|
include GraphQL::Schema::Member::AcceptsDefinition
|
11
7
|
include GraphQL::Schema::Member::HasPath
|
@@ -52,7 +48,7 @@ module GraphQL
|
|
52
48
|
# @param directives [Hash{Class => Hash}]
|
53
49
|
# @param deprecation_reason [String]
|
54
50
|
# @param validates [Hash, nil] Options for building validators, if any should be applied
|
55
|
-
def initialize(arg_name = nil, type_expr = nil, desc = nil, required
|
51
|
+
def initialize(arg_name = nil, type_expr = nil, desc = nil, required: true, type: nil, name: nil, loads: nil, description: nil, ast_node: nil, default_value: NO_DEFAULT, as: nil, from_resolver: false, camelize: true, prepare: nil, method_access: true, owner:, validates: nil, directives: nil, deprecation_reason: nil, &definition_block)
|
56
52
|
arg_name ||= name
|
57
53
|
@name = -(camelize ? Member::BuildType.camelize(arg_name.to_s) : arg_name.to_s)
|
58
54
|
@type_expr = type_expr || type
|
@@ -86,6 +82,10 @@ module GraphQL
|
|
86
82
|
end
|
87
83
|
end
|
88
84
|
|
85
|
+
def inspect
|
86
|
+
"#<#{self.class} #{path}: #{type.to_type_signature}#{description ? " @description=#{description.inspect}" : ""}>"
|
87
|
+
end
|
88
|
+
|
89
89
|
# @return [Object] the value used when the client doesn't provide a value for this argument
|
90
90
|
attr_reader :default_value
|
91
91
|
|
@@ -147,11 +147,11 @@ module GraphQL
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
elsif as_type.kind.input_object?
|
150
|
-
as_type.arguments.each do |_name, input_obj_arg|
|
150
|
+
as_type.arguments(ctx).each do |_name, input_obj_arg|
|
151
151
|
input_obj_arg = input_obj_arg.type_class
|
152
152
|
# TODO: this skips input objects whose values were alread replaced with application objects.
|
153
153
|
# See: https://github.com/rmosolgo/graphql-ruby/issues/2633
|
154
|
-
if value.
|
154
|
+
if value.is_a?(InputObject) && value.key?(input_obj_arg.keyword) && !input_obj_arg.authorized?(obj, value[input_obj_arg.keyword], ctx)
|
155
155
|
return false
|
156
156
|
end
|
157
157
|
end
|
@@ -161,6 +161,8 @@ module GraphQL
|
|
161
161
|
true
|
162
162
|
end
|
163
163
|
|
164
|
+
prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
165
|
+
|
164
166
|
def to_graphql
|
165
167
|
argument = GraphQL::Argument.new
|
166
168
|
argument.name = @name
|
@@ -260,45 +262,88 @@ module GraphQL
|
|
260
262
|
type.coerce_input(value, context)
|
261
263
|
end
|
262
264
|
|
263
|
-
#
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
context.
|
268
|
-
|
269
|
-
context.query.with_error_handling do
|
270
|
-
owner.load_application_object(self, loads, coerced_value, context)
|
265
|
+
# If this isn't lazy, then the block returns eagerly and assigns the result here
|
266
|
+
# If it _is_ lazy, then we write the lazy to the hash, then update it later
|
267
|
+
argument_values[arg_key] = context.schema.after_lazy(coerced_value) do |resolved_coerced_value|
|
268
|
+
if loads && !from_resolver?
|
269
|
+
loaded_value = context.query.with_error_handling do
|
270
|
+
load_and_authorize_value(owner, coerced_value, context)
|
271
271
|
end
|
272
272
|
end
|
273
|
-
end
|
274
273
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
274
|
+
maybe_loaded_value = loaded_value || resolved_coerced_value
|
275
|
+
context.schema.after_lazy(maybe_loaded_value) do |resolved_loaded_value|
|
276
|
+
owner.validate_directive_argument(self, resolved_loaded_value)
|
277
|
+
prepared_value = context.schema.error_handler.with_error_handling(context) do
|
278
|
+
prepare_value(parent_object, resolved_loaded_value, context: context)
|
279
|
+
end
|
280
280
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
281
|
+
# TODO code smell to access such a deeply-nested constant in a distant module
|
282
|
+
argument_values[arg_key] = GraphQL::Execution::Interpreter::ArgumentValue.new(
|
283
|
+
value: prepared_value,
|
284
|
+
definition: self,
|
285
|
+
default_used: default_used,
|
286
|
+
)
|
287
287
|
end
|
288
|
+
end
|
289
|
+
end
|
288
290
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
291
|
+
def load_and_authorize_value(load_method_owner, coerced_value, context)
|
292
|
+
if coerced_value.nil?
|
293
|
+
return nil
|
294
|
+
end
|
295
|
+
arg_load_method = "load_#{keyword}"
|
296
|
+
if load_method_owner.respond_to?(arg_load_method)
|
297
|
+
custom_loaded_value = if load_method_owner.is_a?(Class)
|
298
|
+
load_method_owner.public_send(arg_load_method, coerced_value, context)
|
299
|
+
else
|
300
|
+
load_method_owner.public_send(arg_load_method, coerced_value)
|
301
|
+
end
|
302
|
+
context.schema.after_lazy(custom_loaded_value) do |custom_value|
|
303
|
+
if loads
|
304
|
+
if type.list?
|
305
|
+
loaded_values = custom_value.each_with_index.map { |custom_val, idx|
|
306
|
+
id = coerced_value[idx]
|
307
|
+
load_method_owner.authorize_application_object(self, id, context, custom_val)
|
308
|
+
}
|
309
|
+
context.schema.after_any_lazies(loaded_values, &:itself)
|
310
|
+
else
|
311
|
+
load_method_owner.authorize_application_object(self, coerced_value, context, custom_loaded_value)
|
312
|
+
end
|
313
|
+
else
|
314
|
+
custom_value
|
315
|
+
end
|
316
|
+
end
|
317
|
+
elsif loads
|
318
|
+
if type.list?
|
319
|
+
loaded_values = coerced_value.map { |val| load_method_owner.load_and_authorize_application_object(self, val, context) }
|
320
|
+
context.schema.after_any_lazies(loaded_values, &:itself)
|
321
|
+
else
|
322
|
+
load_method_owner.load_and_authorize_application_object(self, coerced_value, context)
|
323
|
+
end
|
324
|
+
else
|
325
|
+
coerced_value
|
295
326
|
end
|
296
327
|
end
|
297
328
|
|
298
329
|
# @api private
|
299
330
|
def validate_default_value
|
300
331
|
coerced_default_value = begin
|
301
|
-
type
|
332
|
+
# This is weird, but we should accept single-item default values for list-type arguments.
|
333
|
+
# If we used `coerce_isolated_input` below, it would do this for us, but it's not really
|
334
|
+
# the right thing here because we expect default values in application format (Ruby values)
|
335
|
+
# not GraphQL format (scalar values).
|
336
|
+
#
|
337
|
+
# But I don't think Schema::List#coerce_result should apply wrapping to single-item lists.
|
338
|
+
prepped_default_value = if default_value.nil?
|
339
|
+
nil
|
340
|
+
elsif (type.kind.list? || (type.kind.non_null? && type.of_type.list?)) && !default_value.respond_to?(:map)
|
341
|
+
[default_value]
|
342
|
+
else
|
343
|
+
default_value
|
344
|
+
end
|
345
|
+
|
346
|
+
type.coerce_isolated_result(prepped_default_value) unless prepped_default_value.nil?
|
302
347
|
rescue GraphQL::Schema::Enum::UnresolvedValueError
|
303
348
|
# It raises this, which is helpful at runtime, but not here...
|
304
349
|
default_value
|
@@ -3,12 +3,7 @@ require "graphql/schema/build_from_definition/resolve_map"
|
|
3
3
|
|
4
4
|
module GraphQL
|
5
5
|
class Schema
|
6
|
-
# TODO Populate `.directive(...)` from here
|
7
6
|
module BuildFromDefinition
|
8
|
-
if !String.method_defined?(:-@)
|
9
|
-
using GraphQL::StringDedupBackport
|
10
|
-
end
|
11
|
-
|
12
7
|
class << self
|
13
8
|
# @see {Schema.from_definition}
|
14
9
|
def from_definition(definition_string, parser: GraphQL.default_parser, **kwargs)
|
@@ -394,6 +389,11 @@ module GraphQL
|
|
394
389
|
include GraphQL::Schema::Interface
|
395
390
|
graphql_name(interface_type_definition.name)
|
396
391
|
description(interface_type_definition.description)
|
392
|
+
interface_type_definition.interfaces.each do |interface_name|
|
393
|
+
"Implements: #{interface_type_definition} -> #{interface_name}"
|
394
|
+
interface_defn = type_resolver.call(interface_name)
|
395
|
+
implements(interface_defn)
|
396
|
+
end
|
397
397
|
ast_node(interface_type_definition)
|
398
398
|
builder.build_directives(self, interface_type_definition, type_resolver)
|
399
399
|
|
@@ -35,7 +35,7 @@ module GraphQL
|
|
35
35
|
GraphQL::Schema::Directive::INPUT_FIELD_DEFINITION,
|
36
36
|
)
|
37
37
|
|
38
|
-
argument :by, [String], "Flags to check for this schema member"
|
38
|
+
argument :by, [String], "Flags to check for this schema member"
|
39
39
|
|
40
40
|
module VisibleByFlag
|
41
41
|
def self.included(schema_class)
|
@@ -44,7 +44,7 @@ module GraphQL
|
|
44
44
|
|
45
45
|
def visible?(context)
|
46
46
|
if dir = self.directives.find { |d| d.is_a?(Flagged) }
|
47
|
-
relevant_flags = (f = context[:flags]) && dir.arguments[:by] & f
|
47
|
+
relevant_flags = (f = context[:flags]) && dir.arguments[:by] & f # rubocop:disable Development/ContextIsPassedCop -- definition-related
|
48
48
|
relevant_flags && relevant_flags.any? && super
|
49
49
|
else
|
50
50
|
super
|
@@ -8,6 +8,8 @@ module GraphQL
|
|
8
8
|
# - {.resolve}: Wraps field resolution (so it should call `yield` to continue)
|
9
9
|
class Directive < GraphQL::Schema::Member
|
10
10
|
extend GraphQL::Schema::Member::HasArguments
|
11
|
+
extend GraphQL::Schema::Member::AcceptsDefinition
|
12
|
+
|
11
13
|
class << self
|
12
14
|
# Directives aren't types, they don't have kinds.
|
13
15
|
undef_method :kind
|
@@ -53,6 +55,8 @@ module GraphQL
|
|
53
55
|
default_directive
|
54
56
|
end
|
55
57
|
|
58
|
+
prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
59
|
+
|
56
60
|
def to_graphql
|
57
61
|
defn = GraphQL::Directive.new
|
58
62
|
defn.name = self.graphql_name
|
@@ -61,9 +65,9 @@ module GraphQL
|
|
61
65
|
defn.default_directive = self.default_directive
|
62
66
|
defn.ast_node = ast_node
|
63
67
|
defn.metadata[:type_class] = self
|
64
|
-
|
65
|
-
arg_graphql = arg_defn.to_graphql
|
66
|
-
defn.arguments[arg_graphql.name] = arg_graphql
|
68
|
+
all_argument_definitions.each do |arg_defn|
|
69
|
+
arg_graphql = arg_defn.to_graphql(silence_deprecation_warning: true)
|
70
|
+
defn.arguments[arg_graphql.name] = arg_graphql # rubocop:disable Development/ContextIsPassedCop -- legacy-related
|
67
71
|
end
|
68
72
|
# Make a reference to a classic-style Arguments class
|
69
73
|
defn.arguments_class = GraphQL::Query::Arguments.construct_arguments_class(defn)
|
data/lib/graphql/schema/enum.rb
CHANGED
@@ -46,20 +46,70 @@ module GraphQL
|
|
46
46
|
def value(*args, **kwargs, &block)
|
47
47
|
kwargs[:owner] = self
|
48
48
|
value = enum_value_class.new(*args, **kwargs, &block)
|
49
|
-
|
50
|
-
|
49
|
+
key = value.graphql_name
|
50
|
+
prev_value = own_values[key]
|
51
|
+
case prev_value
|
52
|
+
when nil
|
53
|
+
own_values[key] = value
|
54
|
+
when GraphQL::Schema::EnumValue
|
55
|
+
own_values[key] = [prev_value, value]
|
56
|
+
when Array
|
57
|
+
prev_value << value
|
58
|
+
else
|
59
|
+
raise "Invariant: Unexpected enum value for #{key.inspect}: #{prev_value.inspect}"
|
51
60
|
end
|
52
|
-
|
53
|
-
nil
|
61
|
+
value
|
54
62
|
end
|
55
63
|
|
56
|
-
# @return [
|
57
|
-
def
|
58
|
-
inherited_values = superclass
|
59
|
-
|
60
|
-
|
64
|
+
# @return [Array<GraphQL::Schema::EnumValue>] Possible values of this enum
|
65
|
+
def enum_values(context = GraphQL::Query::NullContext)
|
66
|
+
inherited_values = superclass.respond_to?(:enum_values) ? superclass.enum_values(context) : nil
|
67
|
+
visible_values = []
|
68
|
+
warden = Warden.from_context(context)
|
69
|
+
own_values.each do |key, values_entry|
|
70
|
+
if (v = Warden.visible_entry?(:visible_enum_value?, values_entry, context, warden))
|
71
|
+
visible_values << v
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
if inherited_values
|
76
|
+
# Local values take precedence over inherited ones
|
77
|
+
inherited_values.each do |i_val|
|
78
|
+
if !visible_values.any? { |v| v.graphql_name == i_val.graphql_name }
|
79
|
+
visible_values << i_val
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
visible_values
|
61
85
|
end
|
62
86
|
|
87
|
+
# @return [Array<Schema::EnumValue>] An unfiltered list of all definitions
|
88
|
+
def all_enum_value_definitions
|
89
|
+
all_defns = if superclass.respond_to?(:all_enum_value_definitions)
|
90
|
+
superclass.all_enum_value_definitions
|
91
|
+
else
|
92
|
+
[]
|
93
|
+
end
|
94
|
+
|
95
|
+
@own_values && @own_values.each do |_key, value|
|
96
|
+
if value.is_a?(Array)
|
97
|
+
all_defns.concat(value)
|
98
|
+
else
|
99
|
+
all_defns << value
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
all_defns
|
104
|
+
end
|
105
|
+
|
106
|
+
# @return [Hash<String => GraphQL::Schema::EnumValue>] Possible values of this enum, keyed by name.
|
107
|
+
def values(context = GraphQL::Query::NullContext)
|
108
|
+
enum_values(context).each_with_object({}) { |val, obj| obj[val.graphql_name] = val }
|
109
|
+
end
|
110
|
+
|
111
|
+
prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
112
|
+
|
63
113
|
# @return [GraphQL::EnumType]
|
64
114
|
def to_graphql
|
65
115
|
enum_type = GraphQL::EnumType.new
|
@@ -68,7 +118,7 @@ module GraphQL
|
|
68
118
|
enum_type.introspection = introspection
|
69
119
|
enum_type.ast_node = ast_node
|
70
120
|
values.each do |name, val|
|
71
|
-
enum_type.add_value(val.
|
121
|
+
enum_type.add_value(val.deprecated_to_graphql)
|
72
122
|
end
|
73
123
|
enum_type.metadata[:type_class] = self
|
74
124
|
enum_type
|
@@ -73,6 +73,8 @@ module GraphQL
|
|
73
73
|
@value
|
74
74
|
end
|
75
75
|
|
76
|
+
prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
77
|
+
|
76
78
|
# @return [GraphQL::EnumType::EnumValue] A runtime-ready object derived from this object
|
77
79
|
def to_graphql
|
78
80
|
enum_value = GraphQL::EnumType::EnumValue.new
|
@@ -85,6 +87,10 @@ module GraphQL
|
|
85
87
|
enum_value
|
86
88
|
end
|
87
89
|
|
90
|
+
def inspect
|
91
|
+
"#<#{self.class} #{path} @value=#{@value.inspect}#{description ? " @description=#{description.inspect}" : ""}>"
|
92
|
+
end
|
93
|
+
|
88
94
|
def visible?(_ctx); true; end
|
89
95
|
def accessible?(_ctx); true; end
|
90
96
|
def authorized?(_ctx); true; end
|
@@ -42,7 +42,7 @@ module GraphQL
|
|
42
42
|
value.after_value ||= original_arguments[:after]
|
43
43
|
value.last_value ||= original_arguments[:last]
|
44
44
|
value.before_value ||= original_arguments[:before]
|
45
|
-
value.arguments ||= original_arguments
|
45
|
+
value.arguments ||= original_arguments # rubocop:disable Development/ContextIsPassedCop -- unrelated .arguments method
|
46
46
|
value.field ||= field
|
47
47
|
if field.has_max_page_size? && !value.has_max_page_size_override?
|
48
48
|
value.max_page_size = field.max_page_size
|