import type { OperationContext, OperationOptions, } from '@commerce/api/operations' import { GetAllPagesQuery, GetAllPagesQueryVariables } from '@framework/schema' import type { ShopifyConfig, Provider } from '..' import { GetAllPagesOperation } from '../../types/page' import getAllPagesQuery from '../../utils/queries/get-all-pages-query' export default function getAllPagesOperation({ commerce, }: OperationContext) { async function getAllPages(opts?: { config?: Partial preview?: boolean }): Promise async function getAllPages( opts: { config?: Partial preview?: boolean } & OperationOptions ): Promise async function getAllPages({ query = getAllPagesQuery, config, }: { url?: string config?: Partial preview?: boolean query?: string } = {}): Promise { const cfg = commerce.getConfig(config) const { data } = await cfg.fetch< GetAllPagesQuery, GetAllPagesQueryVariables >(query) return { pages: data.pages.edges, } } return getAllPages }