shippingAddressUpdate method

Future<Checkout> shippingAddressUpdate(
  1. String checkoutId,
  2. Address address, {
  3. bool deleteThisPartOfCache = false,
})

Updates the shipping address on given checkoutId

Implementation

Future<Checkout> shippingAddressUpdate(
  String checkoutId,
  Address address, {
  bool deleteThisPartOfCache = false,
}) async {
  Map<String, dynamic> variables = address.toJson();
  variables['checkoutId'] = checkoutId;
  final MutationOptions _options = MutationOptions(
    document: gql(checkoutShippingAddressUpdateMutation),
    variables: variables,
  );
  final QueryResult result = await _graphQLClient!.mutate(_options);
  checkForError(
    result,
    key: 'checkoutShippingAddressUpdateV2',
    errorKey: 'checkoutUserErrors',
  );
  if (deleteThisPartOfCache) {
    _graphQLClient!.cache.writeQuery(_options.asRequest, data: {});
  }

  return Checkout.fromJson(
      ((result.data!['checkoutShippingAddressUpdateV2'] ??
              const {})['checkout'] ??
          const {}));
}