query all products for vendors & paths, improve search

This commit is contained in:
cond0r
2021-02-12 09:56:03 +02:00
parent 1450492826
commit 8d801ce5d7
20 changed files with 315 additions and 126 deletions

View File

@@ -1,27 +1,39 @@
import { ShopifyConfig, getConfig } from '../api'
import type { Page } from '../types'
import { GraphQLFetcherResult } from '@commerce/api'
export type { Page }
import { getConfig, ShopifyConfig } from '../api'
import getPageQuery from '@framework/utils/queries/get-page-query'
import { Page, PageEdge } from '@framework/schema'
export type GetPageResult<T extends { page?: any } = { page?: Page }> = T
export type PageVariables = {
id: string
type Variables = {
slug: string
}
async function getPage({
url,
variables,
config,
preview,
}: {
url?: string
variables: PageVariables
config?: ShopifyConfig
type ReturnType = {
page: any
}
const getPage = async (options: {
variables: Variables
config: ShopifyConfig
preview?: boolean
}): Promise<GetPageResult> {
}): Promise<ReturnType> => {
let { config, variables } = options ?? {}
config = getConfig(config)
return {}
const { data }: GraphQLFetcherResult = await config.fetch(getPageQuery, {
variables,
})
const page: Page = data?.pageByHandle
return {
page: page
? {
...page,
url: page?.handle,
}
: null,
}
}
export default getPage