Skip to content

Commit bf98441

Browse files
committed
Add deprecation warnings to execution strategy methods
1 parent f41bad4 commit bf98441

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

lib/graphql/execution/interpreter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def run_all(schema, query_options, context: {}, max_complexity: schema.max_compl
4747
begin
4848
# Since this is basically the batching context,
4949
# share it for a whole multiplex
50-
multiplex.context[:interpreter_instance] ||= multiplex.schema.query_execution_strategy.new
50+
multiplex.context[:interpreter_instance] ||= multiplex.schema.query_execution_strategy(deprecation_warning: false).new
5151
# Do as much eager evaluation of the query as possible
5252
results = []
5353
queries.each_with_index do |query, idx|

lib/graphql/schema.rb

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ module GraphQL
6363
# Schemas can restrict large incoming queries with `max_depth` and `max_complexity` configurations.
6464
# (These configurations can be overridden by specific calls to {Schema#execute})
6565
#
66-
# Schemas can specify how queries should be executed against them.
67-
# `query_execution_strategy`, `mutation_execution_strategy` and `subscription_execution_strategy`
68-
# each apply to corresponding root types.
69-
#
7066
# @example defining a schema
7167
# class MySchema < GraphQL::Schema
7268
# query QueryType
@@ -651,27 +647,39 @@ def default_page_size(new_default_page_size = nil)
651647
end
652648
end
653649

654-
def query_execution_strategy(new_query_execution_strategy = nil)
650+
def query_execution_strategy(new_query_execution_strategy = nil, deprecation_warning: true)
651+
if deprecation_warning
652+
warn "GraphQL::Schema.query_execution_strategy is deprecated without replacement. Use `GraphQL::Query.new` directly to create and execute a custom query instead."
653+
warn " #{caller(1, 1).first}"
654+
end
655655
if new_query_execution_strategy
656656
@query_execution_strategy = new_query_execution_strategy
657657
else
658-
@query_execution_strategy || find_inherited_value(:query_execution_strategy, self.default_execution_strategy)
658+
@query_execution_strategy || (superclass.respond_to?(:query_execution_strategy) ? superclass.query_execution_strategy(deprecation_warning: false) : self.default_execution_strategy)
659659
end
660660
end
661661

662-
def mutation_execution_strategy(new_mutation_execution_strategy = nil)
662+
def mutation_execution_strategy(new_mutation_execution_strategy = nil, deprecation_warning: true)
663+
if deprecation_warning
664+
warn "GraphQL::Schema.mutation_execution_strategy is deprecated without replacement. Use `GraphQL::Query.new` directly to create and execute a custom query instead."
665+
warn " #{caller(1, 1).first}"
666+
end
663667
if new_mutation_execution_strategy
664668
@mutation_execution_strategy = new_mutation_execution_strategy
665669
else
666-
@mutation_execution_strategy || find_inherited_value(:mutation_execution_strategy, self.default_execution_strategy)
670+
@mutation_execution_strategy || (superclass.respond_to?(:mutation_execution_strategy) ? superclass.mutation_execution_strategy(deprecation_warning: false) : self.default_execution_strategy)
667671
end
668672
end
669673

670-
def subscription_execution_strategy(new_subscription_execution_strategy = nil)
674+
def subscription_execution_strategy(new_subscription_execution_strategy = nil, deprecation_warning: true)
675+
if deprecation_warning
676+
warn "GraphQL::Schema.subscription_execution_strategy is deprecated without replacement. Use `GraphQL::Query.new` directly to create and execute a custom query instead."
677+
warn " #{caller(1, 1).first}"
678+
end
671679
if new_subscription_execution_strategy
672680
@subscription_execution_strategy = new_subscription_execution_strategy
673681
else
674-
@subscription_execution_strategy || find_inherited_value(:subscription_execution_strategy, self.default_execution_strategy)
682+
@subscription_execution_strategy || (superclass.respond_to?(:subscription_execution_strategy) ? superclass.subscription_execution_strategy(deprecation_warning: false) : self.default_execution_strategy)
675683
end
676684
end
677685

0 commit comments

Comments
 (0)