import type { LoginMutation, LoginMutationVariables, } from 'lib/bigcommerce/schema' import type { RecursivePartial } from '../utils/types' import { BigcommerceConfig, getConfig } from '..' export const loginMutation = /* GraphQL */ ` mutation login($email: String!, $password: String!) { login(email: $email, password: $password) { result } } ` export type LoginResult = T export type LoginVariables = LoginMutationVariables async function login(opts: { variables: LoginVariables config?: BigcommerceConfig }): Promise async function login(opts: { query: string variables: V config?: BigcommerceConfig }): Promise> async function login({ query = loginMutation, variables, config, }: { query?: string variables: LoginVariables config?: BigcommerceConfig }): Promise { config = getConfig(config) const data = await config.fetch>(query, { variables, }) return { result: data.login?.result, } } export default login