mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
27 lines
697 B
TypeScript
27 lines
697 B
TypeScript
import type { LocalConfig } from '../index'
|
|
import { Product } from '@commerce/types/product'
|
|
import { GetProductOperation } from '@commerce/types/product'
|
|
import data from '../../data.json'
|
|
import type { OperationContext } from '@commerce/api/operations'
|
|
|
|
export default function getProductOperation({
|
|
commerce,
|
|
}: OperationContext<any>) {
|
|
async function getProduct<T extends GetProductOperation>({
|
|
query = '',
|
|
variables,
|
|
config,
|
|
}: {
|
|
query?: string
|
|
variables?: T['variables']
|
|
config?: Partial<LocalConfig>
|
|
preview?: boolean
|
|
} = {}): Promise<Product | {} | any> {
|
|
return Promise.resolve({
|
|
product: data.products[0],
|
|
})
|
|
}
|
|
|
|
return getProduct
|
|
}
|