graphql 1.12.0 → 1.12.5
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_generator.rb +4 -1
- data/lib/generators/graphql/loader_generator.rb +1 -0
- data/lib/generators/graphql/mutation_generator.rb +1 -0
- data/lib/generators/graphql/relay.rb +55 -0
- data/lib/generators/graphql/relay_generator.rb +4 -46
- data/lib/generators/graphql/type_generator.rb +1 -0
- data/lib/graphql.rb +2 -2
- data/lib/graphql/analysis/analyze_query.rb +1 -1
- data/lib/graphql/analysis/ast.rb +1 -1
- data/lib/graphql/backtrace/inspect_result.rb +0 -1
- data/lib/graphql/backtrace/table.rb +0 -1
- data/lib/graphql/backtrace/traced_error.rb +0 -1
- data/lib/graphql/backtrace/tracer.rb +4 -8
- data/lib/graphql/backwards_compatibility.rb +1 -1
- data/lib/graphql/base_type.rb +1 -1
- data/lib/graphql/compatibility/execution_specification.rb +1 -1
- data/lib/graphql/compatibility/lazy_execution_specification.rb +1 -1
- data/lib/graphql/compatibility/query_parser_specification.rb +1 -1
- data/lib/graphql/compatibility/schema_parser_specification.rb +1 -1
- data/lib/graphql/dataloader.rb +102 -91
- data/lib/graphql/dataloader/null_dataloader.rb +5 -5
- data/lib/graphql/dataloader/request.rb +1 -6
- data/lib/graphql/dataloader/request_all.rb +1 -4
- data/lib/graphql/dataloader/source.rb +20 -6
- data/lib/graphql/define/instance_definable.rb +1 -1
- data/lib/graphql/deprecated_dsl.rb +4 -4
- data/lib/graphql/deprecation.rb +13 -0
- data/lib/graphql/execution/errors.rb +1 -1
- data/lib/graphql/execution/execute.rb +1 -1
- data/lib/graphql/execution/interpreter.rb +3 -3
- data/lib/graphql/execution/interpreter/arguments_cache.rb +37 -14
- data/lib/graphql/execution/interpreter/resolve.rb +33 -25
- data/lib/graphql/execution/interpreter/runtime.rb +38 -74
- data/lib/graphql/execution/multiplex.rb +22 -23
- data/lib/graphql/function.rb +1 -1
- data/lib/graphql/internal_representation/document.rb +2 -2
- data/lib/graphql/internal_representation/rewrite.rb +1 -1
- data/lib/graphql/object_type.rb +0 -2
- data/lib/graphql/pagination/connection.rb +9 -0
- data/lib/graphql/pagination/connections.rb +1 -1
- data/lib/graphql/parse_error.rb +0 -1
- data/lib/graphql/query.rb +8 -2
- data/lib/graphql/query/arguments.rb +1 -1
- data/lib/graphql/query/arguments_cache.rb +0 -1
- data/lib/graphql/query/context.rb +1 -3
- data/lib/graphql/query/executor.rb +0 -1
- data/lib/graphql/query/null_context.rb +3 -2
- data/lib/graphql/query/serial_execution.rb +1 -1
- data/lib/graphql/query/variable_validation_error.rb +1 -1
- data/lib/graphql/relay/base_connection.rb +2 -2
- data/lib/graphql/relay/mutation.rb +1 -1
- data/lib/graphql/relay/node.rb +3 -3
- data/lib/graphql/relay/range_add.rb +10 -5
- data/lib/graphql/relay/type_extensions.rb +2 -2
- data/lib/graphql/schema.rb +14 -13
- data/lib/graphql/schema/argument.rb +61 -0
- data/lib/graphql/schema/field.rb +12 -7
- data/lib/graphql/schema/find_inherited_value.rb +3 -1
- data/lib/graphql/schema/input_object.rb +6 -2
- data/lib/graphql/schema/member/has_arguments.rb +43 -56
- data/lib/graphql/schema/member/has_fields.rb +1 -4
- data/lib/graphql/schema/member/instrumentation.rb +0 -1
- data/lib/graphql/schema/middleware_chain.rb +1 -1
- data/lib/graphql/schema/resolver.rb +28 -1
- data/lib/graphql/schema/timeout_middleware.rb +1 -1
- data/lib/graphql/schema/validation.rb +2 -2
- data/lib/graphql/static_validation/validator.rb +4 -2
- data/lib/graphql/subscriptions/event.rb +0 -1
- data/lib/graphql/subscriptions/instrumentation.rb +0 -1
- data/lib/graphql/subscriptions/serialize.rb +0 -1
- data/lib/graphql/subscriptions/subscription_root.rb +1 -1
- data/lib/graphql/tracing/skylight_tracing.rb +1 -1
- data/lib/graphql/upgrader/member.rb +1 -1
- data/lib/graphql/upgrader/schema.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- data/readme.md +1 -1
- metadata +22 -90
@@ -35,7 +35,7 @@ module GraphQL
|
|
35
35
|
@queries = queries
|
36
36
|
@queries.each { |q| q.multiplex = self }
|
37
37
|
@context = context
|
38
|
-
@context[:dataloader] = @dataloader = @schema.dataloader_class.new
|
38
|
+
@context[:dataloader] = @dataloader = @schema.dataloader_class.new
|
39
39
|
@tracers = schema.tracers + (context[:tracers] || [])
|
40
40
|
# Support `context: {backtrace: true}`
|
41
41
|
if context[:backtrace] && !@tracers.include?(GraphQL::Backtrace::Tracer)
|
@@ -74,6 +74,24 @@ module GraphQL
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
# @param query [GraphQL::Query]
|
78
|
+
def begin_query(results, idx, query, multiplex)
|
79
|
+
operation = query.selected_operation
|
80
|
+
result = if operation.nil? || !query.valid? || query.context.errors.any?
|
81
|
+
NO_OPERATION
|
82
|
+
else
|
83
|
+
begin
|
84
|
+
# These were checked to be the same in `#supports_multiplexing?`
|
85
|
+
query.schema.query_execution_strategy.begin_query(query, multiplex)
|
86
|
+
rescue GraphQL::ExecutionError => err
|
87
|
+
query.context.errors << err
|
88
|
+
NO_OPERATION
|
89
|
+
end
|
90
|
+
end
|
91
|
+
results[idx] = result
|
92
|
+
nil
|
93
|
+
end
|
94
|
+
|
77
95
|
private
|
78
96
|
|
79
97
|
def run_as_multiplex(multiplex)
|
@@ -83,15 +101,13 @@ module GraphQL
|
|
83
101
|
# Do as much eager evaluation of the query as possible
|
84
102
|
results = []
|
85
103
|
queries.each_with_index do |query, idx|
|
86
|
-
multiplex.dataloader.
|
87
|
-
results[idx] = begin_query(query, multiplex)
|
88
|
-
}
|
104
|
+
multiplex.dataloader.append_job { begin_query(results, idx, query, multiplex) }
|
89
105
|
end
|
90
106
|
|
91
107
|
multiplex.dataloader.run
|
92
108
|
|
93
109
|
# Then, work through lazy results in a breadth-first way
|
94
|
-
multiplex.dataloader.
|
110
|
+
multiplex.dataloader.append_job {
|
95
111
|
multiplex.schema.query_execution_strategy.finish_multiplex(results, multiplex)
|
96
112
|
}
|
97
113
|
multiplex.dataloader.run
|
@@ -112,23 +128,6 @@ module GraphQL
|
|
112
128
|
raise
|
113
129
|
end
|
114
130
|
|
115
|
-
# @param query [GraphQL::Query]
|
116
|
-
# @return [Hash] The initial result (may not be finished if there are lazy values)
|
117
|
-
def begin_query(query, multiplex)
|
118
|
-
operation = query.selected_operation
|
119
|
-
if operation.nil? || !query.valid? || query.context.errors.any?
|
120
|
-
NO_OPERATION
|
121
|
-
else
|
122
|
-
begin
|
123
|
-
# These were checked to be the same in `#supports_multiplexing?`
|
124
|
-
query.schema.query_execution_strategy.begin_query(query, multiplex)
|
125
|
-
rescue GraphQL::ExecutionError => err
|
126
|
-
query.context.errors << err
|
127
|
-
NO_OPERATION
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
131
|
# @param data_result [Hash] The result for the "data" key, if any
|
133
132
|
# @param query [GraphQL::Query] The query which was run
|
134
133
|
# @return [Hash] final result of this query, including all values and errors
|
@@ -156,7 +155,7 @@ module GraphQL
|
|
156
155
|
|
157
156
|
# use the old `query_execution_strategy` etc to run this query
|
158
157
|
def run_one_legacy(schema, query)
|
159
|
-
warn "Multiplex.run_one_legacy will be removed from GraphQL-Ruby 2.0, upgrade to the Interpreter to avoid this deprecated codepath: https://graphql-ruby.org/queries/interpreter.html"
|
158
|
+
GraphQL::Deprecation.warn "Multiplex.run_one_legacy will be removed from GraphQL-Ruby 2.0, upgrade to the Interpreter to avoid this deprecated codepath: https://graphql-ruby.org/queries/interpreter.html"
|
160
159
|
|
161
160
|
query.result_values = if !query.valid?
|
162
161
|
all_errors = query.validation_errors + query.analysis_errors + query.context.errors
|
data/lib/graphql/function.rb
CHANGED
@@ -3,7 +3,7 @@ module GraphQL
|
|
3
3
|
# @api deprecated
|
4
4
|
class Function
|
5
5
|
def self.inherited(subclass)
|
6
|
-
warn "GraphQL::Function (used for #{subclass}) will be removed from GraphQL-Ruby 2.0, please upgrade to resolvers: https://graphql-ruby.org/fields/resolvers.html"
|
6
|
+
GraphQL::Deprecation.warn "GraphQL::Function (used for #{subclass}) will be removed from GraphQL-Ruby 2.0, please upgrade to resolvers: https://graphql-ruby.org/fields/resolvers.html"
|
7
7
|
end
|
8
8
|
|
9
9
|
# @return [Hash<String => GraphQL::Argument>] Arguments, keyed by name
|
@@ -14,12 +14,12 @@ module GraphQL
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def [](key)
|
17
|
-
warn "#{self.class}#[] is deprecated; use `operation_definitions[]` instead"
|
17
|
+
GraphQL::Deprecation.warn "#{self.class}#[] is deprecated; use `operation_definitions[]` instead"
|
18
18
|
operation_definitions[key]
|
19
19
|
end
|
20
20
|
|
21
21
|
def each(&block)
|
22
|
-
warn "#{self.class}#each is deprecated; use `operation_definitions.each` instead"
|
22
|
+
GraphQL::Deprecation.warn "#{self.class}#each is deprecated; use `operation_definitions.each` instead"
|
23
23
|
operation_definitions.each(&block)
|
24
24
|
end
|
25
25
|
end
|
@@ -60,7 +60,7 @@ module GraphQL
|
|
60
60
|
|
61
61
|
# @return [Hash<String, Node>] Roots of this query
|
62
62
|
def operations
|
63
|
-
warn "#{self.class}#operations is deprecated; use `document.operation_definitions` instead"
|
63
|
+
GraphQL::Deprecation.warn "#{self.class}#operations is deprecated; use `document.operation_definitions` instead"
|
64
64
|
@document.operation_definitions
|
65
65
|
end
|
66
66
|
|
data/lib/graphql/object_type.rb
CHANGED
@@ -121,8 +121,6 @@ module GraphQL
|
|
121
121
|
iface = GraphQL::BaseType.resolve_related_type(type_membership.abstract_type)
|
122
122
|
if iface.is_a?(GraphQL::InterfaceType)
|
123
123
|
@clean_inherited_fields.merge!(iface.fields)
|
124
|
-
else
|
125
|
-
pp iface
|
126
124
|
end
|
127
125
|
end
|
128
126
|
@clean_inherited_fields
|
@@ -105,6 +105,15 @@ module GraphQL
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
+
# This is called by `Relay::RangeAdd` -- it can be overridden
|
109
|
+
# when `item` needs some modifications based on this connection's state.
|
110
|
+
#
|
111
|
+
# @param item [Object] An item newly added to `items`
|
112
|
+
# @return [Edge]
|
113
|
+
def range_add_edge(item)
|
114
|
+
edge_class.new(item, self)
|
115
|
+
end
|
116
|
+
|
108
117
|
attr_writer :last
|
109
118
|
# @return [Integer, nil] A clamped `last` value. (The underlying instance variable doesn't have limits on it)
|
110
119
|
def last
|
@@ -23,7 +23,7 @@ module GraphQL
|
|
23
23
|
|
24
24
|
def self.use(schema_defn)
|
25
25
|
if schema_defn.plugins.any? { |(plugin, args)| plugin == self }
|
26
|
-
warn("#{self} is now the default, remove `use #{self}` from #{caller(2,1).first}")
|
26
|
+
GraphQL::Deprecation.warn("#{self} is now the default, remove `use #{self}` from #{caller(2,1).first}")
|
27
27
|
end
|
28
28
|
schema_defn.connections = self.new(schema: schema_defn)
|
29
29
|
end
|
data/lib/graphql/parse_error.rb
CHANGED
data/lib/graphql/query.rb
CHANGED
@@ -251,12 +251,18 @@ module GraphQL
|
|
251
251
|
# @param parent_object [GraphQL::Schema::Object]
|
252
252
|
# @return Hash{Symbol => Object}
|
253
253
|
def arguments_for(ast_node, definition, parent_object: nil)
|
254
|
+
if interpreter?
|
255
|
+
arguments_cache.fetch(ast_node, definition, parent_object)
|
256
|
+
else
|
257
|
+
arguments_cache[ast_node][definition]
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def arguments_cache
|
254
262
|
if interpreter?
|
255
263
|
@arguments_cache ||= Execution::Interpreter::ArgumentsCache.new(self)
|
256
|
-
@arguments_cache.fetch(ast_node, definition, parent_object)
|
257
264
|
else
|
258
265
|
@arguments_cache ||= ArgumentsCache.build(self)
|
259
|
-
@arguments_cache[ast_node][definition]
|
260
266
|
end
|
261
267
|
end
|
262
268
|
|
@@ -22,7 +22,7 @@ module GraphQL
|
|
22
22
|
method_names.each do |method_name|
|
23
23
|
# Don't define a helper method if it would override something.
|
24
24
|
if method_defined?(method_name)
|
25
|
-
warn(
|
25
|
+
GraphQL::Deprecation.warn(
|
26
26
|
"Unable to define a helper for argument with name '#{method_name}' "\
|
27
27
|
"as this is a reserved name. Add `method_access: false` to stop this warning."
|
28
28
|
)
|
@@ -1,6 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# test_via: ../execution/execute.rb
|
3
|
-
# test_via: ../execution/lazy.rb
|
4
2
|
module GraphQL
|
5
3
|
class Query
|
6
4
|
# Expose some query-specific info to field resolve functions.
|
@@ -159,7 +157,7 @@ module GraphQL
|
|
159
157
|
end
|
160
158
|
|
161
159
|
def dataloader
|
162
|
-
@dataloader ||= query.multiplex.dataloader
|
160
|
+
@dataloader ||= query.multiplex ? query.multiplex.dataloader : schema.dataloader_class.new
|
163
161
|
end
|
164
162
|
|
165
163
|
# @api private
|
@@ -9,10 +9,11 @@ module GraphQL
|
|
9
9
|
def visible_type?(t); true; end
|
10
10
|
end
|
11
11
|
|
12
|
-
attr_reader :schema, :query, :warden
|
12
|
+
attr_reader :schema, :query, :warden, :dataloader
|
13
13
|
|
14
14
|
def initialize
|
15
15
|
@query = nil
|
16
|
+
@dataloader = GraphQL::Dataloader::NullDataloader.new
|
16
17
|
@schema = GraphQL::Schema.new
|
17
18
|
@warden = NullWarden.new(
|
18
19
|
GraphQL::Filter.new,
|
@@ -36,7 +37,7 @@ module GraphQL
|
|
36
37
|
@instance = self.new
|
37
38
|
end
|
38
39
|
|
39
|
-
def_delegators :instance, :query, :schema, :warden, :interpreter
|
40
|
+
def_delegators :instance, :query, :schema, :warden, :interpreter?, :dataloader
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
@@ -16,7 +16,7 @@ module GraphQL
|
|
16
16
|
# @param query_object [GraphQL::Query] the query object for this execution
|
17
17
|
# @return [Hash] a spec-compliant GraphQL result, as a hash
|
18
18
|
def execute(ast_operation, root_type, query_object)
|
19
|
-
warn "#{self.class} will be removed in GraphQL-Ruby 2.0, please upgrade to the Interpreter: https://graphql-ruby.org/queries/interpreter.html"
|
19
|
+
GraphQL::Deprecation.warn "#{self.class} will be removed in GraphQL-Ruby 2.0, please upgrade to the Interpreter: https://graphql-ruby.org/queries/interpreter.html"
|
20
20
|
operation_resolution.resolve(
|
21
21
|
query_object.irep_selection,
|
22
22
|
root_type,
|
@@ -23,7 +23,7 @@ module GraphQL
|
|
23
23
|
# a one level deep merge explicitly. However beyond that only show the
|
24
24
|
# latest value and problems.
|
25
25
|
super.merge({ "extensions" => { "value" => value, "problems" => validation_result.problems }}) do |key, oldValue, newValue|
|
26
|
-
if oldValue.respond_to?
|
26
|
+
if oldValue.respond_to?(:merge)
|
27
27
|
oldValue.merge(newValue)
|
28
28
|
else
|
29
29
|
newValue
|
@@ -59,11 +59,11 @@ module GraphQL
|
|
59
59
|
# @param parent [Object] The object which this collection belongs to
|
60
60
|
# @param context [GraphQL::Query::Context] The context from the field being resolved
|
61
61
|
def initialize(nodes, arguments, field: nil, max_page_size: nil, parent: nil, context: nil)
|
62
|
-
warn "GraphQL::Relay::BaseConnection (used for #{self.class}) will be removed from GraphQL-Ruby 2.0, use GraphQL::Pagination::Connections instead: https://graphql-ruby.org/pagination/overview.html"
|
62
|
+
GraphQL::Deprecation.warn "GraphQL::Relay::BaseConnection (used for #{self.class}) will be removed from GraphQL-Ruby 2.0, use GraphQL::Pagination::Connections instead: https://graphql-ruby.org/pagination/overview.html"
|
63
63
|
|
64
64
|
deprecated_caller = caller(0, 10).find { |c| !c.include?("lib/graphql") }
|
65
65
|
if deprecated_caller
|
66
|
-
warn " -> called from #{deprecated_caller}"
|
66
|
+
GraphQL::Deprecation.warn " -> called from #{deprecated_caller}"
|
67
67
|
end
|
68
68
|
|
69
69
|
@context = context
|
@@ -30,7 +30,7 @@ module GraphQL
|
|
30
30
|
alias :input_fields :arguments
|
31
31
|
|
32
32
|
def initialize
|
33
|
-
warn "GraphQL::Relay::Mutation will be removed from GraphQL-Ruby 2.0, use GraphQL::Schema::RelayClassicMutation instead: https://graphql-ruby.org/mutations/mutation_classes"
|
33
|
+
GraphQL::Deprecation.warn "GraphQL::Relay::Mutation will be removed from GraphQL-Ruby 2.0, use GraphQL::Schema::RelayClassicMutation instead: https://graphql-ruby.org/mutations/mutation_classes"
|
34
34
|
@fields = {}
|
35
35
|
@arguments = {}
|
36
36
|
@has_generated_return_type = false
|
data/lib/graphql/relay/node.rb
CHANGED
@@ -5,7 +5,7 @@ module GraphQL
|
|
5
5
|
module Node
|
6
6
|
# @return [GraphQL::Field] a field for finding objects by their global ID.
|
7
7
|
def self.field(**kwargs, &block)
|
8
|
-
warn "GraphQL::Relay::Node.field will be removed from GraphQL-Ruby 2.0, use GraphQL::Types::Relay::NodeField instead"
|
8
|
+
GraphQL::Deprecation.warn "GraphQL::Relay::Node.field will be removed from GraphQL-Ruby 2.0, use GraphQL::Types::Relay::NodeField instead"
|
9
9
|
# We have to define it fresh each time because
|
10
10
|
# its name will be modified and its description
|
11
11
|
# _may_ be modified.
|
@@ -19,7 +19,7 @@ module GraphQL
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.plural_field(**kwargs, &block)
|
22
|
-
warn "GraphQL::Relay::Nodes.field will be removed from GraphQL-Ruby 2.0, use GraphQL::Types::Relay::NodesField instead"
|
22
|
+
GraphQL::Deprecation.warn "GraphQL::Relay::Nodes.field will be removed from GraphQL-Ruby 2.0, use GraphQL::Types::Relay::NodesField instead"
|
23
23
|
field = GraphQL::Types::Relay::NodesField.graphql_definition
|
24
24
|
|
25
25
|
if kwargs.any? || block
|
@@ -31,7 +31,7 @@ module GraphQL
|
|
31
31
|
|
32
32
|
# @return [GraphQL::InterfaceType] The interface which all Relay types must implement
|
33
33
|
def self.interface
|
34
|
-
warn "GraphQL::Relay::Node.interface will be removed from GraphQL-Ruby 2.0, use GraphQL::Types::Relay::Node instead"
|
34
|
+
GraphQL::Deprecation.warn "GraphQL::Relay::Node.interface will be removed from GraphQL-Ruby 2.0, use GraphQL::Types::Relay::Node instead"
|
35
35
|
@interface ||= GraphQL::Types::Relay::Node.graphql_definition
|
36
36
|
end
|
37
37
|
end
|
@@ -9,7 +9,7 @@ module GraphQL
|
|
9
9
|
# should be ordered and paginated before providing it here.
|
10
10
|
#
|
11
11
|
# @example Adding a comment to list of comments
|
12
|
-
# post = Post.find(args[:
|
12
|
+
# post = Post.find(args[:post_id])
|
13
13
|
# comments = post.comments
|
14
14
|
# new_comment = comments.build(body: args[:body])
|
15
15
|
# new_comment.save!
|
@@ -18,13 +18,13 @@ module GraphQL
|
|
18
18
|
# parent: post,
|
19
19
|
# collection: comments,
|
20
20
|
# item: new_comment,
|
21
|
-
# context:
|
21
|
+
# context: context,
|
22
22
|
# )
|
23
23
|
#
|
24
24
|
# response = {
|
25
25
|
# post: post,
|
26
|
-
#
|
27
|
-
#
|
26
|
+
# comments_connection: range_add.connection,
|
27
|
+
# new_comment_edge: range_add.edge,
|
28
28
|
# }
|
29
29
|
class RangeAdd
|
30
30
|
attr_reader :edge, :connection, :parent
|
@@ -39,7 +39,12 @@ module GraphQL
|
|
39
39
|
conn_class = context.schema.connections.wrapper_for(collection)
|
40
40
|
# The rest will be added by ConnectionExtension
|
41
41
|
@connection = conn_class.new(collection, parent: parent, context: context, edge_class: edge_class)
|
42
|
-
|
42
|
+
# Check if this connection supports it, to support old versions of GraphQL-Pro
|
43
|
+
@edge = if @connection.respond_to?(:range_add_edge)
|
44
|
+
@connection.range_add_edge(item)
|
45
|
+
else
|
46
|
+
@connection.edge_class.new(item, @connection)
|
47
|
+
end
|
43
48
|
else
|
44
49
|
connection_class = BaseConnection.connection_for_nodes(collection)
|
45
50
|
@connection = connection_class.new(collection, {}, parent: parent, context: context)
|
@@ -12,7 +12,7 @@ module GraphQL
|
|
12
12
|
# Define a custom connection type for this object type
|
13
13
|
# @return [GraphQL::ObjectType]
|
14
14
|
def define_connection(**kwargs, &block)
|
15
|
-
warn ".connection_type and .define_connection will be removed from GraphQL-Ruby 2.0, use class-based type definitions instead: https://graphql-ruby.org/schema/class_based_api.html"
|
15
|
+
GraphQL::Deprecation.warn ".connection_type and .define_connection will be removed from GraphQL-Ruby 2.0, use class-based type definitions instead: https://graphql-ruby.org/schema/class_based_api.html"
|
16
16
|
GraphQL::Relay::ConnectionType.create_type(self, **kwargs, &block)
|
17
17
|
end
|
18
18
|
|
@@ -24,7 +24,7 @@ module GraphQL
|
|
24
24
|
# Define a custom edge type for this object type
|
25
25
|
# @return [GraphQL::ObjectType]
|
26
26
|
def define_edge(**kwargs, &block)
|
27
|
-
warn ".edge_type and .define_edge will be removed from GraphQL-Ruby 2.0, use class-based type definitions instead: https://graphql-ruby.org/schema/class_based_api.html"
|
27
|
+
GraphQL::Deprecation.warn ".edge_type and .define_edge will be removed from GraphQL-Ruby 2.0, use class-based type definitions instead: https://graphql-ruby.org/schema/class_based_api.html"
|
28
28
|
GraphQL::Relay::EdgeType.create_type(self, **kwargs, &block)
|
29
29
|
end
|
30
30
|
end
|
data/lib/graphql/schema.rb
CHANGED
@@ -184,7 +184,7 @@ module GraphQL
|
|
184
184
|
},
|
185
185
|
query_analyzer: ->(schema, analyzer) {
|
186
186
|
if analyzer == GraphQL::Authorization::Analyzer
|
187
|
-
warn("The Authorization query analyzer is deprecated. Authorizing at query runtime is generally a better idea.")
|
187
|
+
GraphQL::Deprecation.warn("The Authorization query analyzer is deprecated. Authorizing at query runtime is generally a better idea.")
|
188
188
|
end
|
189
189
|
schema.query_analyzers << analyzer
|
190
190
|
},
|
@@ -1118,14 +1118,15 @@ module GraphQL
|
|
1118
1118
|
type.possible_types(context: context)
|
1119
1119
|
else
|
1120
1120
|
stored_possible_types = own_possible_types[type.graphql_name]
|
1121
|
-
visible_possible_types = stored_possible_types
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1121
|
+
visible_possible_types = if stored_possible_types && type.kind.interface?
|
1122
|
+
stored_possible_types.select do |possible_type|
|
1123
|
+
# Use `.graphql_name` comparison to match legacy vs class-based types.
|
1124
|
+
# When we don't need to support legacy `.define` types, use `.include?(type)` instead.
|
1125
|
+
possible_type.interfaces(context).any? { |interface| interface.graphql_name == type.graphql_name }
|
1126
|
+
end
|
1127
|
+
else
|
1128
|
+
stored_possible_types
|
1129
|
+
end
|
1129
1130
|
visible_possible_types ||
|
1130
1131
|
introspection_system.possible_types[type.graphql_name] ||
|
1131
1132
|
(
|
@@ -1564,7 +1565,7 @@ module GraphQL
|
|
1564
1565
|
|
1565
1566
|
def instrument(instrument_step, instrumenter, options = {})
|
1566
1567
|
if instrument_step == :field
|
1567
|
-
warn "Field instrumentation (#{instrumenter.inspect}) will be removed in GraphQL-Ruby 2.0, please upgrade to field extensions: https://graphql-ruby.org/type_definitions/field_extensions.html"
|
1568
|
+
GraphQL::Deprecation.warn "Field instrumentation (#{instrumenter.inspect}) will be removed in GraphQL-Ruby 2.0, please upgrade to field extensions: https://graphql-ruby.org/type_definitions/field_extensions.html"
|
1568
1569
|
end
|
1569
1570
|
|
1570
1571
|
step = if instrument_step == :field && options[:after_built_ins]
|
@@ -1614,7 +1615,7 @@ module GraphQL
|
|
1614
1615
|
|
1615
1616
|
def query_analyzer(new_analyzer)
|
1616
1617
|
if new_analyzer == GraphQL::Authorization::Analyzer
|
1617
|
-
warn("The Authorization query analyzer is deprecated. Authorizing at query runtime is generally a better idea.")
|
1618
|
+
GraphQL::Deprecation.warn("The Authorization query analyzer is deprecated. Authorizing at query runtime is generally a better idea.")
|
1618
1619
|
end
|
1619
1620
|
own_query_analyzers << new_analyzer
|
1620
1621
|
end
|
@@ -1625,7 +1626,7 @@ module GraphQL
|
|
1625
1626
|
|
1626
1627
|
def middleware(new_middleware = nil)
|
1627
1628
|
if new_middleware
|
1628
|
-
warn "Middleware will be removed in GraphQL-Ruby 2.0, please upgrade to Field Extensions: https://graphql-ruby.org/type_definitions/field_extensions.html"
|
1629
|
+
GraphQL::Deprecation.warn "Middleware will be removed in GraphQL-Ruby 2.0, please upgrade to Field Extensions: https://graphql-ruby.org/type_definitions/field_extensions.html"
|
1629
1630
|
own_middleware << new_middleware
|
1630
1631
|
else
|
1631
1632
|
# TODO make sure this is cached when running a query
|
@@ -1702,7 +1703,7 @@ module GraphQL
|
|
1702
1703
|
if interpreter? && !defined?(@subscription_extension_added) && subscription && self.subscriptions
|
1703
1704
|
@subscription_extension_added = true
|
1704
1705
|
if subscription.singleton_class.ancestors.include?(Subscriptions::SubscriptionRoot)
|
1705
|
-
warn("`extend Subscriptions::SubscriptionRoot` is no longer required; you may remove it from #{self}'s `subscription` root type (#{subscription}).")
|
1706
|
+
GraphQL::Deprecation.warn("`extend Subscriptions::SubscriptionRoot` is no longer required; you may remove it from #{self}'s `subscription` root type (#{subscription}).")
|
1706
1707
|
else
|
1707
1708
|
subscription.fields.each do |name, field|
|
1708
1709
|
field.extension(Subscriptions::DefaultSubscriptionResolveExtension)
|