Skip to content

Commit eebed7d

Browse files
committed
feat: add where query to get system module
1 parent ab021b1 commit eebed7d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/modules/system-modules/index.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,33 @@ import { SystemModuleInterface } from '../../types/';
66
export class SystemModules {
77
constructor(protected client: ClientType) {}
88

9-
public async getSystemModules(): Promise<SystemModuleInterface[]> {
9+
public async getSystemModules(
10+
first: number,
11+
page?: number
12+
): Promise<SystemModuleInterface[]> {
1013
const response = await this.client.query({
1114
query: SYSTEM_MODULES_QUERY,
15+
variables: {
16+
first,
17+
page,
18+
},
19+
});
20+
return response.data.systemModels.data as SystemModuleInterface[];
21+
}
22+
23+
public async getSystemModulesUuidBySlug(
24+
slug: string
25+
): Promise<SystemModuleInterface[]> {
26+
const response = await this.client.query({
27+
query: SYSTEM_MODULES_QUERY,
28+
variables: {
29+
first: 1,
30+
where: {
31+
column: 'SLUG',
32+
operator: 'EQ',
33+
value: slug,
34+
},
35+
},
1236
});
1337
return response.data.systemModels.data as SystemModuleInterface[];
1438
}

src/queries/system-module.query.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { gql } from '@apollo/client/core';
22
export const SYSTEM_MODULES_QUERY = gql`
33
query systemModels(
44
$where: QuerySystemModelsWhereWhereConditions
5-
$orderBy: [QuerySystemModelsOrderByOrderByClause]
5+
$orderBy: [QuerySystemModelsOrderByOrderByClause!]
66
$first: Int!
77
$page: Int
88
) {
9-
systemModels {
9+
systemModels(where: $where, orderBy: $orderBy, first: $first, page: $page) {
1010
data {
1111
id
1212
uuid
@@ -29,3 +29,5 @@ export const SYSTEM_MODULES_QUERY = gql`
2929
}
3030
}
3131
`;
32+
33+

0 commit comments

Comments
 (0)