@@ -21,12 +21,11 @@ const addKeyValuesInObject = <Entity>({
2121 relations,
2222 select,
2323 expandRelation,
24- hasCountType,
2524} : AddKeyValueInObjectProps < Entity > ) : GetInfoFromQueryProps < Entity > => {
2625 if ( stack . length ) {
2726 let stackToString = stack . join ( '.' ) ;
2827
29- if ( hasCountType ) {
28+ if ( stack . length && stack [ 0 ] === DATA ) {
3029 if ( stack [ 0 ] !== DATA || ( stack . length === 1 && stack [ 0 ] === DATA ) ) {
3130 return { relations, select } ;
3231 }
@@ -46,7 +45,6 @@ const addKeyValuesInObject = <Entity>({
4645export function getOptionFromGqlQuery < Entity > (
4746 this : Repository < Entity > ,
4847 query : string ,
49- hasCountType ?: boolean ,
5048) : GetInfoFromQueryProps < Entity > {
5149 const splitted = query . split ( '\n' ) ;
5250
@@ -65,7 +63,7 @@ export function getOptionFromGqlQuery<Entity>(
6563
6664 if ( line . includes ( '{' ) ) {
6765 stack . push ( replacedLine ) ;
68- const isFirstLineDataType = hasCountType && replacedLine === DATA ;
66+ const isFirstLineDataType = replacedLine === DATA ;
6967
7068 if ( ! isFirstLineDataType ) {
7169 lastMetadata = lastMetadata . relations . find (
@@ -78,11 +76,9 @@ export function getOptionFromGqlQuery<Entity>(
7876 relations : acc . relations ,
7977 select : acc . select ,
8078 expandRelation : true ,
81- hasCountType,
8279 } ) ;
8380 } else if ( line . includes ( '}' ) ) {
84- const hasDataTypeInStack =
85- hasCountType && stack . length && stack [ 0 ] === DATA ;
81+ const hasDataTypeInStack = stack . length && stack [ 0 ] === DATA ;
8682
8783 lastMetadata =
8884 stack . length < ( hasDataTypeInStack ? 3 : 2 )
@@ -110,7 +106,6 @@ export function getOptionFromGqlQuery<Entity>(
110106 stack : addedStack ,
111107 relations : acc . relations ,
112108 select : acc . select ,
113- hasCountType,
114109 } ) ;
115110 } ,
116111 {
@@ -120,7 +115,7 @@ export function getOptionFromGqlQuery<Entity>(
120115 ) ;
121116}
122117
123- const getCurrentGraphQLQuery = ( ctx : GqlExecutionContext ) => {
118+ export const getCurrentGraphQLQuery = ( ctx : GqlExecutionContext ) => {
124119 const { fieldName, path } = ctx . getArgByIndex ( 3 ) as {
125120 fieldName : string ;
126121 path : { key : string } ;
@@ -159,7 +154,7 @@ const getCurrentGraphQLQuery = (ctx: GqlExecutionContext) => {
159154 return stack . join ( '\n' ) ;
160155} ;
161156
162- export const GraphQLQueryToOption = < T > ( hasCountType ?: boolean ) =>
157+ export const GraphQLQueryToOption = < T > ( ) =>
163158 createParamDecorator ( ( _ : unknown , context : ExecutionContext ) => {
164159 const ctx = GqlExecutionContext . create ( context ) ;
165160 const request = ctx . getContext ( ) . req ;
@@ -175,7 +170,6 @@ export const GraphQLQueryToOption = <T>(hasCountType?: boolean) =>
175170 const queryOption : GetInfoFromQueryProps < T > = getOptionFromGqlQuery . call (
176171 repository ,
177172 query ,
178- hasCountType ,
179173 ) ;
180174
181175 return queryOption ;
0 commit comments