@@ -130,11 +130,11 @@ export type ProcessRPCNode<
130
130
Row extends Record < string , unknown > ,
131
131
RelationName extends string ,
132
132
NodeType extends Ast . Node
133
- > = NodeType extends Ast . StarNode // If the selection is *
133
+ > = NodeType [ 'type' ] extends Ast . StarNode [ 'type' ] // If the selection is *
134
134
? Row
135
- : NodeType extends Ast . FieldNode
136
- ? ProcessSimpleField < Row , RelationName , NodeType >
137
- : SelectQueryError < 'Unsupported node type.' >
135
+ : NodeType [ 'type' ] extends Ast . FieldNode [ 'type' ]
136
+ ? ProcessSimpleField < Row , RelationName , Extract < NodeType , Ast . FieldNode > >
137
+ : SelectQueryError < 'RPC Unsupported node type.' >
138
138
/**
139
139
* Process select call that can be chained after an rpc call
140
140
*/
@@ -197,12 +197,12 @@ export type ProcessNode<
197
197
RelationName extends string ,
198
198
Relationships extends GenericRelationship [ ] ,
199
199
NodeType extends Ast . Node
200
- > = NodeType extends Ast . StarNode // If the selection is *
200
+ > = NodeType [ 'type' ] extends Ast . StarNode [ 'type' ] // If the selection is *
201
201
? Row
202
- : NodeType extends Ast . SpreadNode // If the selection is a ...spread
203
- ? ProcessSpreadNode < Schema , Row , RelationName , Relationships , NodeType >
204
- : NodeType extends Ast . FieldNode
205
- ? ProcessFieldNode < Schema , Row , RelationName , Relationships , NodeType >
202
+ : NodeType [ 'type' ] extends Ast . SpreadNode [ 'type' ] // If the selection is a ...spread
203
+ ? ProcessSpreadNode < Schema , Row , RelationName , Relationships , Extract < NodeType , Ast . SpreadNode > >
204
+ : NodeType [ 'type' ] extends Ast . FieldNode [ 'type' ]
205
+ ? ProcessFieldNode < Schema , Row , RelationName , Relationships , Extract < NodeType , Ast . FieldNode > >
206
206
: SelectQueryError < 'Unsupported node type.' >
207
207
208
208
/**
@@ -369,7 +369,9 @@ type ProcessSpreadNode<
369
369
/**
370
370
* Helper type to process the result of a spread node.
371
371
*/
372
- type ProcessSpreadNodeResult < Result > = ExtractFirstProperty < Result > extends infer SpreadedObject
372
+ type ProcessSpreadNodeResult < Result > = Result extends Record < string , SelectQueryError < string > >
373
+ ? Result
374
+ : ExtractFirstProperty < Result > extends infer SpreadedObject
373
375
? ContainsNull < SpreadedObject > extends true
374
376
? Exclude < { [ K in keyof SpreadedObject ] : SpreadedObject [ K ] | null } , null >
375
377
: Exclude < { [ K in keyof SpreadedObject ] : SpreadedObject [ K ] } , null >
0 commit comments