import { FetchResult } from '@apollo/client/core' ; import { CustomQuery } from '@vue-storefront/core' ; import { CreateCustomerMutation , CreateCustomerMutationVariables , CustomerCreateInput , } from '../../types/GraphQL' ; import createCustomer from './createCustomer' ; import { Context } from '../../types/context' ; export default async ( context , input , customQuery = { createCustomer : 'createCustomer' } ) : Promise < FetchResult < CreateCustomerMutation > > => { try { const { createCustomer : createCustomerGQL } = context . extendQuery ( customQuery , { createCustomer : { query : createCustomer , variables : { input } , } , } ) ; return await context . client . mutate < CreateCustomerMutation , CreateCustomerMutationVariables > ( { mutation : createCustomerGQL . query , variables : createCustomerGQL . variables , } ) ; } catch ( error ) { if ( error . graphQLErrors ) { return { errors : error . graphQLErrors , data : null , } ; } throw error . networkError ?. result || error ; } } ;