Skip to content

Commit 3d5582c

Browse files
committed
Migrate tests
1 parent 5e28ed7 commit 3d5582c

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

spec/graphql/execution/interpreter_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,20 +306,20 @@ def self.trace(event, data)
306306
end
307307
tracer EnsureArgsAreObject
308308

309-
class EnsureThreadCleanedUp
310-
def self.before_multiplex(_multiplex); end
311-
def self.after_multiplex(multiplex)
309+
module EnsureThreadCleanedUp
310+
def execute_multiplex(multiplex:)
311+
res = super
312312
runtime_info = Thread.current[:__graphql_runtime_info]
313313
if !runtime_info.nil? && runtime_info != {}
314314
if !multiplex.context[:allow_pending_thread_state]
315315
# `nestedQuery` can allow this
316316
raise "Query did not clean up runtime state, found: #{runtime_info.inspect}"
317317
end
318318
end
319+
res
319320
end
320321
end
321-
322-
instrument :multiplex, EnsureThreadCleanedUp
322+
trace_with(EnsureThreadCleanedUp)
323323
end
324324
end
325325

spec/graphql/execution/lookahead_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,16 @@ def species(id:)
8989
end
9090
end
9191

92-
class LookaheadInstrumenter
93-
def self.before_query(query)
92+
module LookaheadInstrumenter
93+
def execute_query(query:)
9494
query.context[:root_lookahead_selections] = query.lookahead.selections
95-
end
96-
97-
def self.after_query(q)
95+
super
9896
end
9997
end
10098

10199
class Schema < GraphQL::Schema
102100
query(Query)
103-
instrument :query, LookaheadInstrumenter
101+
trace_with LookaheadInstrumenter
104102
end
105103

106104
class AlwaysVisibleSchema < Schema

spec/graphql/schema_spec.rb

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,12 @@ def trace(_key, data)
238238
end
239239
end
240240

241-
class NoOpInstrumentation
242-
def before_query(query)
243-
query.context[:no_op_instrumentation_ran_before_query] = true
244-
end
245-
246-
def after_query(query)
247-
query.context[:no_op_instrumentation_ran_after_query] = true
241+
module NoOpTrace
242+
def execute_query(query:)
243+
query.context[:no_op_trace_ran_before_query] = true
244+
super
245+
ensure
246+
query.context[:no_op_trace_ran_after_query] = true
248247
end
249248
end
250249

@@ -265,7 +264,7 @@ def result
265264

266265
module PluginWithInstrumentationTracingAndAnalyzer
267266
def self.use(schema_defn)
268-
schema_defn.instrument :query, NoOpInstrumentation.new
267+
schema_defn.trace_with(NoOpTrace)
269268
schema_defn.tracer NoOpTracer.new
270269
schema_defn.query_analyzer NoOpAnalyzer
271270
end
@@ -291,8 +290,8 @@ def foobar; 1337; end
291290
res = query.result
292291
assert res.key?("data")
293292

294-
assert_equal true, query.context[:no_op_instrumentation_ran_before_query]
295-
assert_equal true, query.context[:no_op_instrumentation_ran_after_query]
293+
assert_equal true, query.context[:no_op_trace_ran_before_query]
294+
assert_equal true, query.context[:no_op_trace_ran_after_query]
296295
assert_equal true, query.context[:no_op_tracer_ran]
297296
assert_equal true, query.context[:no_op_analyzer_ran_initialize]
298297
assert_equal true, query.context[:no_op_analyzer_ran_on_leave_field]
@@ -318,8 +317,8 @@ def foobar; 1337; end
318317
res = query.result
319318
assert res.key?("data")
320319

321-
assert_equal true, query.context[:no_op_instrumentation_ran_before_query]
322-
assert_equal true, query.context[:no_op_instrumentation_ran_after_query]
320+
assert_equal true, query.context[:no_op_trace_ran_before_query]
321+
assert_equal true, query.context[:no_op_trace_ran_after_query]
323322
assert_equal true, query.context[:no_op_tracer_ran]
324323
assert_equal true, query.context[:no_op_analyzer_ran_initialize]
325324
assert_equal true, query.context[:no_op_analyzer_ran_on_leave_field]

0 commit comments

Comments
 (0)