import { GET_PRODUCTS } from '~/graphql/queries/standalone/products'; import type { IProductResponse } from '~/types'; export function useProducts(params: Record = {}) { const variables = ref({ first: 12, ...params }); const { data, error } = useAsyncQuery( GET_PRODUCTS, variables ); const products = computed(() => data.value?.products?.edges ?? []); const pageInfo = computed(() => data.value?.products?.pageInfo ?? {}); watch(error, (e) => { if (e) console.error('useProducts error:', e); }); const updateVariables = (newParams: Record) => { variables.value = { first: 12, ...newParams }; }; return { products, pageInfo, updateVariables }; }