createCustomerAddress
Create customer address
Signature
declare function createCustomerAddress(
context: Context,
input: CustomerAddressInput,
customQuery?: CustomQuery,
customHeaders?: CustomHeaders
): Promise<FetchResult<CreateCustomerAddressMutation>>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | Context | |
input | Required | CustomerAddressInput | |
customQuery | Optional | CustomQuery | |
customHeaders | Optional | CustomHeaders |
Referenced Types
- Context
- CustomerAddressInput
- CustomQuery
- CustomHeaders
FetchResultCreateCustomerAddressMutation
Examples
Simple usage:
import { sdk } from '~/sdk.config.ts';
// create customer address
const result = await sdk.magento.createCustomerAddress({
firstname: 'John',
lastname: 'Doe',
street: ['123 Main St'],
city: 'New York',
postcode: '10001',
country_code: 'US'
});Creating a custom GraphQL query for creating customer address
module.exports = {
integrations: {
magento: {
customQueries: {
'create-customer-address-custom-query': ({ variables, metadata }) => ({
variables,
query: `
mutation createCustomerAddress($input: CustomerAddressInput!) {
createCustomerAddress(input: $input) {
${metadata.fields}
}
}
`
}),
},
}
}
};Using a custom GraphQL query to create 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 = {
createCustomerAddress: 'create-customer-address-custom-query',
metadata: {
fields: 'id firstname lastname city'
}
};
const result = await sdk.magento.createCustomerAddress({
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.