graphql 2.6.14 → 2.6.15
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/templates/graphql_controller.erb +7 -1
- data/lib/graphql/analysis/max_query_complexity.rb +2 -1
- data/lib/graphql/analysis/max_query_depth.rb +2 -1
- data/lib/graphql/analysis/query_complexity.rb +2 -1
- data/lib/graphql/analysis/query_depth.rb +1 -1
- data/lib/graphql/analysis/visitor.rb +14 -2
- data/lib/graphql/analysis.rb +4 -5
- data/lib/graphql/analysis_error.rb +1 -1
- data/lib/graphql/coercion_error.rb +1 -1
- data/lib/graphql/current.rb +5 -1
- data/lib/graphql/dashboard.rb +1 -1
- data/lib/graphql/date_encoding_error.rb +3 -1
- data/lib/graphql/duration_encoding_error.rb +3 -1
- data/lib/graphql/execution/directive_checks.rb +2 -1
- data/lib/graphql/execution/errors.rb +18 -7
- data/lib/graphql/execution/field_resolve_step.rb +3 -3
- data/lib/graphql/execution/input_values.rb +160 -120
- data/lib/graphql/execution/interpreter/runtime.rb +9 -5
- data/lib/graphql/execution/lookahead.rb +19 -8
- data/lib/graphql/execution/next.rb +1 -0
- data/lib/graphql/execution/runner.rb +19 -12
- data/lib/graphql/execution/selections_step.rb +1 -1
- data/lib/graphql/execution/variable_values.rb +248 -0
- data/lib/graphql/float_decoding_error.rb +3 -1
- data/lib/graphql/integer_decoding_error.rb +3 -1
- data/lib/graphql/introspection/base_object.rb +1 -1
- data/lib/graphql/introspection/directive_location_enum.rb +1 -1
- data/lib/graphql/introspection/directive_type.rb +3 -1
- data/lib/graphql/introspection/dynamic_fields.rb +3 -1
- data/lib/graphql/introspection/enum_value_type.rb +3 -1
- data/lib/graphql/introspection/field_type.rb +5 -1
- data/lib/graphql/introspection/type_kind_enum.rb +1 -1
- data/lib/graphql/introspection.rb +2 -1
- data/lib/graphql/language/comment.rb +2 -1
- data/lib/graphql/language/generation.rb +2 -1
- data/lib/graphql/language/lexer.rb +29 -21
- data/lib/graphql/language/parser.rb +10 -7
- data/lib/graphql/language.rb +1 -1
- data/lib/graphql/name_validator.rb +2 -1
- data/lib/graphql/pagination.rb +1 -1
- data/lib/graphql/query/fingerprint.rb +2 -1
- data/lib/graphql/query/partial.rb +4 -0
- data/lib/graphql/query.rb +8 -12
- data/lib/graphql/railtie.rb +1 -1
- data/lib/graphql/relay.rb +1 -1
- data/lib/graphql/rubocop.rb +1 -1
- data/lib/graphql/runtime_error.rb +1 -1
- data/lib/graphql/runtime_type_error.rb +1 -1
- data/lib/graphql/schema/always_visible.rb +3 -1
- data/lib/graphql/schema/base_64_encoder.rb +3 -1
- data/lib/graphql/schema/built_in_types.rb +2 -2
- data/lib/graphql/schema/directive/deprecated.rb +1 -1
- data/lib/graphql/schema/directive/include.rb +2 -1
- data/lib/graphql/schema/directive/skip.rb +2 -1
- data/lib/graphql/schema/directive/specified_by.rb +1 -1
- data/lib/graphql/schema/field/scope_extension.rb +2 -1
- data/lib/graphql/schema/field.rb +3 -0
- data/lib/graphql/schema/find_inherited_value.rb +5 -1
- data/lib/graphql/schema/member/graphql_type_names.rb +1 -1
- data/lib/graphql/schema/member/has_directives.rb +20 -22
- data/lib/graphql/schema/member/has_path.rb +2 -1
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +2 -1
- data/lib/graphql/schema/member.rb +3 -2
- data/lib/graphql/schema/mutation.rb +6 -1
- data/lib/graphql/schema/object.rb +1 -1
- data/lib/graphql/schema/resolver.rb +2 -2
- data/lib/graphql/schema/type_expression.rb +3 -1
- data/lib/graphql/schema/validator/all_validator.rb +6 -3
- data/lib/graphql/static_validation/all_rules.rb +1 -1
- data/lib/graphql/static_validation/base_visitor.rb +125 -53
- data/lib/graphql/static_validation/definition_dependencies.rb +14 -2
- data/lib/graphql/static_validation/interpreter_visitor.rb +1 -1
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +4 -1
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +2 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +8 -4
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +2 -1
- data/lib/graphql/static_validation/rules/fragments_are_named.rb +2 -1
- data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +4 -1
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +6 -3
- data/lib/graphql/static_validation/rules/fragments_are_used.rb +2 -1
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +3 -1
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +3 -2
- data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +4 -1
- data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +4 -1
- data/lib/graphql/static_validation/rules/not_single_subscription_error.rb +4 -1
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +9 -2
- data/lib/graphql/static_validation/rules/query_root_exists.rb +3 -2
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +4 -1
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +10 -4
- data/lib/graphql/static_validation/rules/subscription_root_exists_and_single_subscription_selection.rb +8 -6
- data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +4 -1
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +5 -4
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +2 -1
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +2 -1
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +1 -1
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
- data/lib/graphql/static_validation/validation_context.rb +49 -14
- data/lib/graphql/static_validation/validation_timeout_error.rb +4 -1
- data/lib/graphql/static_validation.rb +1 -2
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +14 -13
- data/lib/graphql/testing.rb +1 -1
- data/lib/graphql/tracing/legacy_trace.rb +1 -1
- data/lib/graphql/tracing/null_trace.rb +1 -1
- data/lib/graphql/types/big_int.rb +4 -1
- data/lib/graphql/types/boolean.rb +3 -1
- data/lib/graphql/types/id.rb +3 -1
- data/lib/graphql/types/iso_8601_date.rb +1 -0
- data/lib/graphql/types/iso_8601_date_time.rb +6 -2
- data/lib/graphql/types/iso_8601_duration.rb +3 -0
- data/lib/graphql/types/relay/base_connection.rb +1 -1
- data/lib/graphql/types/relay/base_edge.rb +1 -1
- data/lib/graphql/types/relay/node.rb +1 -1
- data/lib/graphql/types/relay/page_info.rb +1 -1
- data/lib/graphql/types/relay/page_info_behaviors.rb +4 -1
- data/lib/graphql/types/relay.rb +1 -1
- data/lib/graphql/types/string.rb +1 -0
- data/lib/graphql/types.rb +1 -1
- data/lib/graphql/version.rb +2 -2
- metadata +3 -4
- data/lib/graphql/query/variables.rb +0 -99
- data/lib/graphql/static_validation/literal_validator.rb +0 -157
data/lib/graphql/query.rb
CHANGED
|
@@ -47,7 +47,6 @@ module GraphQL
|
|
|
47
47
|
autoload :NullContext, "graphql/query/null_context"
|
|
48
48
|
autoload :Partial, "graphql/query/partial"
|
|
49
49
|
autoload :Result, "graphql/query/result"
|
|
50
|
-
autoload :Variables, "graphql/query/variables"
|
|
51
50
|
autoload :InputValidationResult, "graphql/query/input_validation_result"
|
|
52
51
|
autoload :VariableValidationError, "graphql/query/variable_validation_error"
|
|
53
52
|
autoload :ValidationPipeline, "graphql/query/validation_pipeline"
|
|
@@ -236,6 +235,7 @@ module GraphQL
|
|
|
236
235
|
@root_value = root_value
|
|
237
236
|
@fragments = nil
|
|
238
237
|
@operations = nil
|
|
238
|
+
@input_values = nil
|
|
239
239
|
@finalizers = @top_level_finalizers = nil
|
|
240
240
|
@validate = validate
|
|
241
241
|
self.static_validator = static_validator if static_validator
|
|
@@ -332,6 +332,10 @@ module GraphQL
|
|
|
332
332
|
end
|
|
333
333
|
end
|
|
334
334
|
|
|
335
|
+
def input_values # :nodoc:
|
|
336
|
+
@input_values ||= Execution::InputValues.new(self)
|
|
337
|
+
end
|
|
338
|
+
|
|
335
339
|
def result_values=(result_hash) # :nodoc:
|
|
336
340
|
if @executed
|
|
337
341
|
raise "Invariant: Can't reassign result"
|
|
@@ -424,20 +428,12 @@ module GraphQL
|
|
|
424
428
|
#
|
|
425
429
|
# **Returns**
|
|
426
430
|
#
|
|
427
|
-
# - `GraphQL::
|
|
431
|
+
# - `GraphQL::Execution::VariableValues` — Variables to apply to this query
|
|
428
432
|
#
|
|
429
433
|
# :call-seq:
|
|
430
|
-
# variables() -> GraphQL::
|
|
434
|
+
# variables() -> GraphQL::Execution::VariableValues
|
|
431
435
|
def variables
|
|
432
|
-
@variables ||=
|
|
433
|
-
with_prepared_ast {
|
|
434
|
-
GraphQL::Query::Variables.new(
|
|
435
|
-
@context,
|
|
436
|
-
@ast_variables,
|
|
437
|
-
@provided_variables,
|
|
438
|
-
)
|
|
439
|
-
}
|
|
440
|
-
end
|
|
436
|
+
@variables ||= with_prepared_ast { input_values.variable_values }
|
|
441
437
|
end
|
|
442
438
|
|
|
443
439
|
# A version of the given query string, with:
|
data/lib/graphql/railtie.rb
CHANGED
data/lib/graphql/relay.rb
CHANGED
data/lib/graphql/rubocop.rb
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
module GraphQL
|
|
4
4
|
class Schema
|
|
5
5
|
module AlwaysVisible
|
|
6
|
+
#: (singleton(GraphQL::Schema) schema, **untyped opts) -> void
|
|
6
7
|
def self.use(schema, **opts)
|
|
7
8
|
schema.use(GraphQL::Schema::Visibility, profiles: { nil => {} })
|
|
8
9
|
schema.extend(self)
|
|
9
10
|
end
|
|
10
11
|
|
|
12
|
+
#: (untyped _member, GraphQL::Query::Context _context) -> bool
|
|
11
13
|
def visible?(_member, _context)
|
|
12
14
|
true
|
|
13
15
|
end
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
require "base64"
|
|
4
4
|
module GraphQL
|
|
5
5
|
class Schema
|
|
6
6
|
module Base64Encoder # :nodoc:
|
|
7
|
+
#: (String unencoded_text, ?nonce: bool) -> String
|
|
7
8
|
def self.encode(unencoded_text, nonce: false)
|
|
8
9
|
Base64.urlsafe_encode64(unencoded_text, padding: false)
|
|
9
10
|
end
|
|
10
11
|
|
|
12
|
+
#: (String encoded_text, ?nonce: bool) -> String
|
|
11
13
|
def self.decode(encoded_text, nonce: false)
|
|
12
14
|
# urlsafe_decode64 is for forward compatibility
|
|
13
15
|
Base64.urlsafe_decode64(encoded_text)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
module GraphQL
|
|
4
4
|
class Schema
|
|
5
5
|
BUILT_IN_TYPES = {
|
|
@@ -8,6 +8,6 @@ module GraphQL
|
|
|
8
8
|
"Float" => GraphQL::Types::Float,
|
|
9
9
|
"Boolean" => GraphQL::Types::Boolean,
|
|
10
10
|
"ID" => GraphQL::Types::ID,
|
|
11
|
-
}
|
|
11
|
+
} #: Hash[String, GraphQL::Schema::Member::type_definition]
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
module GraphQL
|
|
4
4
|
class Schema
|
|
5
5
|
class Directive < GraphQL::Schema::Member
|
|
@@ -17,6 +17,7 @@ module GraphQL
|
|
|
17
17
|
|
|
18
18
|
default_directive true
|
|
19
19
|
|
|
20
|
+
#: (Hash[Symbol, untyped] args, GraphQL::Query::Context ctx) -> bool
|
|
20
21
|
def self.static_include?(args, ctx)
|
|
21
22
|
!!args[:if]
|
|
22
23
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
module GraphQL
|
|
4
4
|
class Schema
|
|
5
5
|
class Directive < GraphQL::Schema::Member
|
|
@@ -17,6 +17,7 @@ module GraphQL
|
|
|
17
17
|
|
|
18
18
|
default_directive true
|
|
19
19
|
|
|
20
|
+
#: (Hash[Symbol, untyped] args, GraphQL::Query::Context ctx) -> bool
|
|
20
21
|
def self.static_include?(args, ctx)
|
|
21
22
|
!args[:if]
|
|
22
23
|
end
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
|
|
4
4
|
module GraphQL
|
|
5
5
|
class Schema
|
|
6
6
|
class Field
|
|
7
7
|
class ScopeExtension < GraphQL::Schema::FieldExtension
|
|
8
|
+
#: (object: untyped, arguments: Hash[Symbol, untyped], context: GraphQL::Query::Context, value: untyped, memo: untyped) -> untyped
|
|
8
9
|
def after_resolve(object:, arguments:, context:, value:, memo:)
|
|
9
10
|
if object.is_a?(GraphQL::Schema::Object)
|
|
10
11
|
if value.nil?
|
data/lib/graphql/schema/field.rb
CHANGED
|
@@ -987,6 +987,9 @@ module GraphQL
|
|
|
987
987
|
|
|
988
988
|
if max_possible_page_size.nil?
|
|
989
989
|
max_possible_page_size = default_page_size || query.schema.default_page_size || max_page_size || query.schema.default_max_page_size
|
|
990
|
+
elsif max_possible_page_size < 0
|
|
991
|
+
# Pagination returns no items for a negative `first:` or `last:`, so it mustn't subtract from the total.
|
|
992
|
+
max_possible_page_size = 0
|
|
990
993
|
end
|
|
991
994
|
|
|
992
995
|
if max_possible_page_size.nil?
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
module GraphQL
|
|
4
4
|
class Schema
|
|
5
5
|
#--
|
|
6
6
|
# @requires_ancestor: Module
|
|
7
7
|
module FindInheritedValue
|
|
8
|
+
#: (Module[untyped] child_cls) -> void
|
|
8
9
|
def self.extended(child_cls)
|
|
9
10
|
child_cls.singleton_class.include(GraphQL::EmptyObjects)
|
|
10
11
|
end
|
|
11
12
|
|
|
13
|
+
#: (Module[untyped] child_cls) -> void
|
|
12
14
|
def self.included(child_cls)
|
|
13
15
|
child_cls.include(GraphQL::EmptyObjects)
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
private
|
|
17
19
|
|
|
20
|
+
# Returns whatever the inherited configuration method returns, so the result is `untyped`.
|
|
21
|
+
#: (Symbol method_name, ?untyped default_value) -> untyped
|
|
18
22
|
def find_inherited_value(method_name, default_value = nil)
|
|
19
23
|
if self.is_a?(Class)
|
|
20
24
|
superclass.respond_to?(method_name, true) ? superclass.send(method_name) : default_value
|
|
@@ -91,32 +91,18 @@ module GraphQL
|
|
|
91
91
|
else
|
|
92
92
|
GraphQL::EmptyObjects::EMPTY_ARRAY
|
|
93
93
|
end
|
|
94
|
-
when Module
|
|
95
|
-
dirs = nil #: Array[GraphQL::Schema::Directive]?
|
|
96
|
-
ancestors = schema_member.ancestors #: Array[untyped]
|
|
97
|
-
ancestors.reverse_each do |ancestor|
|
|
98
|
-
if ancestor.respond_to?(:own_directives) &&
|
|
99
|
-
!(anc_dirs = ancestor.own_directives).empty?
|
|
100
|
-
dirs ||= []
|
|
101
|
-
merge_directives(dirs, anc_dirs)
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
if directives
|
|
105
|
-
dirs ||= []
|
|
106
|
-
merge_directives(dirs, directives)
|
|
107
|
-
end
|
|
108
|
-
dirs || GraphQL::EmptyObjects::EMPTY_ARRAY
|
|
109
94
|
when HasDirectives
|
|
110
95
|
directives || GraphQL::EmptyObjects::EMPTY_ARRAY
|
|
111
96
|
else
|
|
112
|
-
raise "Invariant: how could #{schema_member} not be a Class
|
|
97
|
+
raise "Invariant: how could #{schema_member} not be a Class or instance of HasDirectives?"
|
|
113
98
|
end
|
|
114
99
|
end
|
|
115
100
|
|
|
116
101
|
private
|
|
117
102
|
|
|
118
103
|
# Modify `target` by adding items from `dirs` such that:
|
|
119
|
-
# - Any name conflict is overridden by the incoming member of `dirs
|
|
104
|
+
# - Any name conflict is overridden by the incoming member(s) of `dirs`.
|
|
105
|
+
# (Repeatable directives replace _all_ same-named directives in `target`, and all incoming ones are kept.)
|
|
120
106
|
# - Any other member of `dirs` is appended
|
|
121
107
|
#
|
|
122
108
|
# **Parameters**
|
|
@@ -131,14 +117,26 @@ module GraphQL
|
|
|
131
117
|
# :call-seq:
|
|
132
118
|
# merge_directives(Array[GraphQL::Schema::Directive] target, Array[GraphQL::Schema::Directive] dirs) -> void
|
|
133
119
|
def merge_directives(target, dirs)
|
|
134
|
-
dirs.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
120
|
+
incoming = dirs.group_by(&:graphql_name)
|
|
121
|
+
merged = [] #: Array[GraphQL::Schema::Directive]
|
|
122
|
+
target.each do |d|
|
|
123
|
+
name = d.graphql_name
|
|
124
|
+
if incoming.key?(name)
|
|
125
|
+
# Put the incoming directive(s) where the first overridden one was
|
|
126
|
+
if (replacements = incoming[name])
|
|
127
|
+
merged.concat(replacements)
|
|
128
|
+
incoming[name] = nil
|
|
129
|
+
end
|
|
138
130
|
else
|
|
139
|
-
|
|
131
|
+
merged << d
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
dirs.each do |dir|
|
|
135
|
+
if incoming[dir.graphql_name]
|
|
136
|
+
merged << dir
|
|
140
137
|
end
|
|
141
138
|
end
|
|
139
|
+
target.replace(merged)
|
|
142
140
|
nil
|
|
143
141
|
end
|
|
144
142
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
|
|
4
4
|
module GraphQL
|
|
5
5
|
class Schema
|
|
@@ -13,6 +13,7 @@ module GraphQL
|
|
|
13
13
|
#
|
|
14
14
|
# :call-seq:
|
|
15
15
|
# path() -> String
|
|
16
|
+
#: -> String?
|
|
16
17
|
def path
|
|
17
18
|
member = self #: untyped
|
|
18
19
|
path_str = if member.respond_to?(:graphql_name)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
|
|
4
4
|
module GraphQL
|
|
5
5
|
class Schema
|
|
@@ -7,6 +7,7 @@ module GraphQL
|
|
|
7
7
|
# Set up a type-specific error to make debugging & bug tracker integration better
|
|
8
8
|
module HasUnresolvedTypeError
|
|
9
9
|
private
|
|
10
|
+
#: (Module[untyped] child_class) -> void
|
|
10
11
|
def add_unresolved_type_error(child_class)
|
|
11
12
|
if child_class.name # Don't set this for anonymous classes
|
|
12
13
|
child_class.const_set(:UnresolvedTypeError, Class.new(GraphQL::UnresolvedTypeError))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
require 'graphql/schema/member/base_dsl_methods'
|
|
4
4
|
require 'graphql/schema/member/graphql_type_names'
|
|
5
5
|
require 'graphql/schema/member/has_ast_node'
|
|
@@ -23,7 +23,7 @@ module GraphQL
|
|
|
23
23
|
#
|
|
24
24
|
class Member # :nodoc:
|
|
25
25
|
# A module that defines a GraphQL interface type (it includes `GraphQL::Schema::Interface`).
|
|
26
|
-
#: type interface_definition = GraphQL::Schema::Interface::DefinitionMethods & Module
|
|
26
|
+
#: type interface_definition = GraphQL::Schema::Interface::DefinitionMethods & Module[untyped]
|
|
27
27
|
|
|
28
28
|
# A class or module that defines a GraphQL type:
|
|
29
29
|
# an object, union, enum, scalar or input object class, or an interface module.
|
|
@@ -40,6 +40,7 @@ module GraphQL
|
|
|
40
40
|
extend HasAstNode
|
|
41
41
|
extend HasDirectives
|
|
42
42
|
|
|
43
|
+
#: (GraphQL::Query::Context _ctx) -> bool
|
|
43
44
|
def self.authorizes?(_ctx)
|
|
44
45
|
false
|
|
45
46
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
|
|
4
4
|
module GraphQL
|
|
5
5
|
class Schema
|
|
@@ -67,6 +67,8 @@ module GraphQL
|
|
|
67
67
|
extend GraphQL::Schema::Member::HasFields
|
|
68
68
|
extend GraphQL::Schema::Resolver::HasPayloadType
|
|
69
69
|
|
|
70
|
+
# Returns the application's resolved value.
|
|
71
|
+
#: (Hash[Symbol, untyped] _args_hash) -> untyped
|
|
70
72
|
def call_resolve(_args_hash) # :nodoc:
|
|
71
73
|
# Clear any cached values from `loads` or authorization:
|
|
72
74
|
dataloader.clear_cache
|
|
@@ -74,17 +76,20 @@ module GraphQL
|
|
|
74
76
|
end
|
|
75
77
|
|
|
76
78
|
class << self
|
|
79
|
+
#: (GraphQL::Query::Context context) -> bool
|
|
77
80
|
def visible?(context)
|
|
78
81
|
true
|
|
79
82
|
end
|
|
80
83
|
|
|
81
84
|
private
|
|
82
85
|
|
|
86
|
+
#: (GraphQL::Schema::Field field_defn) -> String
|
|
83
87
|
def conflict_field_name_warning(field_defn)
|
|
84
88
|
"#{self.graphql_name}'s `field :#{field_defn.name}` conflicts with a built-in method, use `hash_key:` or `method:` to pick a different resolve behavior for this field (for example, `hash_key: :#{field_defn.resolver_method}_value`, and modify the return hash). Or use `method_conflict_warning: false` to suppress this warning."
|
|
85
89
|
end
|
|
86
90
|
|
|
87
91
|
# Override this to attach self as `mutation`
|
|
92
|
+
#: () -> singleton(GraphQL::Schema::Object)
|
|
88
93
|
def generate_payload_type
|
|
89
94
|
payload_class = super
|
|
90
95
|
payload_class.mutation(self)
|
|
@@ -89,7 +89,7 @@ module GraphQL
|
|
|
89
89
|
# authorized_new(Object object, GraphQL::Query::Context context) -> GraphQL::Schema::Object | GraphQL::Execution::Lazy | GraphQL::UnauthorizedError
|
|
90
90
|
def authorized_new(object, context)
|
|
91
91
|
context.query.current_trace.begin_authorized(self, object, context)
|
|
92
|
-
raised_auth_err = nil
|
|
92
|
+
raised_auth_err = nil #: GraphQL::UnauthorizedError?
|
|
93
93
|
begin
|
|
94
94
|
maybe_lazy_auth_val = context.query.current_trace.authorized(query: context.query, type: self, object: object) do
|
|
95
95
|
begin
|
|
@@ -125,7 +125,7 @@ module GraphQL
|
|
|
125
125
|
exec_result[exec_index] = err
|
|
126
126
|
rescue StandardError => stderr
|
|
127
127
|
exec_result[exec_index] = begin
|
|
128
|
-
context.query.handle_or_reraise(stderr)
|
|
128
|
+
context.query.handle_or_reraise(stderr, field: @field, arguments: @prepared_arguments, object: object)
|
|
129
129
|
rescue GraphQL::ExecutionError => ex_err
|
|
130
130
|
ex_err
|
|
131
131
|
end
|
|
@@ -265,7 +265,7 @@ module GraphQL
|
|
|
265
265
|
end
|
|
266
266
|
|
|
267
267
|
def self.authorizes?(context)
|
|
268
|
-
self.instance_method(:authorized?).owner != GraphQL::Schema::Resolver
|
|
268
|
+
self.instance_method(:authorized?).owner != GraphQL::Schema::Resolver || super
|
|
269
269
|
end
|
|
270
270
|
|
|
271
271
|
# Called when an object loaded by `loads:` fails the `.authorized?` check for its resolved GraphQL object type.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
module GraphQL
|
|
4
4
|
class Schema
|
|
5
5
|
module TypeExpression # :nodoc:
|
|
@@ -17,6 +17,7 @@ module GraphQL
|
|
|
17
17
|
#
|
|
18
18
|
# :call-seq:
|
|
19
19
|
# build_type(#type type_owner, GraphQL::Language::Nodes::AbstractNode ast_node) -> Class | GraphQL::Schema::NonNull | GraphQL::Schema:List
|
|
20
|
+
#: (GraphQL::Schema::Visibility::Profile | GraphQL::Schema::Warden::VisibilityProfile type_owner, GraphQL::Language::Nodes::AbstractNode ast_node) -> (GraphQL::Schema::Member::type_definition | GraphQL::Schema::NonNull | GraphQL::Schema::List | nil)
|
|
20
21
|
def self.build_type(type_owner, ast_node)
|
|
21
22
|
case ast_node
|
|
22
23
|
when GraphQL::Language::Nodes::TypeName
|
|
@@ -37,6 +38,7 @@ module GraphQL
|
|
|
37
38
|
class << self
|
|
38
39
|
private
|
|
39
40
|
|
|
41
|
+
#: (GraphQL::Schema::Member::type_definition | GraphQL::Schema::NonNull | GraphQL::Schema::List | nil type, Symbol wrapper_method) -> (GraphQL::Schema::NonNull | GraphQL::Schema::List | nil)
|
|
40
42
|
def wrap_type(type, wrapper_method)
|
|
41
43
|
if type.nil?
|
|
42
44
|
nil
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
|
|
4
4
|
module GraphQL
|
|
5
5
|
class Schema
|
|
@@ -29,16 +29,19 @@ module GraphQL
|
|
|
29
29
|
# validates: { all: { inclusion: { in: 1..12 } } }
|
|
30
30
|
# ```
|
|
31
31
|
class AllValidator < Validator
|
|
32
|
+
# `validators` is configuration for other validators, for example `{ format: { with: /.../ } }`.
|
|
33
|
+
#: (validated: GraphQL::Schema::Argument | GraphQL::Schema::Field | singleton(GraphQL::Schema::Resolver) | singleton(GraphQL::Schema::InputObject), ?allow_blank: bool, ?allow_null: bool, **untyped validators) -> void
|
|
32
34
|
def initialize(validated:, allow_blank: false, allow_null: false, **validators)
|
|
33
35
|
super(validated: validated, allow_blank: allow_blank, allow_null: allow_null)
|
|
34
36
|
|
|
35
|
-
@validators = Validator.from_config(validated, validators)
|
|
37
|
+
@validators = Validator.from_config(validated, validators) #: Array[GraphQL::Schema::Validator]
|
|
36
38
|
end
|
|
37
39
|
|
|
40
|
+
#: (untyped object, GraphQL::Query::Context context, untyped value) -> Array[String]
|
|
38
41
|
def validate(object, context, value)
|
|
39
42
|
return EMPTY_ARRAY if permitted_empty_value?(value)
|
|
40
43
|
|
|
41
|
-
all_errors = EMPTY_ARRAY
|
|
44
|
+
all_errors = EMPTY_ARRAY #: Array[String]
|
|
42
45
|
|
|
43
46
|
value.each do |subvalue|
|
|
44
47
|
@validators.each do |validator|
|