Refactor catalog to use coordinate-based GraphQL endpoints
All checks were successful
Build Docker Image / build (push) Successful in 3m33s

Replace entity-specific queries (GetProductsNearHub, GetOffersByHub, GetHubsForProduct, GetSuppliersForProduct) with unified coordinate-based endpoints (NearestHubs, NearestOffers, NearestSuppliers, RouteToCoordinate). This simplifies backend architecture from 18 to 8 core endpoints while maintaining identical UI/UX behavior.

All composables and pages now use coordinates + client-side grouping instead of specialized backend queries. For global product filtering, uses center point (0,0) with 20000km radius.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Ruslan Bakiev
2026-01-25 17:39:33 +07:00
parent 7403d4f063
commit 50375f2a74
6 changed files with 372 additions and 93 deletions

View File

@@ -1,4 +1,4 @@
import { GetNodesDocument, GetHubCountriesDocument, GetHubsForProductDocument } from '~/composables/graphql/public/geo-generated'
import { GetNodesDocument, GetHubCountriesDocument, NearestHubsDocument } from '~/composables/graphql/public/geo-generated'
const PAGE_SIZE = 24
@@ -52,15 +52,22 @@ export function useCatalogHubs() {
const fetchPage = async (offset: number, replace = false) => {
if (replace) isLoading.value = true
try {
// If filtering by product, use specialized query
// If filtering by product, use nearestHubs with global search
// (center point 0,0 with very large radius to cover entire globe)
if (filterProductUuid.value) {
const data = await execute(
GetHubsForProductDocument,
{ productUuid: filterProductUuid.value },
NearestHubsDocument,
{
lat: 0,
lon: 0,
radius: 20000, // 20000 km radius covers entire Earth
productUuid: filterProductUuid.value,
limit: 500 // Increased limit for global search
},
'public',
'geo'
)
const next = data?.hubsForProduct || []
const next = data?.nearestHubs || []
items.value = next
total.value = next.length
isInitialized.value = true