createCustomer
Create a new customer.
Signature
declare function createCustomer(
context: Context,
input: CustomerCreateInput,
customQuery?: CustomQuery,
customHeaders?: CustomHeaders
): Promise<FetchResult<CreateCustomerMutation>>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | Context | |
input | Required | CustomerCreateInput | |
customQuery | Optional | CustomQuery | |
customHeaders | Optional | CustomHeaders |
Referenced Types
- Context
- CustomerCreateInput
- CustomQuery
- CustomHeaders
FetchResultCreateCustomerMutation
Examples
Simple usage with basic customer data:
import { sdk } from '~/sdk.config.ts';
const params = {
email: 'john.doe@gmail.com'
firstname: 'John',
lastname: 'Doe',
}
const result = await sdk.magento.createCustomer(params);Creating a custom GraphQL query for creating a customer
module.exports = {
integrations: {
magento: {
customQueries: {
'create-customer-custom-query': ({ variables, metadata }) => ({
variables,
query: `
query customer {
customer {
${metadata.fields}
}
}
`
}),
},
}
}
};Using a custom GraphQL query to fetch customer
import { sdk } from '~/sdk.config.ts';
// reduce the amount of fields returned by the query, when compared to the default query
const customQuery = {
customer: 'create customer-custom-query',
metadata: {
fields: 'email firstname lastname'
}
};
const params = {
email: 'john.doe@gmail.com'
firstname: 'John',
lastname: 'Doe',
}
const result = await sdk.magento.createCustomer(params, customQuery)
// result will contain only the fields specified in the custom query.