88 type GeneratedSchemaObject ,
99 type Type ,
1010} from '../Schema' ;
11- import type { Selection } from '../Selection' ;
11+ import type { Selection , SelectionInput } from '../Selection' ;
1212import { isPlainObject } from '../Utils' ;
1313import type { Meta } from './meta' ;
1414import { $meta } from './meta' ;
@@ -253,15 +253,32 @@ const objectProxyHandler: ProxyHandler<GeneratedSchemaObject> = {
253253
254254 const { __args, __type } = targetType ;
255255 if ( __args ) {
256- return ( args ?: Record < string , unknown > ) =>
257- resolve (
256+ return ( args ?: Record < string , unknown > ) => {
257+ const alias = meta . context . aliasGenerator ?.(
258+ meta . selection . ancestry . map ( ( s ) => s . key . toString ( ) ) . concat ( key ) ,
259+ args
260+ ) ;
261+ const input : SelectionInput = { } ;
262+
263+ if ( args ) {
264+ for ( const key in args ) {
265+ input [ key ] = {
266+ alias : alias ?. input [ key ] ,
267+ type : __args [ key ] ,
268+ value : args [ key ] ,
269+ } ;
270+ }
271+ }
272+
273+ return resolve (
258274 proxy ,
259275 meta . selection . getChild (
260276 key ,
261- args ? { input : { types : __args ! , values : args } } : { }
277+ args ? { alias : alias ?. field , input } : { }
262278 ) ,
263279 __type
264280 ) ;
281+ } ;
265282 }
266283
267284 return resolve ( proxy , meta . selection . getChild ( key ) , __type ) ;
@@ -468,7 +485,7 @@ const selectIdentityFields = (
468485
469486 // Always __typename except inside interfaces and unions
470487 if ( parent ?. key !== '$on' ) {
471- accessor . __typename ;
488+ Reflect . get ( accessor , ' __typename' ) ;
472489 }
473490
474491 const keys = getIdentityFields ( meta ) ;
@@ -479,7 +496,7 @@ const selectIdentityFields = (
479496 // Already selected at the common root of this interface/union.
480497 if ( isUnion && parent ?. parent ?. children . has ( key ) ) continue ;
481498
482- accessor [ key ] ;
499+ Reflect . get ( accessor , key ) ;
483500 }
484501} ;
485502
@@ -506,7 +523,7 @@ const arrayProxyHandler: ProxyHandler<CacheObject[]> = {
506523 throw new GQtyError ( `Cache data must be an array.` ) ;
507524 }
508525
509- if ( key === 'length' ) proxy [ 0 ] ;
526+ if ( key === 'length' ) Reflect . get ( proxy , 0 ) ;
510527
511528 const numKey = + key ;
512529 if ( ! isNaN ( numKey ) && numKey < data . length ) {
0 commit comments