feat: deprecate remoteQueryConfig in favor of queryConfig (#10773)

Fixes: FRMW-2783
This commit is contained in:
Harminder Virk
2025-01-03 08:46:23 +00:00
committed by GitHub
parent 54e1e70d78
commit 5e9d86d75d
200 changed files with 375 additions and 399 deletions
@@ -60,12 +60,12 @@ export const POST = async (
type: error.type,
},
})
return;
return
}
const { data } = await query.graph({
entity: "order",
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
filters: { id: result.id },
})
@@ -23,7 +23,7 @@ export const POST = async (
const cart = await refetchCart(
req.params.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ cart })
@@ -51,7 +51,7 @@ export const POST = async (
const updatedCart = await refetchCart(
req.params.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ cart: updatedCart })
@@ -70,7 +70,7 @@ export const DELETE = async (
const cart = await refetchCart(
req.params.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({
@@ -18,7 +18,7 @@ export const POST = async (
const cart = await refetchCart(
req.params.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ cart })
@@ -26,7 +26,7 @@ export const POST = async (
const cart = await refetchCart(
req.params.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ cart })
@@ -52,7 +52,7 @@ export const DELETE = async (
const cart = await refetchCart(
req.params.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ cart })
@@ -15,7 +15,7 @@ export const GET = async (
const cart = await refetchCart(
req.params.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.json({ cart })
@@ -39,7 +39,7 @@ export const POST = async (
const cart = await refetchCart(
req.params.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ cart })
@@ -20,7 +20,7 @@ export const POST = async (
const cart = await refetchCart(
req.params.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ cart })
@@ -17,7 +17,7 @@ export const POST = async (
const cart = await refetchCart(
req.params.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ cart })
+1 -5
View File
@@ -23,11 +23,7 @@ export const POST = async (
input: workflowInput as CreateCartWorkflowInputDTO,
})
const cart = await refetchCart(
result.id,
req.scope,
req.remoteQueryConfig.fields
)
const cart = await refetchCart(result.id, req.scope, req.queryConfig.fields)
res.status(200).json({ cart })
}
@@ -12,7 +12,7 @@ export const GET = async (
const collection = await refetchCollection(
req.params.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ collection })
@@ -19,9 +19,9 @@ export const GET = async (
entryPoint: "product_collection",
variables: {
filters: req.filterableFields,
...req.remoteQueryConfig.pagination,
...req.queryConfig.pagination,
},
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
})
const { rows: collections, metadata } = await remoteQuery(query)
@@ -17,7 +17,7 @@ export const GET = async (
const queryObject = remoteQueryObjectFromString({
entryPoint: "currency",
variables,
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
})
const [currency] = await remoteQuery(queryObject)
@@ -15,9 +15,9 @@ export const GET = async (
entryPoint: "currency",
variables: {
filters: req.filterableFields,
...req.remoteQueryConfig.pagination,
...req.queryConfig.pagination,
},
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
})
const { rows: currencies, metadata } = await remoteQuery(queryObject)
@@ -30,7 +30,7 @@ export const GET = async (
variables: {
filters: { id: req.params.address_id, customer_id: customerId },
},
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
})
const [address] = await remoteQuery(queryObject)
@@ -59,11 +59,7 @@ export const POST = async (
},
})
const customer = await refetchCustomer(
id,
req.scope,
req.remoteQueryConfig.fields
)
const customer = await refetchCustomer(id, req.scope, req.queryConfig.fields)
res.status(200).json({ customer })
}
@@ -80,11 +76,7 @@ export const DELETE = async (
input: { ids: [req.params.address_id] },
})
const customer = await refetchCustomer(
id,
req.scope,
req.remoteQueryConfig.fields
)
const customer = await refetchCustomer(id, req.scope, req.queryConfig.fields)
res.status(200).json({
id,
@@ -26,9 +26,9 @@ export const GET = async (
entryPoint: "customer_address",
variables: {
filters: { ...req.filterableFields, customer_id: customerId },
...req.remoteQueryConfig.pagination,
...req.queryConfig.pagination,
},
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
})
const { rows: addresses, metadata } = await remoteQuery(queryObject)
@@ -62,7 +62,7 @@ export const POST = async (
const customer = await refetchCustomer(
customerId,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ customer })
@@ -17,11 +17,7 @@ export const GET = async (
res: MedusaResponse<HttpTypes.StoreCustomerResponse>
) => {
const id = req.auth_context.actor_id
const customer = await refetchCustomer(
id,
req.scope,
req.remoteQueryConfig.fields
)
const customer = await refetchCustomer(id, req.scope, req.queryConfig.fields)
if (!customer) {
throw new MedusaError(
@@ -48,7 +44,7 @@ export const POST = async (
const customer = await refetchCustomer(
customerId,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ customer })
}
@@ -30,7 +30,7 @@ export const POST = async (
const customer = await refetchCustomer(
result.id,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({ customer })
@@ -10,7 +10,7 @@ export const GET = async (
const workflow = getOrderDetailWorkflow(req.scope)
const { result } = await workflow.run({
input: {
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
order_id: req.params.id,
filters: {
is_draft_order: false,
@@ -20,7 +20,7 @@ export const POST = async (
const { result } = await getOrderDetailWorkflow(req.scope).run({
input: {
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
order_id: req.params.id,
},
})
@@ -25,7 +25,7 @@ export const POST = async (
const { result } = await getOrderDetailWorkflow(req.scope).run({
input: {
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
order_id: orderId,
},
})
@@ -20,7 +20,7 @@ export const POST = async (
const { result } = await getOrderDetailWorkflow(req.scope).run({
input: {
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
order_id: req.params.id,
},
})
@@ -27,7 +27,7 @@ export const POST = async (
const { result } = await getOrderDetailWorkflow(req.scope).run({
input: {
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
order_id: orderId,
},
})
@@ -15,13 +15,13 @@ export const GET = async (
is_draft_order: false,
customer_id: req.auth_context.actor_id,
},
...req.remoteQueryConfig.pagination,
...req.queryConfig.pagination,
}
const workflow = getOrdersListWorkflow(req.scope)
const { result } = await workflow.run({
input: {
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
variables,
},
})
@@ -33,7 +33,7 @@ export const POST = async (
const paymentCollection = await refetchPaymentCollection(
collectionId,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
res.status(200).json({
@@ -21,9 +21,7 @@ export const POST = async (
remoteQueryObjectFromString({
entryPoint: "cart_payment_collection",
variables: { filters: { cart_id } },
fields: req.remoteQueryConfig.fields.map(
(f) => `payment_collection.${f}`
),
fields: req.queryConfig.fields.map((f) => `payment_collection.${f}`),
})
)
let paymentCollection = cartCollectionRelation?.payment_collection
@@ -37,9 +35,7 @@ export const POST = async (
remoteQueryObjectFromString({
entryPoint: "cart_payment_collection",
variables: { filters: { cart_id } },
fields: req.remoteQueryConfig.fields.map(
(f) => `payment_collection.${f}`
),
fields: req.queryConfig.fields.map((f) => `payment_collection.${f}`),
})
)
paymentCollection = cartCollectionRelation?.payment_collection
@@ -28,9 +28,9 @@ export const GET = async (
filters: {
region_id: req.filterableFields.region_id,
},
...req.remoteQueryConfig.pagination,
...req.queryConfig.pagination,
},
fields: req.remoteQueryConfig.fields.map((f) => `payment_provider.${f}`),
fields: req.queryConfig.fields.map((f) => `payment_provider.${f}`),
})
const { rows: regionPaymentProvidersRelation, metadata } = await remoteQuery(
@@ -15,7 +15,7 @@ export const GET = async (
"product_category",
{ id: req.params.id, ...req.filterableFields },
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
if (!category) {
@@ -21,9 +21,9 @@ export const GET = async (
entryPoint: "product_category",
variables: {
filters: req.filterableFields,
...req.remoteQueryConfig.pagination,
...req.queryConfig.pagination,
},
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
})
const { rows: product_categories, metadata } = await remoteQuery(queryObject)
@@ -12,12 +12,12 @@ export const GET = async (
req: RequestWithContext<HttpTypes.StoreProductParams>,
res: MedusaResponse<HttpTypes.StoreProductResponse>
) => {
const withInventoryQuantity = req.remoteQueryConfig.fields.some((field) =>
const withInventoryQuantity = req.queryConfig.fields.some((field) =>
field.includes("variants.inventory_quantity")
)
if (withInventoryQuantity) {
req.remoteQueryConfig.fields = req.remoteQueryConfig.fields.filter(
req.queryConfig.fields = req.queryConfig.fields.filter(
(field) => !field.includes("variants.inventory_quantity")
)
}
@@ -36,7 +36,7 @@ export const GET = async (
const product = await refetchProduct(
filters,
req.scope,
req.remoteQueryConfig.fields
req.queryConfig.fields
)
if (!product) {
@@ -14,12 +14,12 @@ export const GET = async (
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
const context: object = {}
const withInventoryQuantity = req.remoteQueryConfig.fields.some((field) =>
const withInventoryQuantity = req.queryConfig.fields.some((field) =>
field.includes("variants.inventory_quantity")
)
if (withInventoryQuantity) {
req.remoteQueryConfig.fields = req.remoteQueryConfig.fields.filter(
req.queryConfig.fields = req.queryConfig.fields.filter(
(field) => !field.includes("variants.inventory_quantity")
)
}
@@ -34,10 +34,10 @@ export const GET = async (
entryPoint: "product",
variables: {
filters: req.filterableFields,
...req.remoteQueryConfig.pagination,
...req.queryConfig.pagination,
...context,
},
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
})
const { rows: products, metadata } = await remoteQuery(queryObject)
@@ -16,7 +16,7 @@ export const GET = async (
variables: {
filters: { id: req.params.id },
},
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
})
const [region] = await remoteQuery(queryObject)
@@ -15,9 +15,9 @@ export const GET = async (
entryPoint: "region",
variables: {
filters: req.filterableFields,
...req.remoteQueryConfig.pagination,
...req.queryConfig.pagination,
},
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
})
const { rows: regions, metadata } = await remoteQuery(queryObject)
@@ -17,7 +17,7 @@ export const GET = async (
const queryObject = remoteQueryObjectFromString({
entryPoint: "return_reason",
variables,
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
})
const [return_reason] = await remoteQuery(queryObject)
@@ -17,9 +17,9 @@ export const GET = async (
filters: {
...req.filterableFields,
},
...req.remoteQueryConfig.pagination,
...req.queryConfig.pagination,
},
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
})
const { rows: return_reasons, metadata } = await remoteQuery(queryObject)
@@ -20,7 +20,7 @@ export const POST = async (
const { data } = await query.graph({
entity: "shipping_option",
fields: req.remoteQueryConfig.fields,
fields: req.queryConfig.fields,
filters: { id: req.params.id },
})