@@ -46,9 +46,6 @@ export interface ConnectionConfig {
4646}
4747
4848export class ConnectionBuilder {
49- /**
50- * Build connection configuration without executing queries
51- */
5249 static buildConfig ( args : {
5350 pagination : PaginationArgs
5451 where ?: any
@@ -71,28 +68,23 @@ export class ConnectionBuilder {
7168 } = args
7269 const { first, after, last, before } = pagination
7370
74- // Calculate pagination parameters
7571 let take = first || last || 10
7672 if ( last ) take = - take
7773
78- // For composite key models, we skip cursor-based pagination
7974 const cursor = ( hasIdField && ( after || before ) )
8075 ? { [ cursorField ] : ( after || before ) ! }
8176 : undefined
8277 const skip = cursor ? 1 : 0
8378
84- // Build include from GraphQL selection if info is provided
8579 const finalInclude = info ? buildPrismaInclude ( info , relationFields ) : include
8680
87- // Prepare query options
8881 const findManyOptions : any = {
8982 take : Math . abs ( take ) + 1 , // Get one extra to check for next page
9083 where,
9184 orderBy,
9285 include : finalInclude ,
9386 }
9487
95- // Only add cursor and skip for models with ID field
9688 if ( hasIdField && cursor ) {
9789 findManyOptions . cursor = cursor
9890 findManyOptions . skip = skip
@@ -113,31 +105,24 @@ export class ConnectionBuilder {
113105 }
114106 }
115107
116- /**
117- * Process query results into connection format
118- */
119108 static processResults < T > (
120109 items : T [ ] ,
121110 totalCount : number ,
122111 paginationInfo : ConnectionConfig [ 'paginationInfo' ]
123112 ) : ConnectionResult < T > {
124113 const { first, last, cursorField, hasIdField } = paginationInfo
125114
126- // Determine pagination info
127115 const hasNextPage = first ? items . length > first : false
128116 const hasPreviousPage = last ? items . length > Math . abs ( last ) : false
129117
130- // Remove extra item if present
131118 const resultItems = hasNextPage || hasPreviousPage ? items . slice ( 0 , - 1 ) : items
132119
133- // Build edges - use composite key for cursor if no ID field
134120 const edges = resultItems . map ( ( item : any , index : number ) => {
135121 let cursor : string
136122 if ( hasIdField && item [ cursorField ] ) {
137123 cursor = item [ cursorField ]
138124 } else {
139- // For composite key models, create a cursor from available fields or use index
140- cursor = item . postId && item . categoryId
125+ cursor = item . postId && item . categoryId
141126 ? `${ item . postId } :${ item . categoryId } `
142127 : String ( index )
143128 }
@@ -289,10 +274,6 @@ export class ConnectionBuilder {
289274}
290275
291276export class FilterBuilder {
292- /**
293- * Build Prisma where clause from GraphQL filter input dynamically
294- * This approach uses runtime reflection to map filter operations
295- */
296277 static buildFilter ( filter : any ) : any {
297278 if ( ! filter || typeof filter !== 'object' ) return { }
298279
@@ -304,10 +285,8 @@ export class FilterBuilder {
304285 } else if ( field === 'OR' && Array . isArray ( value ) ) {
305286 where . OR = value . map ( ( f : any ) => this . buildFilter ( f ) )
306287 } else if ( value && typeof value === 'object' ) {
307- // Map filter operations dynamically
308288 const fieldWhere : any = { }
309289
310- // Copy all valid operations from the filter value
311290 for ( const [ operation , operationValue ] of Object . entries ( value ) ) {
312291 if ( operationValue !== undefined && operationValue !== null ) {
313292 fieldWhere [ operation ] = operationValue
@@ -346,19 +325,14 @@ export class FilterBuilder {
346325}
347326
348327export class SortBuilder {
349- /**
350- * Build Prisma orderBy clause from GraphQL sort input dynamically
351- * This approach uses runtime reflection to map sort fields
352- */
353328 static buildSort ( sort : any , fallbackSort : any = { id : 'asc' } ) : any {
354329 if ( ! sort || typeof sort !== 'object' ) return fallbackSort
355330
356331 const orderBy : any = { }
357332
358333 for ( const [ field , direction ] of Object . entries ( sort ) ) {
359334 if ( direction && typeof direction === 'string' ) {
360- // Convert enum values to lowercase for Prisma
361- orderBy [ field ] = direction . toLowerCase ( )
335+ orderBy [ field ] = direction . toLowerCase ( )
362336 }
363337 }
364338
@@ -367,28 +341,24 @@ export class SortBuilder {
367341
368342
369343 static buildUserSort ( sort ?: UserSortInput ) : any {
370- // For models without id field (like composite key models), don't use id as fallback
371344 const fallbackSort = true ? { id : 'asc' } : { }
372345 return this . buildSort ( sort , fallbackSort )
373346 }
374347
375348 static buildPostSort ( sort ?: PostSortInput ) : any {
376- // For models without id field (like composite key models), don't use id as fallback
377349 const fallbackSort = true ? { id : 'asc' } : { }
378350 return this . buildSort ( sort , fallbackSort )
379351 }
380352
381353
382354
383355 static buildCommentSort ( sort ?: CommentSortInput ) : any {
384- // For models without id field (like composite key models), don't use id as fallback
385356 const fallbackSort = true ? { id : 'asc' } : { }
386357 return this . buildSort ( sort , fallbackSort )
387358 }
388359}
389360
390- // Simplified field selection utilities (GraphQL-import-free)
391- // Uses static includes instead of dynamic GraphQL field parsing
361+
392362
393363export interface ResolveTree {
394364 name : string
@@ -401,10 +371,7 @@ export interface FieldsByTypeName {
401371 [ str : string ] : { [ str : string ] : ResolveTree }
402372}
403373
404- // Simplified version that doesn't require GraphQL imports
405374export function buildPrismaInclude ( _resolveInfo : any , relations : string [ ] = [ ] ) : any {
406- // For now, return a simple include object based on available relations
407- // This avoids GraphQL module conflicts while maintaining basic functionality
408375 const include : any = { }
409376
410377 relations . forEach ( relation => {
0 commit comments