This commit is contained in:
+41
-7
@@ -83,12 +83,16 @@ export const typeDefs = `#graphql
|
||||
type Product {
|
||||
uuid: String
|
||||
name: String
|
||||
imageUrl: String
|
||||
offersCount: Int
|
||||
}
|
||||
|
||||
type Supplier {
|
||||
uuid: String
|
||||
name: String
|
||||
country: String
|
||||
countryCode: String
|
||||
logoUrl: String
|
||||
latitude: Float
|
||||
longitude: Float
|
||||
distanceKm: Float
|
||||
@@ -98,8 +102,10 @@ export const typeDefs = `#graphql
|
||||
uuid: String
|
||||
productUuid: String
|
||||
productName: String
|
||||
productImageUrl: String
|
||||
supplierUuid: String
|
||||
supplierName: String
|
||||
supplierLogoUrl: String
|
||||
latitude: Float
|
||||
longitude: Float
|
||||
country: String
|
||||
@@ -115,8 +121,10 @@ export const typeDefs = `#graphql
|
||||
uuid: String
|
||||
productUuid: String
|
||||
productName: String
|
||||
productImageUrl: String
|
||||
supplierUuid: String
|
||||
supplierName: String
|
||||
supplierLogoUrl: String
|
||||
latitude: Float
|
||||
longitude: Float
|
||||
country: String
|
||||
@@ -182,8 +190,10 @@ function mapOffer(doc: ArangoDoc) {
|
||||
uuid: doc._key,
|
||||
productUuid: doc.product_uuid ?? null,
|
||||
productName: doc.product_name ?? null,
|
||||
productImageUrl: doc.product_image_url ?? null,
|
||||
supplierUuid: doc.supplier_uuid ?? null,
|
||||
supplierName: doc.supplier_name ?? null,
|
||||
supplierLogoUrl: doc.supplier_logo_url ?? null,
|
||||
latitude: doc.latitude ?? null,
|
||||
longitude: doc.longitude ?? null,
|
||||
country: doc.country ?? null,
|
||||
@@ -610,7 +620,7 @@ export const resolvers = {
|
||||
FILTER node.product_uuid != null
|
||||
COLLECT product_uuid = node.product_uuid INTO offers
|
||||
LET first_offer = FIRST(offers).node
|
||||
RETURN { uuid: product_uuid, name: first_offer.product_name }
|
||||
RETURN { uuid: product_uuid, name: first_offer.product_name, imageUrl: first_offer.product_image_url }
|
||||
`)
|
||||
return cursor.all()
|
||||
},
|
||||
@@ -653,8 +663,17 @@ export const resolvers = {
|
||||
FOR node IN nodes
|
||||
FILTER node.node_type == 'offer'
|
||||
FILTER node.supplier_uuid != null
|
||||
COLLECT supplier_uuid = node.supplier_uuid
|
||||
RETURN { uuid: supplier_uuid }
|
||||
COLLECT supplier_uuid = node.supplier_uuid INTO offers
|
||||
LET first_offer = FIRST(offers).node
|
||||
RETURN {
|
||||
uuid: supplier_uuid,
|
||||
name: first_offer.supplier_name,
|
||||
country: first_offer.country,
|
||||
countryCode: first_offer.country_code,
|
||||
logoUrl: first_offer.supplier_logo_url,
|
||||
latitude: first_offer.latitude,
|
||||
longitude: first_offer.longitude
|
||||
}
|
||||
`)
|
||||
return cursor.all()
|
||||
},
|
||||
@@ -668,7 +687,7 @@ export const resolvers = {
|
||||
FILTER node.product_uuid != null
|
||||
COLLECT product_uuid = node.product_uuid INTO offers
|
||||
LET first_offer = FIRST(offers).node
|
||||
RETURN { uuid: product_uuid, name: first_offer.product_name }
|
||||
RETURN { uuid: product_uuid, name: first_offer.product_name, imageUrl: first_offer.product_image_url }
|
||||
`, { supplier_uuid: args.supplierUuid })
|
||||
return cursor.all()
|
||||
},
|
||||
@@ -701,7 +720,7 @@ export const resolvers = {
|
||||
FILTER dist <= @radius_km
|
||||
COLLECT product_uuid = node.product_uuid INTO offers
|
||||
LET first_offer = FIRST(offers).node
|
||||
RETURN { uuid: product_uuid, name: first_offer.product_name }
|
||||
RETURN { uuid: product_uuid, name: first_offer.product_name, imageUrl: first_offer.product_image_url }
|
||||
`, { lat: hub.latitude, lon: hub.longitude, radius_km: args.radiusKm ?? 500 })
|
||||
return cursor.all()
|
||||
},
|
||||
@@ -714,7 +733,16 @@ export const resolvers = {
|
||||
FILTER node.product_uuid == @product_uuid
|
||||
FILTER node.supplier_uuid != null
|
||||
COLLECT supplier_uuid = node.supplier_uuid
|
||||
RETURN { uuid: supplier_uuid }
|
||||
LET first_offer = FIRST(offers).node
|
||||
RETURN {
|
||||
uuid: supplier_uuid,
|
||||
name: first_offer.supplier_name,
|
||||
country: first_offer.country,
|
||||
countryCode: first_offer.country_code,
|
||||
logoUrl: first_offer.supplier_logo_url,
|
||||
latitude: first_offer.latitude,
|
||||
longitude: first_offer.longitude
|
||||
}
|
||||
`, { product_uuid: args.productUuid })
|
||||
return cursor.all()
|
||||
},
|
||||
@@ -952,6 +980,9 @@ export const resolvers = {
|
||||
RETURN {
|
||||
uuid: supplier_uuid,
|
||||
name: supplier_node != null ? supplier_node.name : first_offer.supplier_name,
|
||||
country: supplier_node != null ? supplier_node.country : first_offer.country,
|
||||
countryCode: supplier_node != null ? supplier_node.country_code : first_offer.country_code,
|
||||
logoUrl: supplier_node != null ? supplier_node.supplier_logo_url : first_offer.supplier_logo_url,
|
||||
latitude: supplier_node != null ? supplier_node.latitude : first_offer.latitude,
|
||||
longitude: supplier_node != null ? supplier_node.longitude : first_offer.longitude,
|
||||
distanceKm: supplier_dist
|
||||
@@ -1020,6 +1051,9 @@ export const resolvers = {
|
||||
return nodes.map((n: ArangoDoc) => ({
|
||||
uuid: n._key,
|
||||
name: n.name ?? null,
|
||||
country: n.country ?? null,
|
||||
countryCode: n.country_code ?? null,
|
||||
logoUrl: n.supplier_logo_url ?? null,
|
||||
latitude: n.latitude ?? null,
|
||||
longitude: n.longitude ?? null,
|
||||
distanceKm: null,
|
||||
@@ -1039,7 +1073,7 @@ export const resolvers = {
|
||||
LET first_offer = FIRST(offers).node
|
||||
SORT first_offer.product_name ASC
|
||||
LIMIT @offset, @limit
|
||||
RETURN { uuid: product_uuid, name: first_offer.product_name }
|
||||
RETURN { uuid: product_uuid, name: first_offer.product_name, imageUrl: first_offer.product_image_url }
|
||||
`, { offset: args.offset ?? 0, limit: args.limit ?? 50, ...bounds.vars })
|
||||
return cursor.all()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user