updateProfile method Null safety
- Supporter supporter
Updates the supporter's profile data in the database, which is essentially all personal information except for linked data (such as patients).
Implementation
// TODO(tigloo): Remove manual publishing of updates, move to subscription.
Future<Supporter?> updateProfile(Supporter supporter) async {
final result = await updateUserProfile(supporter);
if (result) {
final gqlQueryString = '''
mutation SetSupporterOnboarding {
updateSupporter(
input: {
where: { id: "${supporter.id}" }
data: {
onboardingVersionCompleted: ${supporter.onBoardingVersionCompleted}
}
}
) {
supporter {
${SupporterGqlEntity.gqlQueryFragment}
}
}
}
''';
try {
final queryResult = await graphQLClient.mutate<void>(MutationOptions(
document: gql(gqlQueryString),
fetchPolicy: FetchPolicy.networkOnly,
));
if (queryResult.hasException) {
logger?.e(queryResult.exception.toString());
return null;
}
} catch (e, stackTrace) {
logger?.e('Could not update supporter profile data', e, stackTrace);
return null;
}
_sendSupporterUpdate(supporter: supporter);
return supporter;
}
return null;
}