@@ -105,7 +105,7 @@ export type FilterNever<T extends Record<string, unknown>> = NonNeverKeys<T> ext
105105 * >; // { apple: "red" }
106106 * ```
107107 */
108- type InnerSelect < Schema , Selection extends FieldSelection | null | undefined > = IfAny <
108+ type InnerSelect < Schema , Selection extends FieldSelection | FieldSelectionWithArgs | null | undefined > = IfAny <
109109 Selection ,
110110 never ,
111111 Selection extends null | undefined
@@ -115,10 +115,12 @@ type InnerSelect<Schema, Selection extends FieldSelection | null | undefined> =
115115 : Schema extends null
116116 ? InnerSelect < Exclude < Schema , null > , Selection > | null
117117 : {
118- [ Key in keyof Selection & keyof Schema ] : Selection [ Key ] extends true
118+ [ Key in Exclude < keyof Selection , typeof $args > & keyof Schema ] : Selection [ Key ] extends true
119119 ? Schema [ Key ]
120- : Selection [ Key ] extends FieldSelection
121- ? InnerSelect < Schema [ Key ] , Selection [ Key ] >
120+ : Selection [ Key ] extends FieldSelection | FieldSelectionWithArgs
121+ ? Exclude < keyof Selection [ Key ] , typeof $args > extends never
122+ ? Schema [ Key ]
123+ : InnerSelect < Schema [ Key ] , Selection [ Key ] >
122124 : never ;
123125 }
124126> ;
@@ -148,7 +150,9 @@ export type DeepFilterNever<T> = T extends Record<string, unknown>
148150 * >; // { apple: "red" }
149151 * ```
150152 */
151- export type Select < Schema , Selection extends FieldSelection | null | undefined > = DeepFilterNever < InnerSelect < Schema , Selection > > ;
153+ export type Select < Schema , Selection extends FieldSelection | FieldSelectionWithArgs | null | undefined > = DeepFilterNever <
154+ InnerSelect < Schema , Selection >
155+ > ;
152156
153157/** Represents an amount of some currency. Specified as a string so user's aren't tempted to do math on the value. */
154158export type CurrencyAmount = string ;
@@ -989,10 +993,22 @@ export type ViewResult<F extends ViewFunction<any, any>> = Awaited<
989993 F extends ViewFunctionWithVariables < any , infer Result > ? Result : F extends ViewFunctionWithoutVariables < infer Result > ? Result : never
990994> ;
991995
996+ /** Symbol key for field arguments in selections */
997+ export const $args : unique symbol = Symbol . for ( "gadget/fieldArgs" ) ;
998+
999+ /** Field arguments (e.g., pagination, filtering) */
1000+ export type FieldArgs = Record < string , any > ;
1001+
9921002/**
9931003 * Represents a list of fields selected from a GraphQL API call. Allows nesting, conditional selection.
9941004 * Example: `{ id: true, name: false, richText: { markdown: true, html: false } }`
9951005 **/
9961006export interface FieldSelection {
9971007 [ key : string ] : boolean | null | undefined | FieldSelection ;
9981008}
1009+
1010+ /** A field selection that includes field arguments via the $args symbol key */
1011+ export type FieldSelectionWithArgs = {
1012+ [ $args ] : FieldArgs ;
1013+ [ key : string ] : boolean | null | undefined | FieldSelection | FieldSelectionWithArgs ;
1014+ } ;
0 commit comments