Alokai

updateCustomerAddress

Update customer address

Signature

declare function updateCustomerAddress(
	context: Context,
	input: MutationUpdateCustomerAddressArgs,
	customQuery?: CustomQuery,
	customHeaders?: CustomHeaders
): Promise<FetchResult<UpdateCustomerAddressMutation>>;

Parameters

NameRequiredTypeDescription
contextRequiredContext
inputRequiredMutationUpdateCustomerAddressArgs
customQueryOptionalCustomQuery
customHeadersOptionalCustomHeaders

Referenced Types

Examples

Simple usage:

import { sdk } from '~/sdk.config.ts';

// update customer address
const result = await sdk.magento.updateCustomerAddress({
  id: 123,
  input: {
    firstname: 'John',
    lastname: 'Doe',
    street: ['123 Main St'],
    city: 'New York',
    postcode: '10001',
    country_code: 'US'
  }
});

Creating a custom GraphQL query for updating customer address

module.exports = {
  integrations: {
    magento: {
      customQueries: {
        'update-customer-address-custom-query': ({ variables, metadata }) => ({
           variables,
           query: `
             mutation updateCustomerAddress($id: Int!, $input: CustomerAddressInput!) {
               updateCustomerAddress(id: $id, input: $input) {
                 ${metadata.fields}
               }
             }
           `
        }),
      },
    }
  }
};

Using a custom GraphQL query to update customer address

import { sdk } from '~/sdk.config.ts';
// reduce the amount of fields returned by the query, when compared to the default query
const customQuery = {
  updateCustomerAddress: 'update-customer-address-custom-query',
  metadata: {
    fields: 'id firstname lastname'
  }
};

const result = await sdk.magento.updateCustomerAddress({
  id: 123,
  input: {
    firstname: 'John',
    lastname: 'Doe',
    street: ['123 Main St'],
    city: 'New York',
    postcode: '10001',
    country_code: 'US'
  }
}, customQuery);

// Result will contain only the fields specified in the custom query.

On this page