From 1086fce6bdf1eb68054346f25813942669fc8ed1 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Thu, 20 May 2021 14:37:34 -0500 Subject: [PATCH] Updated login operation --- framework/bigcommerce/api/operations/login.ts | 18 +++++++++++------- framework/commerce/api/operations.ts | 17 +++++++++++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/framework/bigcommerce/api/operations/login.ts b/framework/bigcommerce/api/operations/login.ts index 0b4c46d23..797418745 100644 --- a/framework/bigcommerce/api/operations/login.ts +++ b/framework/bigcommerce/api/operations/login.ts @@ -1,5 +1,8 @@ import type { ServerResponse } from 'http' -import type { OperationContext } from '@commerce/api/operations' +import type { + OperationContext, + OperationOptions, +} from '@commerce/api/operations' import type { LoginMutation, LoginMutationVariables } from '../../schema' import type { RecursivePartial } from '../utils/types' import concatHeader from '../utils/concat-cookie' @@ -24,12 +27,13 @@ function loginOperation({ commerce }: OperationContext) { res: ServerResponse }): Promise - async function login(opts: { - query: string - variables: V - res: ServerResponse - config?: BigcommerceConfig - }): Promise> + async function login( + opts: { + variables: V + config?: BigcommerceConfig + res: ServerResponse + } & OperationOptions + ): Promise> async function login({ query = loginMutation, diff --git a/framework/commerce/api/operations.ts b/framework/commerce/api/operations.ts index e9ef288a8..3902fdaeb 100644 --- a/framework/commerce/api/operations.ts +++ b/framework/commerce/api/operations.ts @@ -24,12 +24,13 @@ export type Operations

= { res: ServerResponse }): Promise - (opts: { - query: string - variables: V - res: ServerResponse - config?: P['config'] | undefined - }): Promise> + ( + opts: { + variables: V + config?: P['config'] + res: ServerResponse + } & OperationOptions + ): Promise> } } @@ -48,3 +49,7 @@ export type AllOperations

= { export type OperationContext

= { commerce: CommerceAPI

} + +export type OperationOptions = + | { query: string; url?: never } + | { query?: never; url: string }