Implementation
Future<BuiltSet<LocalizedType<Interest>>> getAll() async {
const gqlQueryString = '''
query FetchAllInterestsWithLocalizations {
interests {
${InterestGqlEntity.gqlQueryFragment}
}
}
''';
try {
final queryResult = await graphQLClient
.query<void>(QueryOptions(document: gql(gqlQueryString)));
if (queryResult.hasException) {
logger?.e(queryResult.exception.toString());
return BuiltSet<LocalizedType<Interest>>();
}
final data = queryResult.data!['interests'] as List<dynamic>;
final l = data
.map((dynamic e) =>
InterestGqlEntity.fromJson(e as Map<String, dynamic>))
.where((element) => element != null)
.map((e) => e!.toLocalizedTypeInterest())
.toBuiltSet();
InterestStorage.allInterests = BuiltMap.from(
Map<String, LocalizedType<Interest>>.fromEntries(
l.map((p0) => MapEntry(p0.defaultValue.id, p0))));
return l;
} catch (e, stackTrace) {
logger?.e('Could not read list of interests', e.toString(), stackTrace);
return BuiltSet<LocalizedType<Interest>>();
}
}