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
|
@@ -15,8 +15,6 @@ module GraphQL
|
|
|
15
15
|
#
|
|
16
16
|
# A resolver's configuration may be overridden with other keywords in the `field(...)` call.
|
|
17
17
|
#
|
|
18
|
-
# See the {.field_options} to see how a Resolver becomes a set of field configuration options.
|
|
19
|
-
#
|
|
20
18
|
# @see {GraphQL::Schema::Mutation} for a concrete subclass of `Resolver`.
|
|
21
19
|
# @see {GraphQL::Function} `Resolver` is a replacement for `GraphQL::Function`
|
|
22
20
|
class Resolver
|
|
@@ -210,6 +208,18 @@ module GraphQL
|
|
|
210
208
|
end
|
|
211
209
|
|
|
212
210
|
class << self
|
|
211
|
+
def field_arguments(context = GraphQL::Query::NullContext)
|
|
212
|
+
arguments(context)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def get_field_argument(name, context = GraphQL::Query::NullContext)
|
|
216
|
+
get_argument(name, context)
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def own_field_arguments
|
|
220
|
+
own_arguments
|
|
221
|
+
end
|
|
222
|
+
|
|
213
223
|
# Default `:resolve` set below.
|
|
214
224
|
# @return [Symbol] The method to call on instances of this object to resolve the field
|
|
215
225
|
def resolve_method(new_method = nil)
|
|
@@ -242,6 +252,14 @@ module GraphQL
|
|
|
242
252
|
@null.nil? ? (superclass.respond_to?(:null) ? superclass.null : true) : @null
|
|
243
253
|
end
|
|
244
254
|
|
|
255
|
+
def resolver_method(new_method_name = nil)
|
|
256
|
+
if new_method_name
|
|
257
|
+
@resolver_method = new_method_name
|
|
258
|
+
else
|
|
259
|
+
@resolver_method || :resolve_with_support
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
245
263
|
# Call this method to get the return type of the field,
|
|
246
264
|
# or use it as a configuration method to assign a return type
|
|
247
265
|
# instead of generating one.
|
|
@@ -257,8 +275,8 @@ module GraphQL
|
|
|
257
275
|
@type_expr = new_type
|
|
258
276
|
@null = null
|
|
259
277
|
else
|
|
260
|
-
if
|
|
261
|
-
GraphQL::Schema::Member::BuildType.parse_type(
|
|
278
|
+
if type_expr
|
|
279
|
+
GraphQL::Schema::Member::BuildType.parse_type(type_expr, null: self.null)
|
|
262
280
|
elsif superclass.respond_to?(:type)
|
|
263
281
|
superclass.type
|
|
264
282
|
else
|
|
@@ -307,47 +325,7 @@ module GraphQL
|
|
|
307
325
|
|
|
308
326
|
# @return [Boolean] `true` if this resolver or a superclass has an assigned `max_page_size`
|
|
309
327
|
def has_max_page_size?
|
|
310
|
-
defined?(@max_page_size) || (superclass.respond_to?(:has_max_page_size?) && superclass.has_max_page_size?)
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
-
def field_options
|
|
314
|
-
|
|
315
|
-
all_args = {}
|
|
316
|
-
all_argument_definitions.each do |arg|
|
|
317
|
-
if (prev_entry = all_args[arg.graphql_name])
|
|
318
|
-
if prev_entry.is_a?(Array)
|
|
319
|
-
prev_entry << arg
|
|
320
|
-
else
|
|
321
|
-
all_args[arg.graphql_name] = [prev_entry, arg]
|
|
322
|
-
end
|
|
323
|
-
else
|
|
324
|
-
all_args[arg.graphql_name] = arg
|
|
325
|
-
end
|
|
326
|
-
end
|
|
327
|
-
|
|
328
|
-
field_opts = {
|
|
329
|
-
type: type_expr,
|
|
330
|
-
description: description,
|
|
331
|
-
extras: extras,
|
|
332
|
-
resolver_method: :resolve_with_support,
|
|
333
|
-
resolver_class: self,
|
|
334
|
-
arguments: all_args,
|
|
335
|
-
null: null,
|
|
336
|
-
complexity: complexity,
|
|
337
|
-
broadcastable: broadcastable?,
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
# If there aren't any, then the returned array is `[].freeze`,
|
|
341
|
-
# but passing that along breaks some user code.
|
|
342
|
-
if (exts = extensions).any?
|
|
343
|
-
field_opts[:extensions] = exts
|
|
344
|
-
end
|
|
345
|
-
|
|
346
|
-
if has_max_page_size?
|
|
347
|
-
field_opts[:max_page_size] = max_page_size
|
|
348
|
-
end
|
|
349
|
-
|
|
350
|
-
field_opts
|
|
328
|
+
(!!defined?(@max_page_size)) || (superclass.respond_to?(:has_max_page_size?) && superclass.has_max_page_size?)
|
|
351
329
|
end
|
|
352
330
|
|
|
353
331
|
# A non-normalized type configuration, without `null` applied
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
module GraphQL
|
|
3
3
|
class Schema
|
|
4
4
|
class Scalar < GraphQL::Schema::Member
|
|
5
|
-
extend GraphQL::Schema::Member::AcceptsDefinition
|
|
6
5
|
extend GraphQL::Schema::Member::ValidatesInput
|
|
7
6
|
|
|
8
7
|
class << self
|
|
@@ -14,20 +13,6 @@ module GraphQL
|
|
|
14
13
|
val
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
|
18
|
-
|
|
19
|
-
def to_graphql
|
|
20
|
-
type_defn = GraphQL::ScalarType.new
|
|
21
|
-
type_defn.name = graphql_name
|
|
22
|
-
type_defn.description = description
|
|
23
|
-
type_defn.coerce_result = method(:coerce_result)
|
|
24
|
-
type_defn.coerce_input = method(:coerce_input)
|
|
25
|
-
type_defn.metadata[:type_class] = self
|
|
26
|
-
type_defn.default_scalar = default_scalar
|
|
27
|
-
type_defn.ast_node = ast_node
|
|
28
|
-
type_defn
|
|
29
|
-
end
|
|
30
|
-
|
|
31
16
|
def kind
|
|
32
17
|
GraphQL::TypeKinds::SCALAR
|
|
33
18
|
end
|
|
@@ -56,7 +41,6 @@ module GraphQL
|
|
|
56
41
|
end
|
|
57
42
|
|
|
58
43
|
def validate_non_null_input(value, ctx)
|
|
59
|
-
result = Query::InputValidationResult.new
|
|
60
44
|
coerced_result = begin
|
|
61
45
|
ctx.query.with_error_handling do
|
|
62
46
|
coerce_input(value, ctx)
|
|
@@ -71,11 +55,12 @@ module GraphQL
|
|
|
71
55
|
else
|
|
72
56
|
" #{GraphQL::Language.serialize(value)}"
|
|
73
57
|
end
|
|
74
|
-
|
|
58
|
+
Query::InputValidationResult.from_problem("Could not coerce value#{str_value} to #{graphql_name}")
|
|
75
59
|
elsif coerced_result.is_a?(GraphQL::CoercionError)
|
|
76
|
-
|
|
60
|
+
Query::InputValidationResult.from_problem(coerced_result.message, message: coerced_result.message, extensions: coerced_result.extensions)
|
|
61
|
+
else
|
|
62
|
+
nil
|
|
77
63
|
end
|
|
78
|
-
result
|
|
79
64
|
end
|
|
80
65
|
end
|
|
81
66
|
end
|
|
@@ -143,13 +143,6 @@ module GraphQL
|
|
|
143
143
|
def self.topic_for(arguments:, field:, scope:)
|
|
144
144
|
Subscriptions::Serialize.dump_recursive([scope, field.graphql_name, arguments])
|
|
145
145
|
end
|
|
146
|
-
|
|
147
|
-
# Overriding Resolver#field_options to include subscription_scope
|
|
148
|
-
def self.field_options
|
|
149
|
-
super.merge(
|
|
150
|
-
subscription_scope: subscription_scope
|
|
151
|
-
)
|
|
152
|
-
end
|
|
153
146
|
end
|
|
154
147
|
end
|
|
155
148
|
end
|
data/lib/graphql/schema/union.rb
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
module GraphQL
|
|
3
3
|
class Schema
|
|
4
4
|
class Union < GraphQL::Schema::Member
|
|
5
|
-
extend GraphQL::Schema::Member::AcceptsDefinition
|
|
6
5
|
extend GraphQL::Schema::Member::HasUnresolvedTypeError
|
|
7
6
|
|
|
8
7
|
class << self
|
|
@@ -33,21 +32,6 @@ module GraphQL
|
|
|
33
32
|
type_memberships.map(&:object_type)
|
|
34
33
|
end
|
|
35
34
|
|
|
36
|
-
prepend GraphQL::Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
|
|
37
|
-
|
|
38
|
-
def to_graphql
|
|
39
|
-
type_defn = GraphQL::UnionType.new
|
|
40
|
-
type_defn.name = graphql_name
|
|
41
|
-
type_defn.description = description
|
|
42
|
-
type_defn.ast_node = ast_node
|
|
43
|
-
type_defn.type_memberships = type_memberships
|
|
44
|
-
if respond_to?(:resolve_type)
|
|
45
|
-
type_defn.resolve_type = method(:resolve_type)
|
|
46
|
-
end
|
|
47
|
-
type_defn.metadata[:type_class] = self
|
|
48
|
-
type_defn
|
|
49
|
-
end
|
|
50
|
-
|
|
51
35
|
def type_membership_class(membership_class = nil)
|
|
52
36
|
if membership_class
|
|
53
37
|
@type_membership_class = membership_class
|
|
@@ -10,7 +10,7 @@ module GraphQL
|
|
|
10
10
|
# should go through a warden. If you access the schema directly,
|
|
11
11
|
# you may show a client something that it shouldn't be allowed to see.
|
|
12
12
|
#
|
|
13
|
-
# @example
|
|
13
|
+
# @example Hiding private fields
|
|
14
14
|
# private_members = -> (member, ctx) { member.metadata[:private] }
|
|
15
15
|
# result = Schema.execute(query_string, except: private_members)
|
|
16
16
|
#
|
|
@@ -85,7 +85,7 @@ module GraphQL
|
|
|
85
85
|
# @param context [GraphQL::Query::Context]
|
|
86
86
|
# @param schema [GraphQL::Schema]
|
|
87
87
|
def initialize(filter, context:, schema:)
|
|
88
|
-
@schema = schema
|
|
88
|
+
@schema = schema
|
|
89
89
|
# Cache these to avoid repeated hits to the inheritance chain when one isn't present
|
|
90
90
|
@query = @schema.query
|
|
91
91
|
@mutation = @schema.mutation
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
module GraphQL
|
|
4
4
|
class Schema
|
|
5
5
|
class Wrapper
|
|
6
|
-
include GraphQL::Schema::Member::CachedGraphQLDefinition
|
|
7
6
|
include GraphQL::Schema::Member::TypeSystemHelpers
|
|
8
7
|
|
|
9
8
|
# @return [Class, Module] The inner type of this wrapping type, the type of which one or more objects may be present.
|
|
@@ -13,10 +12,6 @@ module GraphQL
|
|
|
13
12
|
@of_type = of_type
|
|
14
13
|
end
|
|
15
14
|
|
|
16
|
-
def to_graphql
|
|
17
|
-
raise GraphQL::RequiredImplementationMissingError
|
|
18
|
-
end
|
|
19
|
-
|
|
20
15
|
def unwrap
|
|
21
16
|
@of_type.unwrap
|
|
22
17
|
end
|