例如下面的 query
statistics {
orderSettlementPm
orderSettlementShop
todayPaidAmount
todayPaidOrderCount
}
}
目前 Resolvers 是这样的,这样会导致不管请求什么字段,都会计算一遍数据? 问:Resolvers 可不可以获取查询的字段列表?
class Resolvers::SysStatisticsData < Resolvers::Base
def resolve
data = {
paid_order_count: ShopOrderStatistic.sum(:paid_order_count),
paid_amount: ShopOrderStatistic.sum(:paid_amount),
today_paid_amount: ShopOrderStatistic.today_paid_amount,
today_paid_order_count: ShopOrderStatistic.today_paid_order_count,
yesterday_paid_order_count: ShopOrderStatistic.yesterday_paid_order_count,
yesterday_paid_amount: ShopOrderStatistic.yesterday_paid_amount,
today_refund_count: Refund.today_data.success_status.count,
yesterday_refund_count: Refund.yesterday_data.success_status.count,
refund_amount: Refund.refund_amount_sum,
withdraw_amount: WithdrawLog.withdraw_amount_sum,
wait_withdraw_amount: WithdrawLog.processing_paid.sum(:amount),
view_count: 100,
yesterday_view_count: 100,
wait_ship_order_count: Order.paid_status.count
}
end
end