Skip to content

Commit

Permalink
Merge pull request #79 from bakaphp/feat/update-get-product
Browse files Browse the repository at this point in the history
Feat/update get product
  • Loading branch information
jerlyrosa authored Sep 27, 2023
2 parents 2c4c97a + 138800a commit 91477c2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{

"version": "0.0.39",
"version": "0.0.40",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
6 changes: 4 additions & 2 deletions src/modules/inventory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
AllCreatedProducts,
CreatedWarehouses,
CreatedAttributes,
OrderBy,
} from '../../types';

export class Inventory {
Expand Down Expand Up @@ -63,11 +64,12 @@ export class Inventory {
public async getProduct(
first?: number,
page?: number,
whereCondition?: WhereCondition
whereCondition?: WhereCondition,
orderByCondition?: OrderBy[]
): Promise<AllCreatedProducts> {
const response = await this.client.query({
query: GET_PRODUCTS,
variables: { first, page, whereCondition },
variables: { first, page, whereCondition, orderByCondition },
});

return response.data;
Expand Down
8 changes: 7 additions & 1 deletion src/queries/inventory.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/types/inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export interface StatusInterface {
name: string;
}

export interface OrderBy {
column: string;
order: 'ASC' | 'DESC';
}

export interface AttributesInterface {
id: number;
uuid: string;
Expand Down

0 comments on commit 91477c2

Please sign in to comment.