graphql 1.12.10 → 1.13.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 +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 +28 -1
- 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 +15 -3
- data/lib/graphql/backtrace/tracer.rb +7 -4
- data/lib/graphql/base_type.rb +4 -2
- data/lib/graphql/boolean_type.rb +1 -1
- data/lib/graphql/dataloader/null_dataloader.rb +1 -0
- data/lib/graphql/dataloader/source.rb +50 -2
- data/lib/graphql/dataloader.rb +110 -41
- 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/execute.rb +1 -1
- data/lib/graphql/execution/interpreter/arguments.rb +1 -1
- data/lib/graphql/execution/interpreter/arguments_cache.rb +5 -4
- data/lib/graphql/execution/interpreter/resolve.rb +6 -2
- data/lib/graphql/execution/interpreter/runtime.rb +513 -213
- data/lib/graphql/execution/interpreter.rb +4 -8
- data/lib/graphql/execution/lazy.rb +5 -1
- 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 +3 -3
- 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 +10 -4
- data/lib/graphql/language/lexer.rb +0 -3
- data/lib/graphql/language/lexer.rl +0 -4
- data/lib/graphql/language/nodes.rb +13 -3
- 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/active_record_relation_connection.rb +43 -6
- data/lib/graphql/pagination/connections.rb +40 -16
- data/lib/graphql/pagination/relation_connection.rb +57 -27
- 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 +5 -1
- 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 +247 -0
- data/lib/graphql/schema/argument.rb +103 -45
- data/lib/graphql/schema/build_from_definition.rb +13 -7
- 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 +14 -2
- data/lib/graphql/schema/directive.rb +7 -3
- data/lib/graphql/schema/enum.rb +70 -11
- 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 +243 -81
- data/lib/graphql/schema/field_extension.rb +89 -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 +39 -29
- 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 +1 -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 +7 -1
- data/lib/graphql/schema/object.rb +10 -75
- data/lib/graphql/schema/printer.rb +12 -17
- 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 +75 -65
- data/lib/graphql/schema/scalar.rb +2 -0
- data/lib/graphql/schema/subscription.rb +36 -8
- 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/required_validator.rb +29 -15
- data/lib/graphql/schema/validator.rb +33 -25
- data/lib/graphql/schema/warden.rb +116 -52
- data/lib/graphql/schema.rb +162 -227
- data/lib/graphql/static_validation/all_rules.rb +1 -0
- 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/query_root_exists.rb +17 -0
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +26 -0
- 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 +13 -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 +36 -6
- data/lib/graphql/subscriptions/event.rb +68 -31
- data/lib/graphql/subscriptions/serialize.rb +23 -3
- data/lib/graphql/subscriptions.rb +17 -19
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +6 -20
- data/lib/graphql/tracing/appsignal_tracing.rb +15 -0
- data/lib/graphql/tracing/notifications_tracing.rb +59 -0
- data/lib/graphql/types/big_int.rb +5 -1
- 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 +2 -2
- data/lib/graphql/types/relay/has_nodes_field.rb +2 -2
- data/lib/graphql/types/relay/node_field.rb +15 -4
- data/lib/graphql/types/relay/nodes_field.rb +14 -4
- 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 -28
- data/readme.md +1 -4
- metadata +17 -21
- data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
|
@@ -24,7 +24,7 @@ module GraphQL
|
|
|
24
24
|
GraphQL::Schema::Directive::FIELD,
|
|
25
25
|
)
|
|
26
26
|
|
|
27
|
-
argument :by, String,
|
|
27
|
+
argument :by, String,
|
|
28
28
|
description: "The name of the transform to run if applicable"
|
|
29
29
|
|
|
30
30
|
TRANSFORMS = [
|
|
@@ -39,7 +39,19 @@ module GraphQL
|
|
|
39
39
|
transform_name = arguments[:by]
|
|
40
40
|
if TRANSFORMS.include?(transform_name) && return_value.respond_to?(transform_name)
|
|
41
41
|
return_value = return_value.public_send(transform_name)
|
|
42
|
-
context.namespace(:interpreter)[:runtime].
|
|
42
|
+
response = context.namespace(:interpreter)[:runtime].final_result
|
|
43
|
+
*keys, last = path
|
|
44
|
+
keys.each do |key|
|
|
45
|
+
if response && (response = response[key])
|
|
46
|
+
next
|
|
47
|
+
else
|
|
48
|
+
break
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
if response
|
|
52
|
+
response[last] = return_value
|
|
53
|
+
end
|
|
54
|
+
nil
|
|
43
55
|
end
|
|
44
56
|
end
|
|
45
57
|
end
|
|
@@ -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
|
@@ -24,6 +24,15 @@ module GraphQL
|
|
|
24
24
|
extend GraphQL::Schema::Member::ValidatesInput
|
|
25
25
|
|
|
26
26
|
class UnresolvedValueError < GraphQL::EnumType::UnresolvedValueError
|
|
27
|
+
def initialize(value:, enum:, context:)
|
|
28
|
+
fix_message = ", but this isn't a valid value for `#{enum.graphql_name}`. Update the field or resolver to return one of `#{enum.graphql_name}`'s values instead."
|
|
29
|
+
message = if (cp = context[:current_path]) && (cf = context[:current_field])
|
|
30
|
+
"`#{cf.path}` returned `#{value.inspect}` at `#{cp.join(".")}`#{fix_message}"
|
|
31
|
+
else
|
|
32
|
+
"`#{value.inspect}` was returned for `#{enum.graphql_name}`#{fix_message}"
|
|
33
|
+
end
|
|
34
|
+
super(message)
|
|
35
|
+
end
|
|
27
36
|
end
|
|
28
37
|
|
|
29
38
|
class << self
|
|
@@ -37,20 +46,70 @@ module GraphQL
|
|
|
37
46
|
def value(*args, **kwargs, &block)
|
|
38
47
|
kwargs[:owner] = self
|
|
39
48
|
value = enum_value_class.new(*args, **kwargs, &block)
|
|
40
|
-
|
|
41
|
-
|
|
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}"
|
|
60
|
+
end
|
|
61
|
+
value
|
|
62
|
+
end
|
|
63
|
+
|
|
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
|
|
42
82
|
end
|
|
43
|
-
|
|
44
|
-
|
|
83
|
+
|
|
84
|
+
visible_values
|
|
45
85
|
end
|
|
46
86
|
|
|
47
|
-
# @return [
|
|
48
|
-
def
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 }
|
|
52
109
|
end
|
|
53
110
|
|
|
111
|
+
prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
|
112
|
+
|
|
54
113
|
# @return [GraphQL::EnumType]
|
|
55
114
|
def to_graphql
|
|
56
115
|
enum_type = GraphQL::EnumType.new
|
|
@@ -59,7 +118,7 @@ module GraphQL
|
|
|
59
118
|
enum_type.introspection = introspection
|
|
60
119
|
enum_type.ast_node = ast_node
|
|
61
120
|
values.each do |name, val|
|
|
62
|
-
enum_type.add_value(val.
|
|
121
|
+
enum_type.add_value(val.deprecated_to_graphql)
|
|
63
122
|
end
|
|
64
123
|
enum_type.metadata[:type_class] = self
|
|
65
124
|
enum_type
|
|
@@ -100,7 +159,7 @@ module GraphQL
|
|
|
100
159
|
if enum_value
|
|
101
160
|
enum_value.graphql_name
|
|
102
161
|
else
|
|
103
|
-
raise
|
|
162
|
+
raise self::UnresolvedValueError.new(enum: self, value: value, context: ctx)
|
|
104
163
|
end
|
|
105
164
|
end
|
|
106
165
|
|
|
@@ -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
|