From c7284c846ef6c23ca5cf0b66c341908ce08d73d6 Mon Sep 17 00:00:00 2001 From: Juan M Date: Thu, 18 Apr 2024 04:07:40 -0300 Subject: [PATCH 1/2] Make OrderBy type recursive --- packages/utils/src/types/order.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/utils/src/types/order.ts b/packages/utils/src/types/order.ts index d5c25e86..bfd33a71 100644 --- a/packages/utils/src/types/order.ts +++ b/packages/utils/src/types/order.ts @@ -6,13 +6,18 @@ export enum Order { DESC = 'desc', } -export interface OrderBy { +export interface FieldOrderBy { [key: string]: Order; } +export type OrderBy = + | FieldOrderBy + | { [key: string]: FieldOrderBy } + | Array; + /** * Order by query variables. */ export interface OrderByVariables { - orderBy: OrderBy | Array; + orderBy: OrderBy; } From d5b0db06f48a695119d268a41eaec1e17839a0f1 Mon Sep 17 00:00:00 2001 From: Juan M Date: Thu, 18 Apr 2024 04:15:51 -0300 Subject: [PATCH 2/2] Return field order by in create --- packages/utils/src/queries/order.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/utils/src/queries/order.ts b/packages/utils/src/queries/order.ts index 30814bb3..956aed9f 100644 --- a/packages/utils/src/queries/order.ts +++ b/packages/utils/src/queries/order.ts @@ -1,8 +1,8 @@ -import { Order, OrderBy } from '../types/order'; +import { Order, FieldOrderBy } from '../types/order'; export function createOrderBy( key: E | undefined, value?: Order | undefined, -): OrderBy { +): FieldOrderBy { return key && value ? { [key]: value } : {}; }