@@ -4,7 +4,7 @@ import * as messages from "../generated/api_pb";
44
55import { DgraphClient } from "./client" ;
66import { ERR_ABORTED , ERR_FINISHED } from "./errors" ;
7- import { isAbortedError , isConflictError , mergeLinReads } from "./util" ;
7+ import { isAbortedError , isConflictError , mergeLinReads , stringifyMessage } from "./util" ;
88
99/**
1010 * Txn is a single atomic transaction.
@@ -50,6 +50,7 @@ export class Txn {
5050 vars ?: { [ k : string ] : any } | null , // tslint:disable-line no-any
5151 ) : Promise < messages . Response > {
5252 if ( this . finished ) {
53+ this . dc . debug ( `Query request (ERR_FINISHED):\nquery = ${ q } \nvars = ${ vars } ` ) ;
5354 throw ERR_FINISHED ;
5455 }
5556
@@ -66,10 +67,13 @@ export class Txn {
6667 }
6768 } ) ;
6869 }
70+ this . dc . debug ( `Query request:\n${ stringifyMessage ( req ) } ` ) ;
6971
7072 const c = this . dc . anyClient ( ) ;
7173 const res = await c . query ( req ) ;
7274 this . mergeContext ( res . getTxn ( ) ) ;
75+ this . dc . debug ( `Query response:\n${ stringifyMessage ( res ) } ` ) ;
76+
7377 return res ;
7478 }
7579
@@ -87,11 +91,13 @@ export class Txn {
8791 */
8892 public async mutate ( mu : messages . Mutation ) : Promise < messages . Assigned > {
8993 if ( this . finished ) {
94+ this . dc . debug ( `Mutate request (ERR_FINISHED):\nmutation = ${ stringifyMessage ( mu ) } ` ) ;
9095 throw ERR_FINISHED ;
9196 }
9297
9398 this . mutated = true ;
9499 mu . setStartTs ( this . ctx . getStartTs ( ) ) ;
100+ this . dc . debug ( `Mutate request:\n${ stringifyMessage ( mu ) } ` ) ;
95101
96102 let ag : messages . Assigned ;
97103 const c = this . dc . anyClient ( ) ;
@@ -118,6 +124,8 @@ export class Txn {
118124 }
119125
120126 this . mergeContext ( ag . getContext ( ) ) ;
127+ this . dc . debug ( `Mutate response:\n${ stringifyMessage ( ag ) } ` ) ;
128+
121129 return ag ;
122130 }
123131
0 commit comments