File tree Expand file tree Collapse file tree
src/generators/utils/generate Expand file tree Collapse file tree Original file line number Diff line number Diff 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
1817export const getEndpointPathQueryKeys = ( endpoint : Endpoint , endpoints : Endpoint [ ] ) => {
You can’t perform that action at this time.
0 commit comments