44describe GraphQL ::Tracing ::DetailedTrace do
55 class SamplerSchema < GraphQL ::Schema
66 class Query < GraphQL ::Schema ::Object
7- field :truthy , Boolean , fallback_value : true
7+ field :truthy , Boolean , fallback_value : true , resolve_static : true
8+ def self . truthy ( ctx ) ; true ; end
89 end
910
1011 query ( Query )
@@ -16,30 +17,48 @@ def self.detailed_trace?(query)
1617 query . context [ :profile ] != false
1718 end
1819 end
20+
21+ use GraphQL ::Execution ::Next
1922 end
2023
2124 before do
2225 SamplerSchema . detailed_trace . delete_all_traces
2326 end
2427
28+ def exec_query ( ...)
29+ if TESTING_EXEC_NEXT
30+ SamplerSchema . execute_next ( ...)
31+ else
32+ SamplerSchema . execute ( ...)
33+ end
34+ end
35+
36+ def exec_multiplex ( ...)
37+ if TESTING_EXEC_NEXT
38+ SamplerSchema . multiplex_next ( ...)
39+ else
40+ SamplerSchema . multiplex ( ...)
41+ end
42+ end
43+
2544 it "runs when the configured trace mode is set" do
2645 assert_equal 0 , SamplerSchema . detailed_trace . traces . size
27- res = SamplerSchema . execute ( "{ truthy }" , context : { profile : false } )
46+ res = exec_query ( "{ truthy }" , context : { profile : false } )
2847 assert_equal true , res [ "data" ] [ "truthy" ]
2948 assert_equal 0 , SamplerSchema . detailed_trace . traces . size
3049
31- SamplerSchema . execute ( "{ truthy }" )
50+ exec_query ( "{ truthy }" )
3251 assert_equal 1 , SamplerSchema . detailed_trace . traces . size
3352 end
3453
3554 it "calls through to storage for access methods" do
36- SamplerSchema . execute ( "{ truthy }" )
55+ exec_query ( "{ truthy }" )
3756 id = SamplerSchema . detailed_trace . traces . first . id
3857 assert_kind_of GraphQL ::Tracing ::DetailedTrace ::StoredTrace , SamplerSchema . detailed_trace . find_trace ( id )
3958 SamplerSchema . detailed_trace . delete_trace ( id )
4059 assert_equal 0 , SamplerSchema . detailed_trace . traces . size
4160
42- SamplerSchema . execute ( "{ truthy }" )
61+ exec_query ( "{ truthy }" )
4362 assert_equal 1 , SamplerSchema . detailed_trace . traces . size
4463 SamplerSchema . detailed_trace . delete_all_traces
4564 end
@@ -66,13 +85,13 @@ def self.detailed_trace?(query)
6685 it "calls detailed_profile? on a Multiplex" do
6786 assert_equal 0 , SamplerSchema . detailed_trace . traces . size
6887
69- SamplerSchema . multiplex ( [
88+ exec_multiplex ( [
7089 { query : "{ truthy }" , context : { profile : false } } ,
7190 { query : "{ truthy }" , context : { profile : true } } ,
7291 ] )
7392 assert_equal 0 , SamplerSchema . detailed_trace . traces . size
7493
75- SamplerSchema . multiplex ( [
94+ exec_multiplex ( [
7695 { query : "{ truthy }" , context : { profile : true } } ,
7796 { query : "{ truthy }" , context : { profile : true } } ,
7897 ] )
0 commit comments