@@ -4,6 +4,7 @@ import { KeyValueCache } from "apollo-server-caching";
44import type {
55 Collection ,
66 Document ,
7+ Filter ,
78 FindOptions ,
89 Sort ,
910 SortDirection
@@ -66,7 +67,7 @@ export default abstract class MongoDataSource<
6667 this . context = context ;
6768 }
6869
69- async count ( query : { } = { } , options = { ttl : this . defaultTTL } ) {
70+ async count ( query : Filter < TSchema > = { } , options = { ttl : this . defaultTTL } ) {
7071 const cacheKey = this . getCacheKey ( "count" , query ) ,
7172 cacheDoc = await this . cache ?. get ( cacheKey ) ;
7273 if ( cacheDoc ) return JSON . parse ( cacheDoc ) ;
@@ -82,7 +83,7 @@ export default abstract class MongoDataSource<
8283 }
8384
8485 async find (
85- fields : any = { } ,
86+ fields : Filter < TSchema > = { } ,
8687 options : { ttl : number ; findOptions ?: FindOptions < TSchema > } = {
8788 ttl : this . defaultTTL
8889 } ,
@@ -117,7 +118,7 @@ export default abstract class MongoDataSource<
117118 }
118119
119120 async findOne (
120- fields : any = { } ,
121+ fields : Filter < TSchema > = { } ,
121122 options : { ttl : number ; findOptions ?: FindOptions < TSchema > } = {
122123 ttl : this . defaultTTL
123124 }
@@ -139,15 +140,15 @@ export default abstract class MongoDataSource<
139140
140141 async delete (
141142 type : DataSourceOperation ,
142- fields : any = { } ,
143+ fields : Filter < TSchema > = { } ,
143144 options : { findOptions ?: FindOptions < TSchema > } = { }
144145 ) {
145146 return await this . cache ?. delete ( this . getCacheKey ( type , fields , options ) ) ;
146147 }
147148
148149 private getCacheKey (
149150 type : DataSourceOperation ,
150- fields : any ,
151+ fields : Filter < TSchema > ,
151152 options : { findOptions ?: FindOptions < TSchema > } = { } ,
152153 sort ?: { sort : Sort ; direction ?: SortDirection } ,
153154 skip ?: number ,
0 commit comments