runWithInterceptor<T> method

Future<T> runWithInterceptor<T>(
  1. Future<T> action(), {
  2. required QueryInterceptor interceptor,
})

Executes action with calls intercepted by the given interceptor

This can be used to, for instance, write a custom statement logger or to retry failing statements automatically.

Implementation

Future<T> runWithInterceptor<T>(
  Future<T> Function() action, {
  required QueryInterceptor interceptor,
}) async {
  final session = await currentSession();

  return _runConnectionZoned(
    _ScopedDatabaseSession(
      session.interceptWith(interceptor),
      currentStreamQueryStore(),
    ),
    action,
  );
}