chore: query graph api (#9125)
CLOSES: FRMW-2704 **What** Re-structure the Query graph API as well as introduce dynamic typing from schemas on the filters and better handling of relation treatment for fields/filters inference Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
3e97a64b21
commit
8829f89402
1157
packages/core/utils/src/modules-sdk/_remote-joiner.ts
Normal file
1157
packages/core/utils/src/modules-sdk/_remote-joiner.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
export * from "./build-query"
|
||||
export * from "./create-pg-connection"
|
||||
export * from "./decorators"
|
||||
export * from "./define-link"
|
||||
export * from "./definition"
|
||||
export * from "./event-builder-factory"
|
||||
export * from "./joiner-config-builder"
|
||||
@@ -14,4 +15,5 @@ export * from "./medusa-service"
|
||||
export * from "./migration-scripts"
|
||||
export * from "./mikro-orm-cli-config-builder"
|
||||
export * from "./module"
|
||||
export * from "./define-link"
|
||||
export * from "./query-context"
|
||||
export * from "./query-filter"
|
||||
|
||||
19
packages/core/utils/src/modules-sdk/query-context.ts
Normal file
19
packages/core/utils/src/modules-sdk/query-context.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
type QueryContextType = {
|
||||
(query: Record<string, unknown>): Record<string, unknown>
|
||||
isQueryContext: (obj: any) => boolean
|
||||
}
|
||||
|
||||
const __type = "QueryContext"
|
||||
|
||||
function QueryContextFn(query: Record<string, unknown>) {
|
||||
return {
|
||||
...query,
|
||||
__type,
|
||||
}
|
||||
}
|
||||
|
||||
QueryContextFn.isQueryContext = (obj: any) => {
|
||||
return obj.__type === __type
|
||||
}
|
||||
|
||||
export const QueryContext: QueryContextType = QueryContextFn
|
||||
18
packages/core/utils/src/modules-sdk/query-filter.ts
Normal file
18
packages/core/utils/src/modules-sdk/query-filter.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { RemoteQueryFilters } from "@medusajs/types"
|
||||
|
||||
const __type = "QueryFilter"
|
||||
|
||||
export function QueryFilterFn<TEntry extends string>(
|
||||
query: RemoteQueryFilters<TEntry>
|
||||
): RemoteQueryFilters<TEntry> & { __type: "QueryFilter" } {
|
||||
return {
|
||||
...query,
|
||||
__type,
|
||||
}
|
||||
}
|
||||
|
||||
QueryFilterFn.isQueryFilter = (obj: any) => {
|
||||
return obj.__type === __type
|
||||
}
|
||||
|
||||
export const QueryFilter = QueryFilterFn
|
||||
Reference in New Issue
Block a user