33
44describe GraphQL ::Tracing ::NewRelicTrace do
55 module NewRelicTraceTest
6- class NestedSource < GraphQL ::Dataloader ::Source
6+ class EchoSource < GraphQL ::Dataloader ::Source
77 def fetch ( keys )
88 keys
99 end
1010 end
1111
1212 class OtherSource < GraphQL ::Dataloader ::Source
1313 def fetch ( keys )
14- dataloader . with ( NestedSource ) . load_all ( keys )
14+ dataloader . with ( EchoSource ) . load_all ( keys )
1515 end
1616 end
1717 class Thing < GraphQL ::Schema ::Object
@@ -31,7 +31,11 @@ class Other < GraphQL::Schema::Object
3131 def self . authorized? ( obj , ctx )
3232 ctx [ :lazy ] ? -> { true } : true
3333 end
34- field :name , String , fallback_value : "other"
34+ field :name , String
35+
36+ def name
37+ dataload ( EchoSource , "name" )
38+ end
3539 end
3640
3741 class Query < GraphQL ::Schema ::Object
@@ -83,6 +87,7 @@ class SchemaWithScalarTrace < GraphQL::Schema
8387 class SchemaWithoutAuthorizedOrResolveType < GraphQL ::Schema
8488 query ( Query )
8589 trace_with ( GraphQL ::Tracing ::NewRelicTrace , set_transaction_name : true , trace_authorized : false , trace_resolve_type : false , trace_scalars : true )
90+ use GraphQL ::Dataloader
8691 end
8792 end
8893
@@ -157,15 +162,17 @@ class SchemaWithoutAuthorizedOrResolveType < GraphQL::Schema
157162 "GraphQL/Source/NewRelicTraceTest::OtherSource" ,
158163 "FINISH GraphQL/Source/NewRelicTraceTest::OtherSource" ,
159164 # Nested source:
160- "GraphQL/Source/NewRelicTraceTest::NestedSource " ,
161- "FINISH GraphQL/Source/NewRelicTraceTest::NestedSource " ,
165+ "GraphQL/Source/NewRelicTraceTest::EchoSource " ,
166+ "FINISH GraphQL/Source/NewRelicTraceTest::EchoSource " ,
162167 "GraphQL/Source/NewRelicTraceTest::OtherSource" ,
163168 "FINISH GraphQL/Source/NewRelicTraceTest::OtherSource" ,
164169 # And back to the field:
165170 "GraphQL/Query/other" ,
166171 "FINISH GraphQL/Query/other" ,
167172 "GraphQL/Authorized/Other" ,
168173 "FINISH GraphQL/Authorized/Other" ,
174+ "GraphQL/Source/NewRelicTraceTest::EchoSource" ,
175+ "FINISH GraphQL/Source/NewRelicTraceTest::EchoSource" ,
169176 "FINISH GraphQL/execute"
170177 ]
171178 assert_equal expected_steps , NewRelic ::EXECUTION_SCOPES
@@ -191,6 +198,12 @@ class SchemaWithoutAuthorizedOrResolveType < GraphQL::Schema
191198 # "FINISH GraphQL/Authorized/Other",
192199 "GraphQL/Other/name" ,
193200 "FINISH GraphQL/Other/name" ,
201+
202+ "GraphQL/Source/NewRelicTraceTest::EchoSource" ,
203+ "FINISH GraphQL/Source/NewRelicTraceTest::EchoSource" ,
204+ "GraphQL/Other/name" ,
205+ "FINISH GraphQL/Other/name" ,
206+
194207 "FINISH GraphQL/execute"
195208 ]
196209 assert_equal expected_steps , NewRelic ::EXECUTION_SCOPES
@@ -232,6 +245,8 @@ class SchemaWithoutAuthorizedOrResolveType < GraphQL::Schema
232245 "FINISH GraphQL/Authorized/Other" ,
233246 "GraphQL/Authorized/Other" ,
234247 "FINISH GraphQL/Authorized/Other" ,
248+ "GraphQL/Source/NewRelicTraceTest::EchoSource" ,
249+ "FINISH GraphQL/Source/NewRelicTraceTest::EchoSource" ,
235250
236251 "FINISH GraphQL/execute" ,
237252 ]
0 commit comments