@Resolver(() => Store)
export class StoreResolver {
@FieldResolver()
async totalFastDelivery(@Root() store: Store): Promise<number> {
return await getRepository(Order)
.createQueryBuilder("orders")
.where("orders.storeId = :id", { id: store.id })
.andWhere("orders.fastDelivery = true ")
.getCount();
}
}
尽管getCount()
的返回类型为Promise<number>
得到这个
Error: You need to provide explicit type for StoreResolver#totalFastDelivery !
那么,这怎么了?我应该使用其他任何类型吗?
答案 0 :(得分:0)
@FieldResolver(() => Int)
会解决的。