@@ -14,7 +14,6 @@ export function useDelegationPlanDebug<
1414 fetchAPI = yoga . fetchAPI ;
1515 } ,
1616 onDelegationPlan ( {
17- subgraph,
1817 typeName,
1918 variables,
2019 fragments,
@@ -23,13 +22,10 @@ export function useDelegationPlanDebug<
2322 logger = opts . logger ,
2423 } ) {
2524 const planId = fetchAPI . crypto . randomUUID ( ) ;
26- const delegationPlanStartLogger = logger . child ( 'delegation-plan-start' ) ;
25+ const planLogger = logger . child ( { planId, typeName } ) ;
26+ const delegationPlanStartLogger = planLogger . child ( 'delegation-plan-start' ) ;
2727 delegationPlanStartLogger . debug ( ( ) => {
28- const logObj : Record < string , any > = {
29- planId,
30- subgraph,
31- typeName,
32- } ;
28+ const logObj : Record < string , any > = { } ;
3329 if ( variables && Object . keys ( variables ) . length ) {
3430 logObj [ 'variables' ] = variables ;
3531 }
@@ -51,21 +47,16 @@ export function useDelegationPlanDebug<
5147 }
5248 return logObj ;
5349 } ) ;
54- const start = performance . now ( ) ;
5550 return ( { delegationPlan } ) => {
5651 const delegationPlanDoneLogger = logger . child ( 'delegation-plan-done' ) ;
57- delegationPlanDoneLogger . debug ( ( ) => ( {
58- planId,
59- plan : delegationPlan . map ( ( plan ) => {
60- const planObj : Record < string , string > = { } ;
61- for ( const [ subschema , selectionSet ] of plan ) {
62- if ( subschema . name ) {
63- planObj [ subschema . name ] = print ( selectionSet ) ;
64- }
52+ delegationPlanDoneLogger . debug ( ( ) => delegationPlan . map ( ( plan ) => {
53+ const planObj : Record < string , string > = { } ;
54+ for ( const [ subschema , selectionSet ] of plan ) {
55+ if ( subschema . name ) {
56+ planObj [ subschema . name ] = print ( selectionSet ) ;
6557 }
66- return planObj ;
67- } ) ,
68- duration : performance . now ( ) - start ,
58+ }
59+ return planObj ;
6960 } ) ) ;
7061 } ;
7162 } ,
@@ -79,16 +70,12 @@ export function useDelegationPlanDebug<
7970 typeName,
8071 logger = opts . logger ,
8172 } ) {
82- let stageId : string ;
8373 let contextLog = stageExecuteLogById . get ( context ) ;
8474 if ( ! contextLog ) {
8575 contextLog = new Set ( ) ;
8676 stageExecuteLogById . set ( context , contextLog ) ;
8777 }
88- const delegationStageLogger = logger . child ( 'delegation-stage-execute' ) ;
8978 const log = {
90- subgraph,
91- typeName,
9279 key : JSON . stringify ( key ) ,
9380 object : JSON . stringify ( object ) ,
9481 selectionSet : print ( selectionSet ) ,
@@ -98,24 +85,23 @@ export function useDelegationPlanDebug<
9885 return ;
9986 }
10087 contextLog . add ( logStr ) ;
101- stageId = fetchAPI . crypto . randomUUID ( ) ;
102- delegationStageLogger . debug ( 'start' , ( ) => {
88+ const logMeta : Record < string , string > = {
89+ stageId : fetchAPI . crypto . randomUUID ( ) ,
90+ subgraph,
91+ typeName,
92+ } ;
93+ const delegationStageLogger = logger . child ( logMeta ) ;
94+ delegationStageLogger . debug ( 'delegation-plan-start' , ( ) => {
10395 return {
104- stageId,
10596 ...log ,
10697 path : pathToArray ( info . path ) . join ( ' | ' ) ,
10798 } ;
10899 } ) ;
109- const start = performance . now ( ) ;
110100 return ( { result } ) => {
111101 const delegationStageExecuteDoneLogger = logger . child (
112102 'delegation-stage-execute-done' ,
113103 ) ;
114- delegationStageExecuteDoneLogger . debug ( ( ) => ( {
115- stageId,
116- result : JSON . stringify ( result , null ) ,
117- duration : performance . now ( ) - start ,
118- } ) ) ;
104+ delegationStageExecuteDoneLogger . debug ( ( ) => result ) ;
119105 } ;
120106 } ,
121107 } ;
0 commit comments