Skip to content

Commit 97ad083

Browse files
committed
refactor(test) parameterize the default execution strategy for testing
1 parent 42138c1 commit 97ad083

File tree

14 files changed

+25
-8
lines changed

14 files changed

+25
-8
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: ruby
33
sudo: false
44
cache: bundler
55
env: CODECLIMATE_REPO_TOKEN=f5b27b2e25d3f4e199bb2566fb4fd4507144a004c71d4aa33a32c2df5f940333
6+
script: bundle exec test_both_strategies
67

78
rvm:
89
- 2.1.0 # Lowest version officially supported by that gem

Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ Rake::TestTask.new do |t|
99
t.warning = false
1010
end
1111

12+
desc "Run the test suite on both built-in execution strategies"
13+
task :test_both_strategies do
14+
system "bundle exec rake test"
15+
system "GRAPHQL_EXEC_STRATEGY=serial bundle exec rake test"
16+
end
17+
1218
require 'rubocop/rake_task'
1319
RuboCop::RakeTask.new(:rubocop) do |t|
1420
t.patterns = Rake::FileList['lib/**/{*}.rb', 'spec/**/*.rb']

lib/graphql/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def initialize
9595
@object_from_id_proc = nil
9696
@id_from_object_proc = nil
9797
# Default to the built-in execution strategy:
98-
@query_execution_strategy = GraphQL::Execution::DeferredExecution
98+
@query_execution_strategy = GraphQL::Query::SerialExecution
9999
@mutation_execution_strategy = GraphQL::Query::SerialExecution
100100
@subscription_execution_strategy = GraphQL::Query::SerialExecution
101101
end

spec/graphql/analysis/query_complexity_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@
258258
GraphQL::Schema.define(
259259
query: query_type,
260260
orphan_types: [double_complexity_type],
261-
resolve_type: :pass
261+
resolve_type: :pass,
262+
query_execution_strategy: DEFAULT_EXEC_STRATEGY,
262263
)
263264
}
264265
let(:query_string) {%|

spec/graphql/argument_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
end
1111

1212
err = assert_raises(GraphQL::Schema::InvalidTypeError) {
13-
schema = GraphQL::Schema.define(query: query_type)
13+
schema = GraphQL::Schema.define(query: query_type, query_execution_strategy: DEFAULT_EXEC_STRATEGY)
1414
schema.types
1515
}
1616

spec/graphql/introspection/introspection_query_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
deep_schema = GraphQL::Schema.define do
2626
query query_type
27+
query_execution_strategy DEFAULT_EXEC_STRATEGY
2728
end
2829

2930
result = deep_schema.execute(query_string)

spec/graphql/query/context_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
resolve ->(target, args, ctx) { ctx.query.class.name }
1818
end
1919
}}
20-
let(:schema) { GraphQL::Schema.define(query: query_type, mutation: nil)}
20+
let(:schema) { GraphQL::Schema.define(query: query_type, mutation: nil, query_execution_strategy: DEFAULT_EXEC_STRATEGY)}
2121
let(:result) { schema.execute(query_string, context: {"some_key" => "some value"})}
2222

2323
describe "access to passed-in values" do

spec/graphql/query/executor_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
end
8686
end
8787

88-
GraphQL::Schema.define(query: DummyQueryType, mutation: MutationType, resolve_type: :pass, id_from_object: :pass)
88+
GraphQL::Schema.define(query: DummyQueryType, mutation: MutationType, resolve_type: :pass, id_from_object: :pass, query_execution_strategy: DEFAULT_EXEC_STRATEGY)
8989
}
9090
let(:variables) { nil }
9191
let(:query_string) { %|

spec/graphql/query/serial_execution/value_resolution_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
GraphQL::Schema.define do
4545
query(query_root)
4646
orphan_types [some_object]
47+
query_execution_strategy DEFAULT_EXEC_STRATEGY
4748
resolve_type ->(obj, ctx) do
4849
if obj.is_a?(Symbol)
4950
other_object

spec/graphql/schema/loader_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
mutation: mutation_root,
112112
orphan_types: [audio_type, video_type],
113113
resolve_type: :pass,
114+
query_execution_strategy: DEFAULT_EXEC_STRATEGY,
114115
)
115116
}
116117

0 commit comments

Comments
 (0)