Skip to content

Commit 8df9ed8

Browse files
committed
Query generate utils fix
1 parent 4440cb6 commit 8df9ed8

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/generators/utils/generate/generate.query.utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ export const getAllQueryKeys = (endpoints: Endpoint[]): { path: string; name: st
77
const paths = endpoints.map(({ path }) => path);
88
const firstPathSegmentRegex = /^\/[^\/]*/g;
99
const queryKeys = Array.from(new Set(paths.map((path) => path.match(firstPathSegmentRegex)).flat()));
10+
const getQueryKeyName = (path: string) =>
11+
queryKeys.length === 1 ? "all" : `all${capitalize(kebabToCamel(path.replace(/\//g, "") ?? ""))}`;
1012
return queryKeys
1113
.filter((path) => path !== null)
12-
.map((path) => ({
13-
path,
14-
name: queryKeys.length === 1 ? "all" : `all${capitalize(kebabToCamel(path?.replace(/\//g, "") ?? ""))}`,
15-
}));
14+
.map((path) => ({ path, name: getQueryKeyName(path ?? "") }) as { path: string; name: string });
1615
};
1716

1817
export const getEndpointPathQueryKeys = (endpoint: Endpoint, endpoints: Endpoint[]) => {

0 commit comments

Comments
 (0)