Merge pull request #12735 from medusajs/fix/graph-query-operators-typing
fix: add operators to RemoteQueryFilters
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
FilterableStockLocationProps,
|
FilterableStockLocationProps,
|
||||||
|
RemoteQueryFilters,
|
||||||
StockLocationDTO,
|
StockLocationDTO,
|
||||||
UpdateStockLocationInput,
|
UpdateStockLocationInput,
|
||||||
UpsertStockLocationAddressInput,
|
UpsertStockLocationAddressInput,
|
||||||
@@ -60,7 +61,7 @@ export const updateStockLocationsWorkflow = createWorkflow(
|
|||||||
): WorkflowResponse<StockLocationDTO[]> => {
|
): WorkflowResponse<StockLocationDTO[]> => {
|
||||||
const stockLocationsQuery = useQueryGraphStep({
|
const stockLocationsQuery = useQueryGraphStep({
|
||||||
entity: "stock_location",
|
entity: "stock_location",
|
||||||
filters: input.selector,
|
filters: input.selector as RemoteQueryFilters<"stock_location">,
|
||||||
fields: ["id", "address.id"],
|
fields: ["id", "address.id"],
|
||||||
}).config({ name: "get-stock-location" })
|
}).config({ name: "get-stock-location" })
|
||||||
|
|
||||||
|
|||||||
@@ -45,10 +45,16 @@ type ExtractFiltersOperators<
|
|||||||
: never
|
: never
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RemoteQueryFilterOperators<T> = {
|
||||||
|
$or?: (T & RemoteQueryFilterOperators<T>)[]
|
||||||
|
$and?: (T & RemoteQueryFilterOperators<T>)[]
|
||||||
|
$not?: T & RemoteQueryFilterOperators<T>
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract all available filters from a remote entry point deeply
|
* Extract all available filters from a remote entry point deeply
|
||||||
*/
|
*/
|
||||||
export type RemoteQueryFilters<
|
export type InternalRemoteQueryFilters<
|
||||||
TEntry extends string,
|
TEntry extends string,
|
||||||
RemoteQueryEntryPointsLevel = RemoteQueryEntryPoints,
|
RemoteQueryEntryPointsLevel = RemoteQueryEntryPoints,
|
||||||
Exclusion extends string[] = [],
|
Exclusion extends string[] = [],
|
||||||
@@ -70,3 +76,23 @@ export type RemoteQueryFilters<
|
|||||||
>
|
>
|
||||||
: Record<string, any>
|
: Record<string, any>
|
||||||
: never
|
: never
|
||||||
|
|
||||||
|
export type RemoteQueryFilters<
|
||||||
|
TEntry extends string,
|
||||||
|
RemoteQueryEntryPointsLevel = RemoteQueryEntryPoints,
|
||||||
|
Exclusion extends string[] = [],
|
||||||
|
Lim extends number = Depth[3]
|
||||||
|
> = RemoteQueryFilterOperators<
|
||||||
|
InternalRemoteQueryFilters<
|
||||||
|
TEntry,
|
||||||
|
RemoteQueryEntryPointsLevel,
|
||||||
|
Exclusion,
|
||||||
|
Lim
|
||||||
|
>
|
||||||
|
> &
|
||||||
|
InternalRemoteQueryFilters<
|
||||||
|
TEntry,
|
||||||
|
RemoteQueryEntryPointsLevel,
|
||||||
|
Exclusion,
|
||||||
|
Lim
|
||||||
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user