From 51993b76ad1b380a26209471f92974558effa07c Mon Sep 17 00:00:00 2001 From: jerlyrosa Date: Wed, 27 Sep 2023 14:24:30 -0400 Subject: [PATCH 1/2] feat(inventory): Add support for ordering products --- src/modules/inventory/index.ts | 6 ++++-- src/queries/inventory.query.ts | 8 +++++++- src/types/inventory.ts | 5 +++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/modules/inventory/index.ts b/src/modules/inventory/index.ts index 79bb0f5a..f716aecf 100644 --- a/src/modules/inventory/index.ts +++ b/src/modules/inventory/index.ts @@ -33,6 +33,7 @@ import { AllCreatedProducts, CreatedWarehouses, CreatedAttributes, + OrderBy, } from '../../types'; export class Inventory { @@ -63,11 +64,12 @@ export class Inventory { public async getProduct( first?: number, page?: number, - whereCondition?: WhereCondition + whereCondition?: WhereCondition, + orderByCondition?: OrderBy[] ): Promise { const response = await this.client.query({ query: GET_PRODUCTS, - variables: { first, page, whereCondition }, + variables: { first, page, whereCondition, orderByCondition }, }); return response.data; diff --git a/src/queries/inventory.query.ts b/src/queries/inventory.query.ts index 08de5359..341684e4 100644 --- a/src/queries/inventory.query.ts +++ b/src/queries/inventory.query.ts @@ -5,8 +5,14 @@ export const GET_PRODUCTS = gql` $first: Int $page: Int $whereCondition: QueryProductsWhereWhereConditions + $orderByCondition: [QueryProductsOrderByOrderByClause!] ) { - products(first: $first, page: $page, where: $whereCondition) { + products( + first: $first + page: $page + where: $whereCondition + orderBy: $orderByCondition + ) { data { id products_types_id diff --git a/src/types/inventory.ts b/src/types/inventory.ts index ad94e99f..3967eced 100644 --- a/src/types/inventory.ts +++ b/src/types/inventory.ts @@ -31,6 +31,11 @@ export interface StatusInterface { name: string; } +export interface OrderBy { + column: string; + order: 'ASC' | 'DESC'; +} + export interface AttributesInterface { id: number; uuid: string; From 138800a0c016e5322b7168afc1752e793634f939 Mon Sep 17 00:00:00 2001 From: jerlyrosa Date: Wed, 27 Sep 2023 14:25:40 -0400 Subject: [PATCH 2/2] chore: update package version to 0.0.40 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 327fd0c7..12dbcac5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "version": "0.0.39", + "version": "0.0.40", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts",