From 067b4fa9416448c638196d628d3d19527d31590c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9B=90=EB=8D=94?= Date: Wed, 6 Jan 2021 09:38:18 +0900 Subject: [PATCH] feat: CACHING AND FETCH --- utils/Fetch.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/utils/Fetch.ts b/utils/Fetch.ts index 9fd0087..cbceba6 100644 --- a/utils/Fetch.ts +++ b/utils/Fetch.ts @@ -1,8 +1,13 @@ import DataLoader from 'dataloader' import * as Query from './Query' -const loaders = { - bor: new DataLoader(async (ids:string[]) => await Promise.all(ids.map((el:string)=> Query.getBot(el)))), - user: new DataLoader(async (ids:string[]) => await Promise.all(ids.map((el:string)=> Query.getUser(el)))), +const Fetch = { + bot: new DataLoader(async (ids:string[]) => await Promise.all(ids.map((el:string)=> Query.getBot(el))), { + batchScheduleFn: callback => setTimeout(callback, 1000) + }), + user: new DataLoader(async (ids:string[]) => await Promise.all(ids.map((el:string)=> Query.getUser(el))), { + batchScheduleFn: callback => setTimeout(callback, 1000) + }), } +export default Fetch \ No newline at end of file