Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove query nesting so goldsky doesn't timeout #53

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions tinlake-ui/services/apollo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [] }

Expand Down
Loading