customerUpdate method

Future<void> customerUpdate({
  1. String? email,
  2. String? firstName,
  3. String? lastName,
  4. String? password,
  5. String? phoneNumber,
  6. String? customerAccessToken,
  7. bool? acceptsMarketing,
  8. bool deleteThisPartOfCache = false,
})

Updates the customer to which customerAccessToken belongs to.

Implementation

Future<void> customerUpdate(
    {String? email,
    String? firstName,
    String? lastName,
    String? password,
    String? phoneNumber,
    String? customerAccessToken,
    bool? acceptsMarketing,
    bool deleteThisPartOfCache = false}) async {
  Map<String, dynamic> variableMap = {};
  ({
    'email': email,
    'firstName': firstName,
    'lastName': lastName,
    'password': password,
    'phone': phoneNumber,
    'acceptsMarketing': acceptsMarketing,
    'customerAccessToken': customerAccessToken
  }).forEach((k, v) => v != {} ? variableMap[k] = v : {});

  final MutationOptions _options = MutationOptions(
      document: gql(createValidMutationString(variableMap)),
      variables: variableMap);
  QueryResult result = await _graphQLClient!.mutate(_options);
  checkForError(
    result,
    key: 'customerUpdate',
    errorKey: 'customerUserErrors',
  );
  if (deleteThisPartOfCache) {
    _graphQLClient!.cache.writeQuery(_options.asRequest, data: {});
  }
}