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

Fixes: FRMW-2783
This commit is contained in:
Harminder Virk authored and GitHub committed 2025-01-03 08:46:23 +00:00
1 parent 54e1e70d78
commit 5e9d86d75d
200 files changed
+375 -399

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
---
"@medusajs/medusa": patch
"@medusajs/framework": patch
"@medusajs/types": patch
---
feat: deprecate remoteQueryConfig in favor of queryConfig
@@ -107,7 +107,7 @@ describe("validateAndTransformQuery", () => {
], ],
order: transformedOrder, order: transformedOrder,
}) })
expect(mockRequest.remoteQueryConfig).toEqual({ expect(mockRequest.queryConfig).toEqual({
fields: [ fields: [
"id", "id",
"created_at", "created_at",
@@ -387,7 +387,7 @@ describe("validateAndTransformQuery", () => {
], ],
}) })
) )
expect(mockRequest.remoteQueryConfig).toEqual( expect(mockRequest.queryConfig).toEqual(
expect.objectContaining({ expect.objectContaining({
fields: [ fields: [
"id", "id",
@@ -447,7 +447,7 @@ describe("validateAndTransformQuery", () => {
relations: ["store"], relations: ["store"],
}) })
) )
expect(mockRequest.remoteQueryConfig).toEqual( expect(mockRequest.queryConfig).toEqual(
expect.objectContaining({ expect.objectContaining({
fields: ["store.name", "id"], fields: ["store.name", "id"],
}) })
@@ -15,10 +15,7 @@ export function applyDefaultFilters<TFilter extends object>(
// Currently we only need it to delete filter keys from the request filter object, but this could // Currently we only need it to delete filter keys from the request filter object, but this could
// be used for other purposes. If we can't find other purposes, we can refactor to accept an array // be used for other purposes. If we can't find other purposes, we can refactor to accept an array
// of strings to delete after filters have been applied. // of strings to delete after filters have been applied.
valueToApply = filterValue( valueToApply = filterValue(req.filterableFields, req.queryConfig.fields)
req.filterableFields,
req.remoteQueryConfig.fields
)
} }
// If the value to apply is an object, we add it to any existing filters thats already applied // If the value to apply is an object, we add it to any existing filters thats already applied
+16 -5
View File
@@ -108,13 +108,20 @@ export interface MedusaRequest<
* An object containing the select, relation to be used with medusa internal services * An object containing the select, relation to be used with medusa internal services
*/ */
retrieveConfig: FindConfig<unknown> retrieveConfig: FindConfig<unknown>
/** /**
* An object containing fields and variables to be used with the remoteQuery * An object containing fields and variables to be used with the remoteQuery
*/ */
remoteQueryConfig: { queryConfig: {
fields: string[] fields: string[]
pagination: { order?: Record<string, string>; skip: number; take?: number } pagination: { order?: Record<string, string>; skip: number; take?: number }
} }
/**
* @deprecated. Instead use "req.queryConfig"
*/
remoteQueryConfig: MedusaRequest["queryConfig"]
/** /**
* An object containing the fields that are filterable e.g `{ id: Any<String> }` * An object containing the fields that are filterable e.g `{ id: Any<String> }`
*/ */
@@ -163,14 +170,18 @@ export interface PublishableKeyContext {
sales_channel_ids: string[] sales_channel_ids: string[]
} }
export interface AuthenticatedMedusaRequest<Body = unknown, QueryFields = Record<string, unknown>> export interface AuthenticatedMedusaRequest<
extends MedusaRequest<Body, QueryFields> { Body = unknown,
QueryFields = Record<string, unknown>
> extends MedusaRequest<Body, QueryFields> {
auth_context: AuthContext auth_context: AuthContext
publishable_key_context?: PublishableKeyContext publishable_key_context?: PublishableKeyContext
} }
export interface MedusaStoreRequest<Body = unknown, QueryFields = Record<string, unknown>> export interface MedusaStoreRequest<
extends MedusaRequest<Body, QueryFields> { Body = unknown,
QueryFields = Record<string, unknown>
> extends MedusaRequest<Body, QueryFields> {
auth_context?: AuthContext auth_context?: AuthContext
publishable_key_context: PublishableKeyContext publishable_key_context: PublishableKeyContext
} }
@@ -11,7 +11,7 @@ export const refetchEntities = async (
idOrFilter: string | object, idOrFilter: string | object,
scope: MedusaContainer, scope: MedusaContainer,
fields: string[], fields: string[],
pagination?: MedusaRequest["remoteQueryConfig"]["pagination"] pagination?: MedusaRequest["queryConfig"]["pagination"]
) => { ) => {
const remoteQuery = scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) const remoteQuery = scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
const filters = isString(idOrFilter) ? { id: idOrFilter } : idOrFilter const filters = isString(idOrFilter) ? { id: idOrFilter } : idOrFilter
@@ -90,7 +90,8 @@ export function validateAndTransformQuery<TEntity extends BaseEntity>(
req.validatedQuery = validated req.validatedQuery = validated
req.filterableFields = getFilterableFields(req.validatedQuery) req.filterableFields = getFilterableFields(req.validatedQuery)
req.remoteQueryConfig = cnf.remoteQueryConfig as any req.queryConfig = cnf.remoteQueryConfig as any
req.remoteQueryConfig = req.queryConfig
req.listConfig = (cnf as any).listConfig req.listConfig = (cnf as any).listConfig
req.retrieveConfig = (cnf as any).retrieveConfig req.retrieveConfig = (cnf as any).retrieveConfig
+1 -1
View File
@@ -443,7 +443,7 @@ export type QueryConfig<TEntity> = {
defaultLimit?: number defaultLimit?: number
/** /**
* If the route that will use that configuration is supposed to return a list of entities. This * If the route that will use that configuration is supposed to return a list of entities. This
* will change the configuration that will be created on req.listConfig and req.remoteQueryConfig (among * will change the configuration that will be created on req.listConfig and req.queryConfig (among
* other things it will include pagination and sorting) * other things it will include pagination and sorting)
*/ */
isList?: boolean isList?: boolean
@@ -24,7 +24,7 @@ export const POST = async (
const apiKey = await refetchApiKey( const apiKey = await refetchApiKey(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ api_key: apiKey }) res.status(200).json({ api_key: apiKey })
@@ -19,7 +19,7 @@ export const GET = async (
const apiKey = await refetchApiKey( const apiKey = await refetchApiKey(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
if (!apiKey) { if (!apiKey) {
@@ -46,7 +46,7 @@ export const POST = async (
const apiKey = await refetchApiKey( const apiKey = await refetchApiKey(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ api_key: apiKey }) res.status(200).json({ api_key: apiKey })
@@ -32,7 +32,7 @@ export const POST = async (
const updatedApiKey = await refetchApiKey( const updatedApiKey = await refetchApiKey(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ api_key: updatedApiKey }) res.status(200).json({ api_key: updatedApiKey })
@@ -20,9 +20,9 @@ export const GET = async (
entryPoint: "api_key", entryPoint: "api_key",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: apiKeys, metadata } = await remoteQuery(queryObject) const { rows: apiKeys, metadata } = await remoteQuery(queryObject)
@@ -20,7 +20,7 @@ export const POST = async (
const campaign = await refetchCampaign( const campaign = await refetchCampaign(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ campaign }) res.status(200).json({ campaign })
@@ -19,7 +19,7 @@ export const GET = async (
const campaign = await refetchCampaign( const campaign = await refetchCampaign(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
if (!campaign) { if (!campaign) {
@@ -62,7 +62,7 @@ export const POST = async (
const campaign = await refetchCampaign( const campaign = await refetchCampaign(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ campaign }) res.status(200).json({ campaign })
} }
@@ -21,9 +21,9 @@ export const GET = async (
entryPoint: "campaign", entryPoint: "campaign",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: campaigns, metadata } = await remoteQuery(query) const { rows: campaigns, metadata } = await remoteQuery(query)
@@ -54,7 +54,7 @@ export const POST = async (
const campaign = await refetchCampaign( const campaign = await refetchCampaign(
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ campaign }) res.status(200).json({ campaign })
@@ -37,7 +37,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderClaim] = await remoteQuery(queryObject) const [orderClaim] = await remoteQuery(queryObject)
@@ -73,7 +73,7 @@ export const DELETE = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderClaim] = await remoteQuery(queryObject) const [orderClaim] = await remoteQuery(queryObject)
@@ -30,7 +30,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderClaim] = await remoteQuery(queryObject) const [orderClaim] = await remoteQuery(queryObject)
@@ -51,7 +51,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderClaim] = await remoteQuery(queryObject) const [orderClaim] = await remoteQuery(queryObject)
@@ -37,7 +37,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderClaim] = await remoteQuery(queryObject) const [orderClaim] = await remoteQuery(queryObject)
@@ -72,7 +72,7 @@ export const DELETE = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderClaim] = await remoteQuery(queryObject) const [orderClaim] = await remoteQuery(queryObject)
@@ -31,7 +31,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderClaim] = await remoteQuery(queryObject) const [orderClaim] = await remoteQuery(queryObject)
@@ -37,7 +37,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderClaim] = await remoteQuery(queryObject) const [orderClaim] = await remoteQuery(queryObject)
@@ -73,7 +73,7 @@ export const DELETE = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderClaim] = await remoteQuery(queryObject) const [orderClaim] = await remoteQuery(queryObject)
@@ -30,7 +30,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderClaim] = await remoteQuery(queryObject) const [orderClaim] = await remoteQuery(queryObject)
@@ -36,7 +36,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderClaim] = await remoteQuery(queryObject, { const [orderClaim] = await remoteQuery(queryObject, {
@@ -14,7 +14,7 @@ export const GET = async (
"order_claim", "order_claim",
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
if (!claim) { if (!claim) {
@@ -24,9 +24,9 @@ export const GET = async (
filters: { filters: {
...req.filterableFields, ...req.filterableFields,
}, },
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: claims, metadata } = await remoteQuery(queryObject) const { rows: claims, metadata } = await remoteQuery(queryObject)
@@ -64,7 +64,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [order, orderClaim] = await promiseAll([ const [order, orderClaim] = await promiseAll([
@@ -25,7 +25,7 @@ export const POST = async (
const collection = await refetchCollection( const collection = await refetchCollection(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ res.status(200).json({
@@ -19,7 +19,7 @@ export const GET = async (
const collection = await refetchCollection( const collection = await refetchCollection(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ collection }) res.status(200).json({ collection })
@@ -49,7 +49,7 @@ export const POST = async (
const collection = await refetchCollection( const collection = await refetchCollection(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ collection }) res.status(200).json({ collection })
@@ -22,9 +22,9 @@ export const GET = async (
entryPoint: "product_collection", entryPoint: "product_collection",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: collections, metadata } = await remoteQuery(query) const { rows: collections, metadata } = await remoteQuery(query)
@@ -54,7 +54,7 @@ export const POST = async (
const collection = await refetchCollection( const collection = await refetchCollection(
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ collection }) res.status(200).json({ collection })
@@ -17,7 +17,7 @@ export const GET = async (
const queryObject = remoteQueryObjectFromString({ const queryObject = remoteQueryObjectFromString({
entryPoint: "currency", entryPoint: "currency",
variables, variables,
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [currency] = await remoteQuery(queryObject) const [currency] = await remoteQuery(queryObject)
@@ -15,9 +15,9 @@ export const GET = async (
entryPoint: "currency", entryPoint: "currency",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: currencies, metadata } = await remoteQuery(queryObject) const { rows: currencies, metadata } = await remoteQuery(queryObject)
@@ -26,7 +26,7 @@ export const POST = async (
const customerGroup = await refetchCustomerGroup( const customerGroup = await refetchCustomerGroup(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ customer_group: customerGroup }) res.status(200).json({ customer_group: customerGroup })
} }
@@ -19,7 +19,7 @@ export const GET = async (
const customerGroup = await refetchCustomerGroup( const customerGroup = await refetchCustomerGroup(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
if (!customerGroup) { if (!customerGroup) {
@@ -58,7 +58,7 @@ export const POST = async (
const customerGroup = await refetchCustomerGroup( const customerGroup = await refetchCustomerGroup(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ customer_group: customerGroup }) res.status(200).json({ customer_group: customerGroup })
} }
@@ -21,9 +21,9 @@ export const GET = async (
entryPoint: "customer_group", entryPoint: "customer_group",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: customer_groups, metadata } = await remoteQuery(query) const { rows: customer_groups, metadata } = await remoteQuery(query)
@@ -55,7 +55,7 @@ export const POST = async (
const customerGroup = await refetchCustomerGroup( const customerGroup = await refetchCustomerGroup(
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ customer_group: customerGroup }) res.status(200).json({ customer_group: customerGroup })
@@ -25,7 +25,7 @@ export const GET = async (
variables: { variables: {
filters: { id: req.params.address_id, customer_id: req.params.id }, filters: { id: req.params.address_id, customer_id: req.params.id },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [address] = await remoteQuery(queryObject) const [address] = await remoteQuery(queryObject)
@@ -53,7 +53,7 @@ export const POST = async (
const customer = await refetchCustomer( const customer = await refetchCustomer(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ customer }) res.status(200).json({ customer })
@@ -73,7 +73,7 @@ export const DELETE = async (
const customer = await refetchCustomer( const customer = await refetchCustomer(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ res.status(200).json({
@@ -22,9 +22,9 @@ export const GET = async (
entryPoint: "customer_address", entryPoint: "customer_address",
variables: { variables: {
filters: { ...req.filterableFields, customer_id: customerId }, 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(query) const { rows: addresses, metadata } = await remoteQuery(query)
@@ -60,7 +60,7 @@ export const POST = async (
const customer = await refetchCustomer( const customer = await refetchCustomer(
customerId, customerId,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ customer }) res.status(200).json({ customer })
@@ -24,11 +24,7 @@ export const POST = async (
}, },
}) })
const customer = await refetchCustomer( const customer = await refetchCustomer(id, req.scope, req.queryConfig.fields)
id,
req.scope,
req.remoteQueryConfig.fields
)
res.status(200).json({ customer: customer }) res.status(200).json({ customer: customer })
} }
@@ -18,7 +18,7 @@ export const GET = async (
const customer = await refetchCustomer( const customer = await refetchCustomer(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
if (!customer) { if (!customer) {
@@ -58,7 +58,7 @@ export const POST = async (
const customer = await refetchCustomer( const customer = await refetchCustomer(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ customer }) res.status(200).json({ customer })
} }
@@ -22,9 +22,9 @@ export const GET = async (
entryPoint: "customers", entryPoint: "customers",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: customers, metadata } = await remoteQuery(query) const { rows: customers, metadata } = await remoteQuery(query)
@@ -58,7 +58,7 @@ export const POST = async (
const customer = await refetchCustomer( const customer = await refetchCustomer(
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ customer }) res.status(200).json({ customer })
@@ -30,9 +30,9 @@ export const GET = async (
...req.filterableFields, ...req.filterableFields,
is_draft_order: true, is_draft_order: true,
}, },
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: draft_orders, metadata } = await remoteQuery(queryObject) const { rows: draft_orders, metadata } = await remoteQuery(queryObject)
@@ -90,7 +90,7 @@ export const POST = async (
const draftOrder = await refetchOrder( const draftOrder = await refetchOrder(
result.id, result.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ draft_order: draftOrder }) res.status(200).json({ draft_order: draftOrder })
@@ -51,7 +51,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderExchange] = await remoteQuery(queryObject) const [orderExchange] = await remoteQuery(queryObject)
@@ -37,7 +37,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderExchange] = await remoteQuery(queryObject) const [orderExchange] = await remoteQuery(queryObject)
@@ -73,7 +73,7 @@ export const DELETE = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderExchange] = await remoteQuery(queryObject) const [orderExchange] = await remoteQuery(queryObject)
@@ -31,7 +31,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderExchange] = await remoteQuery(queryObject) const [orderExchange] = await remoteQuery(queryObject)
@@ -37,7 +37,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderExchange] = await remoteQuery(queryObject) const [orderExchange] = await remoteQuery(queryObject)
@@ -73,7 +73,7 @@ export const DELETE = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderExchange] = await remoteQuery(queryObject) const [orderExchange] = await remoteQuery(queryObject)
@@ -30,7 +30,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderExchange] = await remoteQuery(queryObject) const [orderExchange] = await remoteQuery(queryObject)
@@ -36,7 +36,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [orderExchange] = await remoteQuery(queryObject, { const [orderExchange] = await remoteQuery(queryObject, {
@@ -14,7 +14,7 @@ export const GET = async (
"order_exchange", "order_exchange",
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
if (!exchange) { if (!exchange) {
@@ -24,9 +24,9 @@ export const GET = async (
filters: { filters: {
...req.filterableFields, ...req.filterableFields,
}, },
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: exchanges, metadata } = await remoteQuery(queryObject) const { rows: exchanges, metadata } = await remoteQuery(queryObject)
@@ -64,7 +64,7 @@ export const POST = async (
...req.filterableFields, ...req.filterableFields,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [order, orderExchange] = await promiseAll([ const [order, orderExchange] = await promiseAll([
@@ -17,9 +17,9 @@ export const GET = async (
entryPoint: "fulfillment_provider", entryPoint: "fulfillment_provider",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: fulfillment_providers, metadata } = await remoteQuery( const { rows: fulfillment_providers, metadata } = await remoteQuery(
@@ -33,7 +33,7 @@ export const GET = async (
variables: { variables: {
id: req.params.zone_id, id: req.params.zone_id,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
) )
@@ -85,7 +85,7 @@ export const POST = async (
variables: { variables: {
id: req.params.id, id: req.params.id,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
) )
@@ -25,7 +25,7 @@ export const POST = async (
const fulfillmentSet = await refetchFulfillmentSet( const fulfillmentSet = await refetchFulfillmentSet(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ fulfillment_set: fulfillmentSet }) res.status(200).json({ fulfillment_set: fulfillmentSet })
@@ -18,7 +18,7 @@ export const POST = async (
const fulfillment = await refetchFulfillment( const fulfillment = await refetchFulfillment(
id, id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ fulfillment }) res.status(200).json({ fulfillment })
@@ -24,7 +24,7 @@ export const POST = async (
const fulfillment = await refetchFulfillment( const fulfillment = await refetchFulfillment(
id, id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ fulfillment }) res.status(200).json({ fulfillment })
@@ -23,7 +23,7 @@ export const POST = async (
const fulfillment = await refetchFulfillment( const fulfillment = await refetchFulfillment(
fullfillment.id, fullfillment.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ fulfillment }) res.status(200).json({ fulfillment })
@@ -52,7 +52,7 @@ export const DELETE = async (
const inventoryItem = await refetchInventoryItem( const inventoryItem = await refetchInventoryItem(
id, id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ res.status(200).json({
@@ -77,7 +77,7 @@ export const POST = async (
const inventoryItem = await refetchInventoryItem( const inventoryItem = await refetchInventoryItem(
id, id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ res.status(200).json({
@@ -33,7 +33,7 @@ export const POST = async (
const inventoryItem = await refetchInventoryItem( const inventoryItem = await refetchInventoryItem(
id, id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ inventory_item: inventoryItem }) res.status(200).json({ inventory_item: inventoryItem })
} }
@@ -50,9 +50,9 @@ export const GET = async (
entryPoint: "inventory_levels", entryPoint: "inventory_levels",
variables: { variables: {
filters: { ...req.filterableFields, inventory_item_id: id }, filters: { ...req.filterableFields, inventory_item_id: id },
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: inventory_levels, metadata } = await remoteQuery(query) const { rows: inventory_levels, metadata } = await remoteQuery(query)
@@ -19,7 +19,7 @@ export const GET = async (
const inventoryItem = await refetchInventoryItem( const inventoryItem = await refetchInventoryItem(
id, id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
if (!inventoryItem) { if (!inventoryItem) {
throw new MedusaError( throw new MedusaError(
@@ -49,7 +49,7 @@ export const POST = async (
const inventoryItem = await refetchInventoryItem( const inventoryItem = await refetchInventoryItem(
id, id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ res.status(200).json({
@@ -22,7 +22,7 @@ export const POST = async (
const inventoryItem = await refetchInventoryItem( const inventoryItem = await refetchInventoryItem(
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ inventory_item: inventoryItem }) res.status(200).json({ inventory_item: inventoryItem })
@@ -38,9 +38,9 @@ export const GET = async (
entryPoint: "inventory_items", entryPoint: "inventory_items",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: inventory_items, metadata } = await remoteQuery({ const { rows: inventory_items, metadata } = await remoteQuery({
@@ -18,7 +18,7 @@ export const POST = async (
const invite = await refetchInvite( const invite = await refetchInvite(
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ invite }) res.status(200).json({ invite })
@@ -13,11 +13,7 @@ export const GET = async (
res: MedusaResponse<HttpTypes.AdminInviteResponse> res: MedusaResponse<HttpTypes.AdminInviteResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
const invite = await refetchInvite( const invite = await refetchInvite(id, req.scope, req.queryConfig.fields)
id,
req.scope,
req.remoteQueryConfig.fields
)
if (!invite) { if (!invite) {
throw new MedusaError( throw new MedusaError(
@@ -20,9 +20,9 @@ export const GET = async (
entryPoint: "invite", entryPoint: "invite",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: invites, metadata } = await remoteQuery(queryObject) const { rows: invites, metadata } = await remoteQuery(queryObject)
@@ -52,7 +52,7 @@ export const POST = async (
const invite = await refetchInvite( const invite = await refetchInvite(
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ invite }) res.status(200).json({ invite })
@@ -14,7 +14,7 @@ export const GET = async (
"notification", "notification",
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ notification }) res.status(200).json({ notification })
} }
@@ -13,8 +13,8 @@ export const GET = async (
"notification", "notification",
req.filterableFields, req.filterableFields,
req.scope, req.scope,
req.remoteQueryConfig.fields, req.queryConfig.fields,
req.remoteQueryConfig.pagination req.queryConfig.pagination
) )
res.json({ res.json({
@@ -23,7 +23,7 @@ export const POST = async (
const queryObject = remoteQueryObjectFromString({ const queryObject = remoteQueryObjectFromString({
entryPoint: "order", entryPoint: "order",
variables: { id }, variables: { id },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [order] = await remoteQuery(queryObject) const [order] = await remoteQuery(queryObject)
@@ -29,7 +29,7 @@ export const POST = async (
const queryObject = remoteQueryObjectFromString({ const queryObject = remoteQueryObjectFromString({
entryPoint: "order", entryPoint: "order",
variables, variables,
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [order] = await remoteQuery(queryObject) const [order] = await remoteQuery(queryObject)
@@ -23,7 +23,7 @@ export const GET = async (
order_id: id, order_id: id,
}, },
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const order_changes = await remoteQuery(queryObject) const order_changes = await remoteQuery(queryObject)
@@ -26,7 +26,7 @@ export const POST = async (
const queryObject = remoteQueryObjectFromString({ const queryObject = remoteQueryObjectFromString({
entryPoint: "order", entryPoint: "order",
variables: { id }, variables: { id },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [order] = await remoteQuery(queryObject) const [order] = await remoteQuery(queryObject)
@@ -34,7 +34,7 @@ export const POST = async (
const queryObject = remoteQueryObjectFromString({ const queryObject = remoteQueryObjectFromString({
entryPoint: "order", entryPoint: "order",
variables, variables,
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [order] = await remoteQuery(queryObject) const [order] = await remoteQuery(queryObject)
@@ -20,7 +20,7 @@ export const POST = async (
"order", "order",
orderId, orderId,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ order }) res.status(200).json({ order })
@@ -34,7 +34,7 @@ export const POST = async (
const queryObject = remoteQueryObjectFromString({ const queryObject = remoteQueryObjectFromString({
entryPoint: "order", entryPoint: "order",
variables, variables,
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [order] = await remoteQuery(queryObject) const [order] = await remoteQuery(queryObject)
@@ -28,7 +28,7 @@ export const POST = async (
const queryObject = remoteQueryObjectFromString({ const queryObject = remoteQueryObjectFromString({
entryPoint: "order", entryPoint: "order",
variables: { id: req.params.id }, variables: { id: req.params.id },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [order] = await remoteQuery(queryObject) const [order] = await remoteQuery(queryObject)
@@ -22,9 +22,7 @@ export const GET = async (
...req.filterableFields, ...req.filterableFields,
order_id: id, order_id: id,
}, },
fields: deduplicate( fields: deduplicate(req.queryConfig.fields.concat(["item_id", "version"])),
req.remoteQueryConfig.fields.concat(["item_id", "version"])
),
}) })
const data = result.data const data = result.data
@@ -20,7 +20,7 @@ export const GET = async (
const workflow = getOrderDetailWorkflow(req.scope) const workflow = getOrderDetailWorkflow(req.scope)
const { result } = await workflow.run({ const { result } = await workflow.run({
input: { input: {
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
order_id: req.params.id, order_id: req.params.id,
version: req.validatedQuery.version as number, version: req.validatedQuery.version as number,
}, },
@@ -46,7 +46,7 @@ export const POST = async (
const result = await query.graph({ const result = await query.graph({
entity: "order", entity: "order",
filters: { id: req.params.id }, filters: { id: req.params.id },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
res.status(200).json({ order: result.data[0] as AdminOrder }) res.status(200).json({ order: result.data[0] as AdminOrder })
@@ -26,7 +26,7 @@ export const POST = async (
const result = await query.graph({ const result = await query.graph({
entity: "order", entity: "order",
filters: { id: orderId }, filters: { id: orderId },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
res.status(200).json({ order: result.data[0] as AdminOrder }) res.status(200).json({ order: result.data[0] as AdminOrder })
@@ -31,7 +31,7 @@ export const POST = async (
const queryObject = remoteQueryObjectFromString({ const queryObject = remoteQueryObjectFromString({
entryPoint: "order", entryPoint: "order",
variables, variables,
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const [order] = await remoteQuery(queryObject) const [order] = await remoteQuery(queryObject)
@@ -14,13 +14,13 @@ export const GET = async (
...req.filterableFields, ...req.filterableFields,
is_draft_order: false, is_draft_order: false,
}, },
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
} }
const workflow = getOrdersListWorkflow(req.scope) const workflow = getOrdersListWorkflow(req.scope)
const { result } = await workflow.run({ const { result } = await workflow.run({
input: { input: {
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
variables, variables,
}, },
}) })
@@ -25,7 +25,7 @@ export const POST = async (
"payment_collection", "payment_collection",
id, id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ payment_collection: paymentCollection }) res.status(200).json({ payment_collection: paymentCollection })
@@ -19,7 +19,7 @@ export const POST = async (
"payment_collection", "payment_collection",
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ payment_collection: paymentCollection }) res.status(200).json({ payment_collection: paymentCollection })
@@ -21,11 +21,7 @@ export const POST = async (
}, },
}) })
const payment = await refetchPayment( const payment = await refetchPayment(id, req.scope, req.queryConfig.fields)
id,
req.scope,
req.remoteQueryConfig.fields
)
res.status(200).json({ payment }) res.status(200).json({ payment })
} }
@@ -20,11 +20,7 @@ export const POST = async (
}, },
}) })
const payment = await refetchPayment( const payment = await refetchPayment(id, req.scope, req.queryConfig.fields)
id,
req.scope,
req.remoteQueryConfig.fields
)
res.status(200).json({ payment }) res.status(200).json({ payment })
} }
@@ -13,7 +13,7 @@ export const GET = async (
const payment = await refetchPayment( const payment = await refetchPayment(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ payment }) res.status(200).json({ payment })
@@ -17,9 +17,9 @@ export const GET = async (
entryPoint: "payment_provider", entryPoint: "payment_provider",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: payment_providers, metadata } = await remoteQuery(queryObject) const { rows: payment_providers, metadata } = await remoteQuery(queryObject)
@@ -17,9 +17,9 @@ export const GET = async (
entryPoint: "payment", entryPoint: "payment",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: payments, metadata } = await remoteQuery(queryObject) const { rows: payments, metadata } = await remoteQuery(queryObject)
@@ -39,11 +39,7 @@ export const POST = async (
}, },
}) })
const priceList = await fetchPriceList( const priceList = await fetchPriceList(id, req.scope, req.queryConfig.fields)
id,
req.scope,
req.remoteQueryConfig.fields
)
res.status(200).json({ price_list: priceList }) res.status(200).json({ price_list: priceList })
} }
@@ -17,7 +17,7 @@ export const GET = async (
const price_list = await fetchPriceList( const price_list = await fetchPriceList(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ price_list }) res.status(200).json({ price_list })
@@ -34,11 +34,7 @@ export const POST = async (
input: { price_lists_data: [{ ...req.validatedBody, id }] }, input: { price_lists_data: [{ ...req.validatedBody, id }] },
}) })
const price_list = await fetchPriceList( const price_list = await fetchPriceList(id, req.scope, req.queryConfig.fields)
id,
req.scope,
req.remoteQueryConfig.fields
)
res.status(200).json({ price_list }) res.status(200).json({ price_list })
} }
@@ -21,9 +21,9 @@ export const GET = async (
entryPoint: "price_list", entryPoint: "price_list",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: priceLists, metadata } = await remoteQuery(queryObject) const { rows: priceLists, metadata } = await remoteQuery(queryObject)
@@ -48,7 +48,7 @@ export const POST = async (
const price_list = await fetchPriceList( const price_list = await fetchPriceList(
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ price_list }) res.status(200).json({ price_list })
@@ -18,7 +18,7 @@ export const GET = async (
"price_preference", "price_preference",
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ price_preference }) res.status(200).json({ price_preference })
@@ -39,7 +39,7 @@ export const POST = async (
"price_preference", "price_preference",
id, id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ price_preference }) res.status(200).json({ price_preference })
@@ -15,8 +15,8 @@ export const GET = async (
"price_preference", "price_preference",
req.filterableFields, req.filterableFields,
req.scope, req.scope,
req.remoteQueryConfig.fields, req.queryConfig.fields,
req.remoteQueryConfig.pagination req.queryConfig.pagination
) )
res.json({ res.json({
price_preferences: price_preferences, price_preferences: price_preferences,
@@ -39,7 +39,7 @@ export const POST = async (
"price_preference", "price_preference",
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ price_preference }) res.status(200).json({ price_preference })
@@ -23,7 +23,7 @@ export const POST = async (
"product_category", "product_category",
id, id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ product_category: category }) res.status(200).json({ product_category: category })
@@ -25,7 +25,7 @@ export const GET = async (
"product_category", "product_category",
{ id: req.params.id, ...req.filterableFields }, { id: req.params.id, ...req.filterableFields },
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
if (!category) { if (!category) {
@@ -52,7 +52,7 @@ export const POST = async (
"product_category", "product_category",
{ id, ...req.filterableFields }, { id, ...req.filterableFields },
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ product_category: category }) res.status(200).json({ product_category: category })
@@ -14,8 +14,8 @@ export const GET = async (
"product_category", "product_category",
req.filterableFields, req.filterableFields,
req.scope, req.scope,
req.remoteQueryConfig.fields, req.queryConfig.fields,
req.remoteQueryConfig.pagination req.queryConfig.pagination
) )
res.json({ res.json({
@@ -38,7 +38,7 @@ export const POST = async (
"product_category", "product_category",
{ id: result[0].id, ...req.filterableFields }, { id: result[0].id, ...req.filterableFields },
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ product_category: category }) res.status(200).json({ product_category: category })
@@ -23,7 +23,7 @@ export const GET = async (
"product_tag", "product_tag",
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ product_tag: productTag }) res.status(200).json({ product_tag: productTag })
@@ -58,7 +58,7 @@ export const POST = async (
"product_tag", "product_tag",
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ product_tag: productTag }) res.status(200).json({ product_tag: productTag })
@@ -16,8 +16,8 @@ export const GET = async (
"product_tag", "product_tag",
req.filterableFields, req.filterableFields,
req.scope, req.scope,
req.remoteQueryConfig.fields, req.queryConfig.fields,
req.remoteQueryConfig.pagination req.queryConfig.pagination
) )
res.json({ res.json({
@@ -42,7 +42,7 @@ export const POST = async (
"product_tag", "product_tag",
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ product_tag: productTag }) res.status(200).json({ product_tag: productTag })
@@ -22,7 +22,7 @@ export const GET = async (
const productType = await refetchProductType( const productType = await refetchProductType(
req.params.id, req.params.id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ product_type: productType }) res.status(200).json({ product_type: productType })
@@ -55,7 +55,7 @@ export const POST = async (
const productType = await refetchProductType( const productType = await refetchProductType(
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ product_type: productType }) res.status(200).json({ product_type: productType })
@@ -20,9 +20,9 @@ export const GET = async (
entryPoint: "product_type", entryPoint: "product_type",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
...req.remoteQueryConfig.pagination, ...req.queryConfig.pagination,
}, },
fields: req.remoteQueryConfig.fields, fields: req.queryConfig.fields,
}) })
const { rows: product_types, metadata } = await remoteQuery(queryObject) const { rows: product_types, metadata } = await remoteQuery(queryObject)
@@ -48,7 +48,7 @@ export const POST = async (
const productType = await refetchProductType( const productType = await refetchProductType(
result[0].id, result[0].id,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ product_type: productType }) res.status(200).json({ product_type: productType })
@@ -11,12 +11,12 @@ export const GET = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminProductVariantParams>, req: AuthenticatedMedusaRequest<HttpTypes.AdminProductVariantParams>,
res: MedusaResponse<HttpTypes.AdminProductVariantListResponse> res: MedusaResponse<HttpTypes.AdminProductVariantListResponse>
) => { ) => {
const withInventoryQuantity = req.remoteQueryConfig.fields.some((field) => const withInventoryQuantity = req.queryConfig.fields.some((field) =>
field.includes("inventory_quantity") field.includes("inventory_quantity")
) )
if (withInventoryQuantity) { if (withInventoryQuantity) {
req.remoteQueryConfig.fields = req.remoteQueryConfig.fields.filter( req.queryConfig.fields = req.queryConfig.fields.filter(
(field) => !field.includes("inventory_quantity") (field) => !field.includes("inventory_quantity")
) )
} }
@@ -25,8 +25,8 @@ export const GET = async (
"variant", "variant",
{ ...req.filterableFields }, { ...req.filterableFields },
req.scope, req.scope,
remapKeysForVariant(req.remoteQueryConfig.fields ?? []), remapKeysForVariant(req.queryConfig.fields ?? []),
req.remoteQueryConfig.pagination req.queryConfig.pagination
) )
if (withInventoryQuantity) { if (withInventoryQuantity) {
@@ -21,7 +21,7 @@ export const GET = async (
"product_option", "product_option",
{ id: optionId, product_id: productId }, { id: optionId, product_id: productId },
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ product_option: productOption }) res.status(200).json({ product_option: productOption })
@@ -49,7 +49,7 @@ export const POST = async (
"product", "product",
productId, productId,
req.scope, req.scope,
remapKeysForProduct(req.remoteQueryConfig.fields ?? []) remapKeysForProduct(req.queryConfig.fields ?? [])
) )
res.status(200).json({ product: remapProductResponse(product) }) res.status(200).json({ product: remapProductResponse(product) })
@@ -71,7 +71,7 @@ export const DELETE = async (
"product", "product",
productId, productId,
req.scope, req.scope,
remapKeysForProduct(req.remoteQueryConfig.fields ?? []) remapKeysForProduct(req.queryConfig.fields ?? [])
) )
res.status(200).json({ res.status(200).json({
@@ -18,8 +18,8 @@ export const GET = async (
"product_option", "product_option",
{ ...req.filterableFields, product_id: productId }, { ...req.filterableFields, product_id: productId },
req.scope, req.scope,
req.remoteQueryConfig.fields, req.queryConfig.fields,
req.remoteQueryConfig.pagination req.queryConfig.pagination
) )
res.json({ res.json({
@@ -55,7 +55,7 @@ export const POST = async (
"product", "product",
productId, productId,
req.scope, req.scope,
remapKeysForProduct(req.remoteQueryConfig.fields ?? []) remapKeysForProduct(req.queryConfig.fields ?? [])
) )
res.status(200).json({ product: remapProductResponse(product) }) res.status(200).json({ product: remapProductResponse(product) })
} }
@@ -15,7 +15,7 @@ export const GET = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest,
res: MedusaResponse<HttpTypes.AdminProductResponse> res: MedusaResponse<HttpTypes.AdminProductResponse>
) => { ) => {
const selectFields = remapKeysForProduct(req.remoteQueryConfig.fields ?? []) const selectFields = remapKeysForProduct(req.queryConfig.fields ?? [])
const product = await refetchEntity( const product = await refetchEntity(
"product", "product",
req.params.id, req.params.id,
@@ -66,7 +66,7 @@ export const POST = async (
"product", "product",
result[0].id, result[0].id,
req.scope, req.scope,
remapKeysForProduct(req.remoteQueryConfig.fields ?? []) remapKeysForProduct(req.queryConfig.fields ?? [])
) )
res.status(200).json({ product: remapProductResponse(product) }) res.status(200).json({ product: remapProductResponse(product) })
@@ -28,7 +28,7 @@ export const POST = async (
const variant = await refetchVariant( const variant = await refetchVariant(
variantId, variantId,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ variant }) res.status(200).json({ variant })
@@ -55,7 +55,7 @@ export const DELETE = async (
const parent = await refetchVariant( const parent = await refetchVariant(
variantId, variantId,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ res.status(200).json({
@@ -29,7 +29,7 @@ export const POST = async (
const variant = await refetchVariant( const variant = await refetchVariant(
variantId, variantId,
req.scope, req.scope,
req.remoteQueryConfig.fields req.queryConfig.fields
) )
res.status(200).json({ variant }) res.status(200).json({ variant })
@@ -28,7 +28,7 @@ export const GET = async (
"variant", "variant",
variables, variables,
req.scope, req.scope,
remapKeysForVariant(req.remoteQueryConfig.fields ?? []) remapKeysForVariant(req.queryConfig.fields ?? [])
) )
res.status(200).json({ variant: remapVariantResponse(variant) }) res.status(200).json({ variant: remapVariantResponse(variant) })
@@ -56,7 +56,7 @@ export const POST = async (
"product", "product",
productId, productId,
req.scope, req.scope,
remapKeysForProduct(req.remoteQueryConfig.fields ?? []) remapKeysForProduct(req.queryConfig.fields ?? [])
) )
res.status(200).json({ product: remapProductResponse(product) }) res.status(200).json({ product: remapProductResponse(product) })
@@ -78,7 +78,7 @@ export const DELETE = async (
"product", "product",
productId, productId,
req.scope, req.scope,
remapKeysForProduct(req.remoteQueryConfig.fields ?? []) remapKeysForProduct(req.queryConfig.fields ?? [])
) )
res.status(200).json({ res.status(200).json({
Loaded 100 of 200 files, more files were not shown because too many files have changed in this diff. Show more