connectionAddress property

Future<Uri> get connectionAddress

Returns connection url.

Implementation

Future<Uri> get connectionAddress async {
  // If datasources is not empty, use the first one.
  final Iterable<String> urls = datasources.entries
      .map((e) => e.value.url)
      .where((e) => e?.isNotEmpty == true)
      .cast<String>();
  if (urls.isNotEmpty) {
    return parseConnectionAddress(urls.first);
  }

  // Find in internal datasources.
  final Iterable<String> envNames = intenalDatasources
      .map((e) => e.url)
      .where((e) => e?.isNotEmpty == true)
      .cast<String>();
  final PrismaEnvironment environment = await this.environment;

  for (final name in envNames) {
    final value = environment[name];
    if (value?.isNotEmpty == true) {
      return parseConnectionAddress(value!);
    }
  }

  throw StateError('Not found Data Proxy connection address');
}