diff --git a/packages/indexer-common/src/indexer-management/resolvers/allocations.ts b/packages/indexer-common/src/indexer-management/resolvers/allocations.ts index f5ad5da3a..27eb92d51 100644 --- a/packages/indexer-common/src/indexer-management/resolvers/allocations.ts +++ b/packages/indexer-common/src/indexer-management/resolvers/allocations.ts @@ -1,4 +1,4 @@ -import { epochElapsedBlocks, Network } from '@graphprotocol/indexer-common' +import { epochElapsedBlocks, Network, QueryResult } from '@graphprotocol/indexer-common' /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/ban-types */ @@ -67,7 +67,7 @@ interface AllocationInfo { const ALLOCATION_QUERIES = { [AllocationQuery.all]: gql` query allocations($indexer: String!) { - allocations(where: { indexer: $indexer }, first: 1000) { + allocations(where: { indexer: $indexer }, first: $first, skip: $skip) { id subgraphDeployment { id @@ -88,7 +88,11 @@ const ALLOCATION_QUERIES = { `, [AllocationQuery.active]: gql` query allocations($indexer: String!) { - allocations(where: { indexer: $indexer, status: Active }, first: 1000) { + allocations( + where: { indexer: $indexer, status: Active } + first: $first + skip: $skip + ) { id subgraphDeployment { id @@ -109,7 +113,11 @@ const ALLOCATION_QUERIES = { `, [AllocationQuery.closed]: gql` query allocations($indexer: String!) { - allocations(where: { indexer: $indexer, status: Closed }, first: 1000) { + allocations( + where: { indexer: $indexer, status: Closed } + first: $first + skip: $skip + ) { id subgraphDeployment { id @@ -130,7 +138,7 @@ const ALLOCATION_QUERIES = { `, [AllocationQuery.allocation]: gql` query allocations($allocation: String!) { - allocations(where: { id: $allocation }, first: 1000) { + allocations(where: { id: $allocation }, first: $first, skip: $skip) { id subgraphDeployment { id @@ -203,10 +211,27 @@ async function queryAllocations( ) } - const result = await networkSubgraph.checkedQuery( - ALLOCATION_QUERIES[filterType], - filterVars, - ) + const pageSize = 1000 + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let result: QueryResult + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const resultAllocations: any[] = [] + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const filterPage = { + first: pageSize, + skip: 0, + } + do { + const pageVars = { + ...filterVars, + ...filterPage, + } + result = await networkSubgraph.checkedQuery(ALLOCATION_QUERIES[filterType], pageVars) + // merge results + resultAllocations.push(...result.data.allocations) + filterPage.skip += result.data.allocations.length - 1 + } while (result.data.allocations.length == pageSize) if (result.data.allocations.length == 0) { // TODO: Is 'Claimable' still the correct term here, after Exponential Rebates? @@ -493,8 +518,7 @@ export default { if (receipt === 'paused' || receipt === 'unauthorized') { throw indexerError( IndexerErrorCode.IE062, - `Allocation not created. ${ - receipt === 'paused' ? 'Network paused' : 'Operator not authorized' + `Allocation not created. ${receipt === 'paused' ? 'Network paused' : 'Operator not authorized' }`, ) }