@@ -41,6 +41,7 @@ import type { DrizzleRef } from './interface-ref';
4141import type {
4242 DrizzleConnectionShape ,
4343 ListRelation ,
44+ PathInfo ,
4445 RelatedConnectionOptions ,
4546 RelatedCountOptions ,
4647 RelatedFieldOptions ,
@@ -219,9 +220,23 @@ export class DrizzleObjectFieldBuilder<
219220 ) ! ;
220221 } ;
221222
222- const getQuery = ( args : PothosSchemaTypes . DefaultConnectionArguments , ctx : { } ) => {
223- const { limit, orderBy, where, ...fieldQuery } =
224- ( typeof query === 'function' ? query ( args , ctx ) : query ) ?? { } ;
223+ const getQuery = (
224+ args : PothosSchemaTypes . DefaultConnectionArguments ,
225+ ctx : { } ,
226+ pathInfo ?: import ( './types' ) . PathInfo ,
227+ ) => {
228+ const { limit, orderBy, where, ...fieldQuery } = ( ( typeof query === 'function'
229+ ? ( query as ( args : { } , ctx : { } , pathInfo ?: import ( './types' ) . PathInfo ) => { } ) (
230+ args ,
231+ ctx ,
232+ pathInfo ,
233+ )
234+ : query ) ?? { } ) as {
235+ limit ?: number ;
236+ orderBy ?: unknown ;
237+ where ?: SQL ;
238+ columns ?: Record < string , boolean > ;
239+ } ;
225240
226241 const { cursorColumns, columns, ...connectionQuery } = drizzleCursorConnectionQuery ( {
227242 ctx,
@@ -255,6 +270,7 @@ export class DrizzleObjectFieldBuilder<
255270 context : object ,
256271 nestedQuery : ( query : unknown , path ?: unknown ) => { select ?: object } ,
257272 getSelection : ( path : string [ ] ) => FieldNode | null ,
273+ pathInfo : import ( './types' ) . PathInfo ,
258274 ) => {
259275 typeName ??= this . builder . configStore . getTypeConfig ( ref ) . name ;
260276
@@ -279,7 +295,7 @@ export class DrizzleObjectFieldBuilder<
279295 } ;
280296 }
281297
282- const nested = nestedQuery ( getQuery ( args , context ) . select , {
298+ const nested = nestedQuery ( getQuery ( args , context , pathInfo ) . select , {
283299 getType : ( ) => typeName ! ,
284300 paths : [ [ { name : 'nodes' } ] , [ { name : 'edges' } , { name : 'node' } ] ] ,
285301 } ) as SelectionMap ;
@@ -500,14 +516,24 @@ export class DrizzleObjectFieldBuilder<
500516
501517 const { query = { } , extensions, ...rest } = options ;
502518
503- const relationSelect = ( args : object , context : object , nestedQuery : ( query : unknown ) => { } ) => {
519+ const relationSelect = (
520+ args : object ,
521+ context : object ,
522+ nestedQuery : ( query : unknown ) => { } ,
523+ _resolveSelection : unknown ,
524+ pathInfo : PathInfo ,
525+ ) => {
504526 const relQuery = {
505527 columns : { } ,
506528 with : {
507529 [ name ] : {
508530 ...nestedQuery ( query ) ,
509531 ...( ( typeof query === 'function'
510- ? ( query as ( args : { } , context : { } ) => { } ) ( args , context )
532+ ? ( query as ( args : { } , context : { } , pathInfo : PathInfo ) => { } ) (
533+ args ,
534+ context ,
535+ pathInfo ,
536+ )
511537 : query ) as { } ) ,
512538 } ,
513539 } ,
0 commit comments