graphql 2.0.30 → 2.3.6
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/install/mutation_root_generator.rb +2 -2
- data/lib/generators/graphql/install/templates/base_mutation.erb +2 -0
- data/lib/generators/graphql/install/templates/mutation_type.erb +2 -0
- data/lib/generators/graphql/install_generator.rb +3 -0
- data/lib/generators/graphql/templates/base_argument.erb +2 -0
- data/lib/generators/graphql/templates/base_connection.erb +2 -0
- data/lib/generators/graphql/templates/base_edge.erb +2 -0
- data/lib/generators/graphql/templates/base_enum.erb +2 -0
- data/lib/generators/graphql/templates/base_field.erb +2 -0
- data/lib/generators/graphql/templates/base_input_object.erb +2 -0
- data/lib/generators/graphql/templates/base_interface.erb +2 -0
- data/lib/generators/graphql/templates/base_object.erb +2 -0
- data/lib/generators/graphql/templates/base_resolver.erb +6 -0
- data/lib/generators/graphql/templates/base_scalar.erb +2 -0
- data/lib/generators/graphql/templates/base_union.erb +2 -0
- data/lib/generators/graphql/templates/graphql_controller.erb +2 -0
- data/lib/generators/graphql/templates/loader.erb +2 -0
- data/lib/generators/graphql/templates/mutation.erb +2 -0
- data/lib/generators/graphql/templates/node_type.erb +2 -0
- data/lib/generators/graphql/templates/query_type.erb +2 -0
- data/lib/generators/graphql/templates/schema.erb +5 -0
- data/lib/graphql/analysis/analyzer.rb +89 -0
- data/lib/graphql/analysis/field_usage.rb +82 -0
- data/lib/graphql/analysis/max_query_complexity.rb +20 -0
- data/lib/graphql/analysis/max_query_depth.rb +20 -0
- data/lib/graphql/analysis/query_complexity.rb +183 -0
- data/lib/graphql/analysis/query_depth.rb +58 -0
- data/lib/graphql/analysis/visitor.rb +282 -0
- data/lib/graphql/analysis.rb +92 -1
- data/lib/graphql/backtrace/inspect_result.rb +0 -12
- data/lib/graphql/backtrace/trace.rb +12 -15
- data/lib/graphql/coercion_error.rb +1 -9
- data/lib/graphql/dataloader/async_dataloader.rb +88 -0
- data/lib/graphql/dataloader/null_dataloader.rb +1 -1
- data/lib/graphql/dataloader/request.rb +5 -0
- data/lib/graphql/dataloader/source.rb +11 -3
- data/lib/graphql/dataloader.rb +112 -142
- data/lib/graphql/duration_encoding_error.rb +16 -0
- data/lib/graphql/execution/interpreter/argument_value.rb +5 -1
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +175 -0
- data/lib/graphql/execution/interpreter/runtime.rb +163 -365
- data/lib/graphql/execution/interpreter.rb +92 -158
- data/lib/graphql/execution/lookahead.rb +88 -21
- data/lib/graphql/introspection/dynamic_fields.rb +1 -1
- data/lib/graphql/introspection/entry_points.rb +11 -5
- data/lib/graphql/introspection/schema_type.rb +3 -1
- data/lib/graphql/language/block_string.rb +34 -18
- data/lib/graphql/language/definition_slice.rb +1 -1
- data/lib/graphql/language/document_from_schema_definition.rb +38 -38
- data/lib/graphql/language/lexer.rb +305 -193
- data/lib/graphql/language/nodes.rb +113 -66
- data/lib/graphql/language/parser.rb +787 -1986
- data/lib/graphql/language/printer.rb +303 -146
- data/lib/graphql/language/sanitized_printer.rb +20 -22
- data/lib/graphql/language/static_visitor.rb +167 -0
- data/lib/graphql/language/visitor.rb +20 -81
- data/lib/graphql/language.rb +61 -0
- data/lib/graphql/load_application_object_failed_error.rb +5 -1
- data/lib/graphql/pagination/array_connection.rb +6 -6
- data/lib/graphql/pagination/connection.rb +28 -1
- data/lib/graphql/pagination/mongoid_relation_connection.rb +1 -2
- data/lib/graphql/query/context/scoped_context.rb +101 -0
- data/lib/graphql/query/context.rb +66 -131
- data/lib/graphql/query/null_context.rb +4 -11
- data/lib/graphql/query/validation_pipeline.rb +4 -4
- data/lib/graphql/query/variables.rb +3 -3
- data/lib/graphql/query.rb +17 -26
- data/lib/graphql/railtie.rb +9 -6
- data/lib/graphql/rake_task.rb +3 -12
- data/lib/graphql/rubocop/graphql/base_cop.rb +1 -1
- data/lib/graphql/schema/addition.rb +21 -11
- data/lib/graphql/schema/argument.rb +43 -8
- data/lib/graphql/schema/base_64_encoder.rb +3 -5
- data/lib/graphql/schema/build_from_definition.rb +9 -12
- data/lib/graphql/schema/directive/one_of.rb +12 -0
- data/lib/graphql/schema/directive/specified_by.rb +14 -0
- data/lib/graphql/schema/directive.rb +3 -1
- data/lib/graphql/schema/enum.rb +3 -3
- data/lib/graphql/schema/field/connection_extension.rb +1 -15
- data/lib/graphql/schema/field/scope_extension.rb +8 -1
- data/lib/graphql/schema/field.rb +49 -35
- data/lib/graphql/schema/has_single_input_argument.rb +157 -0
- data/lib/graphql/schema/input_object.rb +4 -4
- data/lib/graphql/schema/interface.rb +10 -10
- data/lib/graphql/schema/introspection_system.rb +4 -2
- data/lib/graphql/schema/late_bound_type.rb +4 -0
- data/lib/graphql/schema/list.rb +2 -2
- data/lib/graphql/schema/loader.rb +2 -3
- data/lib/graphql/schema/member/base_dsl_methods.rb +2 -1
- data/lib/graphql/schema/member/has_arguments.rb +63 -73
- data/lib/graphql/schema/member/has_directives.rb +1 -1
- data/lib/graphql/schema/member/has_fields.rb +8 -5
- data/lib/graphql/schema/member/has_interfaces.rb +23 -9
- data/lib/graphql/schema/member/relay_shortcuts.rb +1 -1
- data/lib/graphql/schema/member/scoped.rb +19 -0
- data/lib/graphql/schema/member/type_system_helpers.rb +1 -2
- data/lib/graphql/schema/member/validates_input.rb +3 -3
- data/lib/graphql/schema/mutation.rb +7 -0
- data/lib/graphql/schema/object.rb +8 -0
- data/lib/graphql/schema/printer.rb +8 -7
- data/lib/graphql/schema/relay_classic_mutation.rb +6 -128
- data/lib/graphql/schema/resolver.rb +27 -13
- data/lib/graphql/schema/scalar.rb +3 -3
- data/lib/graphql/schema/subscription.rb +11 -4
- data/lib/graphql/schema/union.rb +1 -1
- data/lib/graphql/schema/unique_within_type.rb +1 -1
- data/lib/graphql/schema/warden.rb +96 -95
- data/lib/graphql/schema.rb +323 -102
- data/lib/graphql/static_validation/all_rules.rb +1 -1
- data/lib/graphql/static_validation/base_visitor.rb +1 -1
- data/lib/graphql/static_validation/literal_validator.rb +2 -3
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +2 -2
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +1 -1
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +2 -2
- data/lib/graphql/static_validation/validation_context.rb +5 -5
- data/lib/graphql/static_validation/validator.rb +3 -0
- data/lib/graphql/static_validation.rb +0 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +4 -3
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +1 -1
- data/lib/graphql/subscriptions/event.rb +8 -2
- data/lib/graphql/subscriptions/serialize.rb +2 -0
- data/lib/graphql/subscriptions.rb +15 -13
- data/lib/graphql/testing/helpers.rb +151 -0
- data/lib/graphql/testing.rb +2 -0
- data/lib/graphql/tracing/appoptics_trace.rb +2 -2
- data/lib/graphql/tracing/appoptics_tracing.rb +2 -2
- data/lib/graphql/tracing/legacy_hooks_trace.rb +74 -0
- data/lib/graphql/tracing/platform_tracing.rb +3 -1
- data/lib/graphql/tracing/{prometheus_tracing → prometheus_trace}/graphql_collector.rb +3 -1
- data/lib/graphql/tracing/prometheus_trace.rb +9 -9
- data/lib/graphql/tracing/sentry_trace.rb +112 -0
- data/lib/graphql/tracing/trace.rb +1 -0
- data/lib/graphql/tracing.rb +3 -1
- data/lib/graphql/type_kinds.rb +1 -1
- data/lib/graphql/types/iso_8601_duration.rb +77 -0
- data/lib/graphql/types/relay/connection_behaviors.rb +32 -2
- data/lib/graphql/types/relay/edge_behaviors.rb +7 -0
- data/lib/graphql/types.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +13 -13
- data/readme.md +12 -2
- metadata +33 -26
- data/lib/graphql/analysis/ast/analyzer.rb +0 -84
- data/lib/graphql/analysis/ast/field_usage.rb +0 -57
- data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -22
- data/lib/graphql/analysis/ast/max_query_depth.rb +0 -22
- data/lib/graphql/analysis/ast/query_complexity.rb +0 -230
- data/lib/graphql/analysis/ast/query_depth.rb +0 -55
- data/lib/graphql/analysis/ast/visitor.rb +0 -276
- data/lib/graphql/analysis/ast.rb +0 -81
- data/lib/graphql/deprecation.rb +0 -9
- data/lib/graphql/filter.rb +0 -59
- data/lib/graphql/language/parser.y +0 -560
- data/lib/graphql/schema/base_64_bp.rb +0 -26
- data/lib/graphql/static_validation/type_stack.rb +0 -216
- data/lib/graphql/subscriptions/instrumentation.rb +0 -28
@@ -14,7 +14,7 @@ module GraphQL
|
|
14
14
|
# @param include_built_in_directives [Boolean] Whether or not to include built in directives in the AST
|
15
15
|
class DocumentFromSchemaDefinition
|
16
16
|
def initialize(
|
17
|
-
schema, context: nil,
|
17
|
+
schema, context: nil, include_introspection_types: false,
|
18
18
|
include_built_in_directives: false, include_built_in_scalars: false, always_include_schema: false
|
19
19
|
)
|
20
20
|
@schema = schema
|
@@ -24,23 +24,13 @@ module GraphQL
|
|
24
24
|
@include_built_in_directives = include_built_in_directives
|
25
25
|
@include_one_of = false
|
26
26
|
|
27
|
-
schema_context = schema.context_class.new(query: nil,
|
27
|
+
schema_context = schema.context_class.new(query: nil, schema: schema, values: context)
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
filter,
|
35
|
-
schema: @schema,
|
36
|
-
context: schema_context,
|
37
|
-
)
|
38
|
-
else
|
39
|
-
@schema.warden_class.new(
|
40
|
-
schema: @schema,
|
41
|
-
context: schema_context,
|
42
|
-
)
|
43
|
-
end
|
29
|
+
|
30
|
+
@warden = @schema.warden_class.new(
|
31
|
+
schema: @schema,
|
32
|
+
context: schema_context,
|
33
|
+
)
|
44
34
|
|
45
35
|
schema_context.warden = @warden
|
46
36
|
end
|
@@ -52,24 +42,30 @@ module GraphQL
|
|
52
42
|
end
|
53
43
|
|
54
44
|
def build_schema_node
|
55
|
-
schema_options = {
|
56
|
-
# `@schema.directives` is covered by `build_definition_nodes`
|
57
|
-
directives: definition_directives(@schema, :schema_directives),
|
58
|
-
}
|
59
45
|
if !schema_respects_root_name_conventions?(@schema)
|
60
|
-
|
46
|
+
GraphQL::Language::Nodes::SchemaDefinition.new(
|
61
47
|
query: (q = warden.root_type_for_operation("query")) && q.graphql_name,
|
62
48
|
mutation: (m = warden.root_type_for_operation("mutation")) && m.graphql_name,
|
63
49
|
subscription: (s = warden.root_type_for_operation("subscription")) && s.graphql_name,
|
64
|
-
|
50
|
+
directives: definition_directives(@schema, :schema_directives)
|
51
|
+
)
|
52
|
+
else
|
53
|
+
# A plain `schema ...` _must_ include root type definitions.
|
54
|
+
# If the only difference is directives, then you have to use `extend schema`
|
55
|
+
GraphQL::Language::Nodes::SchemaExtension.new(directives: definition_directives(@schema, :schema_directives))
|
65
56
|
end
|
66
|
-
GraphQL::Language::Nodes::SchemaDefinition.new(schema_options)
|
67
57
|
end
|
68
58
|
|
69
59
|
def build_object_type_node(object_type)
|
60
|
+
ints = warden.interfaces(object_type)
|
61
|
+
if ints.any?
|
62
|
+
ints.sort_by!(&:graphql_name)
|
63
|
+
ints.map! { |iface| build_type_name_node(iface) }
|
64
|
+
end
|
65
|
+
|
70
66
|
GraphQL::Language::Nodes::ObjectTypeDefinition.new(
|
71
67
|
name: object_type.graphql_name,
|
72
|
-
interfaces:
|
68
|
+
interfaces: ints,
|
73
69
|
fields: build_field_nodes(warden.fields(object_type)),
|
74
70
|
description: object_type.description,
|
75
71
|
directives: directives(object_type),
|
@@ -190,7 +186,8 @@ module GraphQL
|
|
190
186
|
of_type: build_type_name_node(type.of_type)
|
191
187
|
)
|
192
188
|
else
|
193
|
-
|
189
|
+
@cached_type_name_nodes ||= {}
|
190
|
+
@cached_type_name_nodes[type.graphql_name] ||= GraphQL::Language::Nodes::TypeName.new(name: type.graphql_name)
|
194
191
|
end
|
195
192
|
end
|
196
193
|
|
@@ -247,9 +244,13 @@ module GraphQL
|
|
247
244
|
end
|
248
245
|
|
249
246
|
def build_argument_nodes(arguments)
|
250
|
-
arguments
|
251
|
-
.map { |arg| build_argument_node(arg) }
|
252
|
-
.sort_by(&:name)
|
247
|
+
if arguments.any?
|
248
|
+
nodes = arguments.map { |arg| build_argument_node(arg) }
|
249
|
+
nodes.sort_by!(&:name)
|
250
|
+
nodes
|
251
|
+
else
|
252
|
+
arguments
|
253
|
+
end
|
253
254
|
end
|
254
255
|
|
255
256
|
def build_directive_nodes(directives)
|
@@ -263,16 +264,15 @@ module GraphQL
|
|
263
264
|
if !include_built_in_directives
|
264
265
|
dirs_to_build = dirs_to_build.reject { |directive| directive.default_directive? }
|
265
266
|
end
|
266
|
-
|
267
|
-
|
268
|
-
type_nodes = build_type_definition_nodes(warden.reachable_types)
|
267
|
+
definitions = build_directive_nodes(dirs_to_build)
|
269
268
|
|
269
|
+
type_nodes = build_type_definition_nodes(warden.reachable_types + schema.extra_types)
|
270
270
|
if @include_one_of
|
271
271
|
# This may have been set to true when iterating over all types
|
272
|
-
|
272
|
+
definitions.concat(build_directive_nodes([GraphQL::Schema::Directive::OneOf]))
|
273
273
|
end
|
274
274
|
|
275
|
-
definitions
|
275
|
+
definitions.concat(type_nodes)
|
276
276
|
if include_schema_node?
|
277
277
|
definitions.unshift(build_schema_node)
|
278
278
|
end
|
@@ -295,9 +295,9 @@ module GraphQL
|
|
295
295
|
end
|
296
296
|
|
297
297
|
def build_field_nodes(fields)
|
298
|
-
fields
|
299
|
-
|
300
|
-
|
298
|
+
f_nodes = fields.map { |field| build_field_node(field) }
|
299
|
+
f_nodes.sort_by!(&:name)
|
300
|
+
f_nodes
|
301
301
|
end
|
302
302
|
|
303
303
|
private
|
@@ -320,7 +320,7 @@ module GraphQL
|
|
320
320
|
|
321
321
|
def definition_directives(member, directives_method)
|
322
322
|
dirs = if !member.respond_to?(directives_method) || member.directives.empty?
|
323
|
-
|
323
|
+
EmptyObjects::EMPTY_ARRAY
|
324
324
|
else
|
325
325
|
member.public_send(directives_method).map do |dir|
|
326
326
|
args = []
|