graphql 2.0.27 → 2.1.3
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.
Potentially problematic release.
This version of graphql might be problematic. Click here for more details.
- checksums.yaml +4 -4
- 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/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_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 +2 -0
- data/lib/graphql/analysis/ast/analyzer.rb +7 -0
- data/lib/graphql/analysis/ast/query_depth.rb +7 -2
- data/lib/graphql/analysis/ast/visitor.rb +2 -2
- data/lib/graphql/analysis/ast.rb +15 -11
- data/lib/graphql/dataloader/source.rb +7 -0
- data/lib/graphql/dataloader.rb +38 -10
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +170 -0
- data/lib/graphql/execution/interpreter/runtime.rb +95 -254
- data/lib/graphql/execution/interpreter.rb +0 -6
- data/lib/graphql/execution/lookahead.rb +1 -1
- data/lib/graphql/introspection/dynamic_fields.rb +1 -1
- data/lib/graphql/introspection/entry_points.rb +2 -2
- data/lib/graphql/language/block_string.rb +28 -16
- data/lib/graphql/language/definition_slice.rb +1 -1
- data/lib/graphql/language/document_from_schema_definition.rb +36 -35
- data/lib/graphql/language/nodes.rb +2 -2
- data/lib/graphql/language/printer.rb +294 -145
- 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 +1 -0
- data/lib/graphql/pagination/connection.rb +23 -1
- data/lib/graphql/query/context/scoped_context.rb +101 -0
- data/lib/graphql/query/context.rb +32 -98
- data/lib/graphql/query.rb +2 -19
- data/lib/graphql/rake_task.rb +3 -12
- data/lib/graphql/schema/directive/specified_by.rb +14 -0
- data/lib/graphql/schema/field/connection_extension.rb +1 -15
- data/lib/graphql/schema/field/scope_extension.rb +7 -1
- data/lib/graphql/schema/field.rb +7 -4
- data/lib/graphql/schema/has_single_input_argument.rb +156 -0
- data/lib/graphql/schema/introspection_system.rb +2 -0
- data/lib/graphql/schema/member/base_dsl_methods.rb +2 -1
- data/lib/graphql/schema/member/has_arguments.rb +19 -4
- data/lib/graphql/schema/member/has_fields.rb +4 -1
- data/lib/graphql/schema/member/has_interfaces.rb +21 -7
- data/lib/graphql/schema/member/scoped.rb +19 -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 +4 -0
- data/lib/graphql/schema/scalar.rb +3 -3
- data/lib/graphql/schema/subscription.rb +11 -4
- data/lib/graphql/schema/warden.rb +87 -89
- data/lib/graphql/schema.rb +125 -55
- 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 +1 -1
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +1 -1
- 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 +1 -1
- data/lib/graphql/static_validation/validation_context.rb +5 -5
- data/lib/graphql/static_validation.rb +0 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +2 -1
- data/lib/graphql/subscriptions.rb +11 -6
- data/lib/graphql/tracing/appoptics_trace.rb +2 -2
- data/lib/graphql/tracing/appoptics_tracing.rb +2 -2
- data/lib/graphql/types/relay/connection_behaviors.rb +19 -2
- data/lib/graphql/types/relay/edge_behaviors.rb +7 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +1 -2
- metadata +23 -20
- data/lib/graphql/filter.rb +0 -59
- data/lib/graphql/static_validation/type_stack.rb +0 -216
@@ -59,40 +59,52 @@ module GraphQL
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def self.print(str, indent: '')
|
62
|
-
|
62
|
+
line_length = 120 - indent.length
|
63
|
+
block_str = "".dup
|
64
|
+
triple_quotes = "\"\"\"\n"
|
65
|
+
block_str << indent
|
66
|
+
block_str << triple_quotes
|
63
67
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
if str.include?("\n")
|
69
|
+
str.split("\n") do |line|
|
70
|
+
if line == ''
|
71
|
+
block_str << "\n"
|
72
|
+
else
|
73
|
+
break_line(line, line_length) do |subline|
|
74
|
+
block_str << indent
|
75
|
+
block_str << subline
|
76
|
+
block_str << "\n"
|
77
|
+
end
|
73
78
|
end
|
74
79
|
end
|
80
|
+
else
|
81
|
+
break_line(str, line_length) do |subline|
|
82
|
+
block_str << indent
|
83
|
+
block_str << subline
|
84
|
+
block_str << "\n"
|
85
|
+
end
|
75
86
|
end
|
76
87
|
|
77
|
-
block_str <<
|
88
|
+
block_str << indent
|
89
|
+
block_str << triple_quotes
|
78
90
|
end
|
79
91
|
|
80
92
|
private
|
81
93
|
|
82
94
|
def self.break_line(line, length)
|
83
|
-
return
|
95
|
+
return yield(line) if line.length < length + 5
|
84
96
|
|
85
97
|
parts = line.split(Regexp.new("((?: |^).{15,#{length - 40}}(?= |$))"))
|
86
|
-
return
|
98
|
+
return yield(line) if parts.length < 4
|
87
99
|
|
88
|
-
|
100
|
+
yield(parts.slice!(0, 3).join)
|
89
101
|
|
90
102
|
parts.each_with_index do |part, i|
|
91
103
|
next if i % 2 == 1
|
92
|
-
|
104
|
+
yield "#{part[1..-1]}#{parts[i + 1]}"
|
93
105
|
end
|
94
106
|
|
95
|
-
|
107
|
+
nil
|
96
108
|
end
|
97
109
|
end
|
98
110
|
end
|
@@ -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
|
@@ -26,21 +26,11 @@ module GraphQL
|
|
26
26
|
|
27
27
|
schema_context = schema.context_class.new(query: nil, object: 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,16 @@ 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
|
+
definitions = build_directive_nodes(dirs_to_build)
|
267
268
|
|
268
269
|
type_nodes = build_type_definition_nodes(warden.reachable_types)
|
269
270
|
|
270
271
|
if @include_one_of
|
271
272
|
# This may have been set to true when iterating over all types
|
272
|
-
|
273
|
+
definitions.concat(build_directive_nodes([GraphQL::Schema::Directive::OneOf]))
|
273
274
|
end
|
274
275
|
|
275
|
-
definitions
|
276
|
+
definitions.concat(type_nodes)
|
276
277
|
if include_schema_node?
|
277
278
|
definitions.unshift(build_schema_node)
|
278
279
|
end
|
@@ -295,9 +296,9 @@ module GraphQL
|
|
295
296
|
end
|
296
297
|
|
297
298
|
def build_field_nodes(fields)
|
298
|
-
fields
|
299
|
-
|
300
|
-
|
299
|
+
f_nodes = fields.map { |field| build_field_node(field) }
|
300
|
+
f_nodes.sort_by!(&:name)
|
301
|
+
f_nodes
|
301
302
|
end
|
302
303
|
|
303
304
|
private
|
@@ -320,7 +321,7 @@ module GraphQL
|
|
320
321
|
|
321
322
|
def definition_directives(member, directives_method)
|
322
323
|
dirs = if !member.respond_to?(directives_method) || member.directives.empty?
|
323
|
-
|
324
|
+
EmptyObjects::EMPTY_ARRAY
|
324
325
|
else
|
325
326
|
member.public_send(directives_method).map do |dir|
|
326
327
|
args = []
|
@@ -323,7 +323,7 @@ module GraphQL
|
|
323
323
|
# @return [String, Float, Integer, Boolean, Array, InputObject, VariableIdentifier] The value passed for this key
|
324
324
|
|
325
325
|
def children
|
326
|
-
@children ||= Array(value).flatten.select { |v| v.is_a?(AbstractNode) }
|
326
|
+
@children ||= Array(value).flatten.tap { _1.select! { |v| v.is_a?(AbstractNode) } }
|
327
327
|
end
|
328
328
|
end
|
329
329
|
|
@@ -535,7 +535,7 @@ module GraphQL
|
|
535
535
|
# @example Creating a custom string from a document
|
536
536
|
# class VariableScrubber < GraphQL::Language::Printer
|
537
537
|
# def print_argument(arg)
|
538
|
-
# "#{arg.name}: <HIDDEN>"
|
538
|
+
# print_string("#{arg.name}: <HIDDEN>")
|
539
539
|
# end
|
540
540
|
# end
|
541
541
|
#
|