fix(dashboard): Prevent overfetching data (#11532)
**What** Currently, the dashboard is fetching way more data than needed to display the products. This can lead to issues for complex catalog. this pr aim to reduce the data to be fetched to exactly what is needed. <img width="2553" alt="Screenshot 2025-02-19 at 15 08 16" src="https://github.com/user-attachments/assets/b00e856c-e040-4f05-9f15-41fb8d299387" />
This commit is contained in:
1 parent
508b948b9d
commit
0307304dc6
4 files changed
+12
-4
No files matched your search
@@ -6,6 +6,9 @@ type UseProductTableQueryProps = {
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
const DEFAULT_FIELDS =
|
||||
"id,title,handle,status,*collection,*sales_channels,variants.id"
|
||||
|
||||
export const useProductTableQuery = ({
|
||||
prefix,
|
||||
pageSize = 20,
|
||||
@@ -58,6 +61,7 @@ export const useProductTableQuery = ({
|
||||
type_id: type_id?.split(","),
|
||||
status: status?.split(",") as HttpTypes.AdminProductStatus[],
|
||||
q,
|
||||
fields: DEFAULT_FIELDS,
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
+2
-1
@@ -75,7 +75,8 @@ export const ProductVariantSection = ({
|
||||
: undefined,
|
||||
created_at: created_at ? JSON.parse(created_at) : undefined,
|
||||
updated_at: updated_at ? JSON.parse(updated_at) : undefined,
|
||||
fields: "*inventory_items.inventory.location_levels,+inventory_quantity",
|
||||
fields:
|
||||
"title,sku,*options,created_at,updated_at,*inventory_items.inventory.location_levels,inventory_quantity",
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
|
||||
@@ -7,9 +7,7 @@ import { PricingEdit } from "./pricing-edit"
|
||||
export const ProductPrices = () => {
|
||||
const { id, variant_id } = useParams()
|
||||
|
||||
const { product, isLoading, isError, error } = useProduct(id!, {
|
||||
fields: "+variants,+variants.prices",
|
||||
})
|
||||
const { product, isLoading, isError, error } = useProduct(id!)
|
||||
|
||||
if (isError) {
|
||||
throw error
|
||||
|
||||
Reference in new issue
Block a user