From 177320791b9458f394ac6b73c0b0bfa20798f315 Mon Sep 17 00:00:00 2001 From: sophian Date: Fri, 2 Aug 2024 11:21:34 -0400 Subject: [PATCH] Remove query nesting so goldsky doesn't timeout --- tinlake-ui/services/apollo/index.ts | 60 ++++++++++++++--------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/tinlake-ui/services/apollo/index.ts b/tinlake-ui/services/apollo/index.ts index a2cb94eb..ff5bde50 100644 --- a/tinlake-ui/services/apollo/index.ts +++ b/tinlake-ui/services/apollo/index.ts @@ -292,43 +292,39 @@ class Apollo { async getLoans(root: string) { const result = await this.client.query({ - query: gql` - { - pools(where: { id_in: ["${root.toLowerCase()}"]}) { - loans (first: 1000) { - id - pool { - id - } - index - owner - opened - closed - debt - interestRatePerSecond - ceiling - threshold - borrowsCount - borrowsAggregatedAmount - repaysCount - repaysAggregatedAmount - nftId - nftRegistry - maturityDate - financingDate - riskGroup - } + query: gql` + { + loans( + where: {pool_: {id: "${root.toLowerCase()}"}} + first: 1000 + ) { + id + pool { + id } + index + owner + opened + closed + debt + interestRatePerSecond + ceiling + threshold + borrowsCount + borrowsAggregatedAmount + repaysCount + repaysAggregatedAmount + nftId + nftRegistry + maturityDate + financingDate + riskGroup } + } `, }) - const loans = result.data.pools.reduce((assets: any[], pool: any) => { - if (pool.loans) { - assets.push(...pool.loans) - } - return assets - }, []) + const loans = result.data.loans if (!loans) return { data: [] }