@@ -21,12 +21,11 @@ const addKeyValuesInObject = <Entity>({
21
21
relations,
22
22
select,
23
23
expandRelation,
24
- hasCountType,
25
24
} : AddKeyValueInObjectProps < Entity > ) : GetInfoFromQueryProps < Entity > => {
26
25
if ( stack . length ) {
27
26
let stackToString = stack . join ( '.' ) ;
28
27
29
- if ( hasCountType ) {
28
+ if ( stack . length && stack [ 0 ] === DATA ) {
30
29
if ( stack [ 0 ] !== DATA || ( stack . length === 1 && stack [ 0 ] === DATA ) ) {
31
30
return { relations, select } ;
32
31
}
@@ -46,7 +45,6 @@ const addKeyValuesInObject = <Entity>({
46
45
export function getOptionFromGqlQuery < Entity > (
47
46
this : Repository < Entity > ,
48
47
query : string ,
49
- hasCountType ?: boolean ,
50
48
) : GetInfoFromQueryProps < Entity > {
51
49
const splitted = query . split ( '\n' ) ;
52
50
@@ -65,7 +63,7 @@ export function getOptionFromGqlQuery<Entity>(
65
63
66
64
if ( line . includes ( '{' ) ) {
67
65
stack . push ( replacedLine ) ;
68
- const isFirstLineDataType = hasCountType && replacedLine === DATA ;
66
+ const isFirstLineDataType = replacedLine === DATA ;
69
67
70
68
if ( ! isFirstLineDataType ) {
71
69
lastMetadata = lastMetadata . relations . find (
@@ -78,11 +76,9 @@ export function getOptionFromGqlQuery<Entity>(
78
76
relations : acc . relations ,
79
77
select : acc . select ,
80
78
expandRelation : true ,
81
- hasCountType,
82
79
} ) ;
83
80
} else if ( line . includes ( '}' ) ) {
84
- const hasDataTypeInStack =
85
- hasCountType && stack . length && stack [ 0 ] === DATA ;
81
+ const hasDataTypeInStack = stack . length && stack [ 0 ] === DATA ;
86
82
87
83
lastMetadata =
88
84
stack . length < ( hasDataTypeInStack ? 3 : 2 )
@@ -110,7 +106,6 @@ export function getOptionFromGqlQuery<Entity>(
110
106
stack : addedStack ,
111
107
relations : acc . relations ,
112
108
select : acc . select ,
113
- hasCountType,
114
109
} ) ;
115
110
} ,
116
111
{
@@ -120,7 +115,7 @@ export function getOptionFromGqlQuery<Entity>(
120
115
) ;
121
116
}
122
117
123
- const getCurrentGraphQLQuery = ( ctx : GqlExecutionContext ) => {
118
+ export const getCurrentGraphQLQuery = ( ctx : GqlExecutionContext ) => {
124
119
const { fieldName, path } = ctx . getArgByIndex ( 3 ) as {
125
120
fieldName : string ;
126
121
path : { key : string } ;
@@ -159,7 +154,7 @@ const getCurrentGraphQLQuery = (ctx: GqlExecutionContext) => {
159
154
return stack . join ( '\n' ) ;
160
155
} ;
161
156
162
- export const GraphQLQueryToOption = < T > ( hasCountType ?: boolean ) =>
157
+ export const GraphQLQueryToOption = < T > ( ) =>
163
158
createParamDecorator ( ( _ : unknown , context : ExecutionContext ) => {
164
159
const ctx = GqlExecutionContext . create ( context ) ;
165
160
const request = ctx . getContext ( ) . req ;
@@ -175,7 +170,6 @@ export const GraphQLQueryToOption = <T>(hasCountType?: boolean) =>
175
170
const queryOption : GetInfoFromQueryProps < T > = getOptionFromGqlQuery . call (
176
171
repository ,
177
172
query ,
178
- hasCountType ,
179
173
) ;
180
174
181
175
return queryOption ;
0 commit comments