mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 13:41:22 +00:00
Updated login operation
This commit is contained in:
parent
ff2b12bcf1
commit
1086fce6bd
@ -1,5 +1,8 @@
|
|||||||
import type { ServerResponse } from 'http'
|
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 { LoginMutation, LoginMutationVariables } from '../../schema'
|
||||||
import type { RecursivePartial } from '../utils/types'
|
import type { RecursivePartial } from '../utils/types'
|
||||||
import concatHeader from '../utils/concat-cookie'
|
import concatHeader from '../utils/concat-cookie'
|
||||||
@ -24,12 +27,13 @@ function loginOperation({ commerce }: OperationContext<Provider>) {
|
|||||||
res: ServerResponse
|
res: ServerResponse
|
||||||
}): Promise<LoginResult>
|
}): Promise<LoginResult>
|
||||||
|
|
||||||
async function login<T extends { result?: any }, V = any>(opts: {
|
async function login<T extends { result?: any }, V = any>(
|
||||||
query: string
|
opts: {
|
||||||
variables: V
|
variables: V
|
||||||
res: ServerResponse
|
config?: BigcommerceConfig
|
||||||
config?: BigcommerceConfig
|
res: ServerResponse
|
||||||
}): Promise<LoginResult<T>>
|
} & OperationOptions
|
||||||
|
): Promise<LoginResult<T>>
|
||||||
|
|
||||||
async function login({
|
async function login({
|
||||||
query = loginMutation,
|
query = loginMutation,
|
||||||
|
@ -24,12 +24,13 @@ export type Operations<P extends APIProvider> = {
|
|||||||
res: ServerResponse
|
res: ServerResponse
|
||||||
}): Promise<LoginResult>
|
}): Promise<LoginResult>
|
||||||
|
|
||||||
<T extends { result?: any }, V = any>(opts: {
|
<T extends { result?: any }, V = any>(
|
||||||
query: string
|
opts: {
|
||||||
variables: V
|
variables: V
|
||||||
res: ServerResponse
|
config?: P['config']
|
||||||
config?: P['config'] | undefined
|
res: ServerResponse
|
||||||
}): Promise<LoginResult<T>>
|
} & OperationOptions
|
||||||
|
): Promise<LoginResult<T>>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,3 +49,7 @@ export type AllOperations<P extends APIProvider> = {
|
|||||||
export type OperationContext<P extends APIProvider> = {
|
export type OperationContext<P extends APIProvider> = {
|
||||||
commerce: CommerceAPI<P>
|
commerce: CommerceAPI<P>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type OperationOptions =
|
||||||
|
| { query: string; url?: never }
|
||||||
|
| { query?: never; url: string }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user