All files / src/api/createMyOrderFromCart index.ts

100% Statements 12/12
100% Branches 3/3
100% Functions 1/1
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  2x 2x   2x   2x 2x 2x       2x 2x             2x  
import { OrderMyCartCommand } from '../../types/GraphQL';
import { getCustomQuery, CustomQueryFn } from '../../index';
import CreateMyOrderFromCartMutation from './defaultMutation';
import { OrderMutationResponse } from '../../types/Api';
import gql from 'graphql-tag';
 
const createMyOrderFromCart = async ({ config, client }, draft: OrderMyCartCommand, customQueryFn?: CustomQueryFn): Promise<OrderMutationResponse> => {
  const { locale, acceptLanguage } = config;
  const defaultVariables = { locale,
    acceptLanguage,
    draft
  };
  const { query, variables } = getCustomQuery(customQueryFn, { defaultQuery: CreateMyOrderFromCartMutation, defaultVariables });
  return await client.mutate({
    mutation: gql`${query}`,
    variables,
    fetchPolicy: 'no-cache'
  });
};
 
export default createMyOrderFromCart;