File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -161,16 +161,20 @@ export function discardQuery(...fieldNames: string[]): Hook;
161
161
*/
162
162
export function existsByDot ( object : any , path : string ) : boolean ;
163
163
164
- export type SimpleResolver < T > = ( ...args : any [ ] ) => ( item : T ) => Promise < any > ;
164
+ export interface ResolverContext < T = any > extends HookContext < T > {
165
+ _loaders : any ;
166
+ }
167
+
168
+ export type SimpleResolver < T > = ( ...args : any [ ] ) => ( item : T , context : ResolverContext ) => Promise < any > ;
165
169
166
170
export interface RecursiveResolver < T > {
167
171
resolver : SimpleResolver < T > ;
168
172
joins : ResolverMap < any > ;
169
173
}
170
174
171
175
export interface ResolverMap < T > {
172
- after ?: AsyncContextFunction < void > ;
173
- before ?: AsyncContextFunction < void > ;
176
+ after ?: ( context : ResolverContext ) => void | Promise < void > ;
177
+ before ?: ( context : ResolverContext ) => void | Promise < void > ;
174
178
joins : {
175
179
[ property : string ] : SimpleResolver < T > | RecursiveResolver < T > ;
176
180
} ;
Original file line number Diff line number Diff line change @@ -181,6 +181,21 @@ const postResolvers: ResolverMap<any> = {
181
181
}
182
182
} ;
183
183
184
+ const userResolvers : ResolverMap < any > = {
185
+ joins : {
186
+ memberships : ( ) => async ( user , context ) => {
187
+ const memberships : any = ( await context . app ! . service
188
+ ( 'memberships' ) . find ( { query : {
189
+ user : user . _id ,
190
+ $populate : 'role' ,
191
+ } } ) ) ;
192
+ user . memberships = memberships . data ;
193
+ }
194
+ }
195
+ } ;
196
+
197
+ // $ExpectType Hook
198
+ fastJoin ( userResolvers ) ;
184
199
// $ExpectType Hook
185
200
fastJoin ( postResolvers ) ;
186
201
// $ExpectType Hook
You can’t perform that action at this time.
0 commit comments