@@ -27,7 +27,7 @@ import { TransactionExecutor } from './internal/transaction-executor'
2727import { Bookmark } from './internal/bookmark'
2828import { TxConfig } from './internal/tx-config'
2929import ConnectionProvider from './connection-provider'
30- import { Query } from './types'
30+ import { Query , SessionMode } from './types'
3131import Connection from './connection'
3232import { NumberOrInteger } from './graph-types'
3333
@@ -47,7 +47,7 @@ interface TransactionConfig {
4747 * @access public
4848 */
4949class Session {
50- private _mode : string
50+ private _mode : SessionMode
5151 private _database : string
5252 private _reactive : boolean
5353 private _fetchSize : number
@@ -80,9 +80,9 @@ class Session {
8080 reactive,
8181 fetchSize
8282 } : {
83- mode : string
83+ mode : SessionMode
8484 connectionProvider : ConnectionProvider
85- bookmark : Bookmark
85+ bookmark ? : Bookmark
8686 database : string
8787 config : any
8888 reactive : boolean
@@ -106,7 +106,7 @@ class Session {
106106 } )
107107 this . _open = true
108108 this . _hasTx = false
109- this . _lastBookmark = bookmark
109+ this . _lastBookmark = bookmark || Bookmark . empty ( )
110110 this . _transactionExecutor = _createTransactionExecutor ( config )
111111 this . _onComplete = this . _onCompleteCallback . bind ( this )
112112 }
@@ -233,7 +233,7 @@ class Session {
233233 return this . _beginTransaction ( this . _mode , txConfig )
234234 }
235235
236- _beginTransaction ( accessMode : string , txConfig : TxConfig ) : Transaction {
236+ _beginTransaction ( accessMode : SessionMode , txConfig : TxConfig ) : Transaction {
237237 if ( ! this . _open ) {
238238 throw newError ( 'Cannot begin a transaction on a closed session.' )
239239 }
@@ -333,7 +333,7 @@ class Session {
333333 }
334334
335335 _runTransaction < T > (
336- accessMode : string ,
336+ accessMode : SessionMode ,
337337 transactionConfig : TxConfig ,
338338 transactionWork : TransactionWork < T >
339339 ) : Promise < T > {
@@ -369,7 +369,7 @@ class Session {
369369 }
370370 }
371371
372- _connectionHolderWithMode ( mode : string ) : ConnectionHolder {
372+ _connectionHolderWithMode ( mode : SessionMode ) : ConnectionHolder {
373373 if ( mode === ACCESS_MODE_READ ) {
374374 return this . _readConnectionHolder
375375 } else if ( mode === ACCESS_MODE_WRITE ) {
@@ -391,7 +391,7 @@ class Session {
391391 /**
392392 * @protected
393393 */
394- static _validateSessionMode ( rawMode ?: string ) : string {
394+ static _validateSessionMode ( rawMode ?: SessionMode ) : SessionMode {
395395 const mode = rawMode || ACCESS_MODE_WRITE
396396 if ( mode !== ACCESS_MODE_READ && mode !== ACCESS_MODE_WRITE ) {
397397 throw newError ( 'Illegal session mode ' + mode )
0 commit comments