Fuel API doesn't support reverse pagination for transactions

I’m trying execute the following request in Fuel’s graphQL API:

query TransactionsByOwner($address: Address) {
  transactionsByOwner(owner: $address, last: 10) {
    nodes {
      id
    }
  }
}

And I’m getting the following error:

{
  "data": null,
  "errors": [
    {
      "message": "reverse pagination isn't supported for this resource",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "transactionsByOwner"
      ]
    }
  ]
}

The same request with the first parameter instead of last works, but shows the oldest transactions first:

query TransactionsByOwner($address: Address) {
  transactionsByOwner(owner: $address, first: 10) {
    nodes {
      id
    }
  }
}

That means that the only direction the pagination for transactions work is from oldest transactions to the newest. That makes it impossible or inefficient to make a proper pagination of transactions, requesting pages of transactions from newest to oldest.

Please add support for query parameters last and before

Fuel’s client leverages RocksDB for data storage, and as evidenced in the source code at FuelLabs/fuel-core, RocksDB does not inherently support reverse iteration over a prefix. This limitation can be observed in the way the data is managed within the system.

But I totally get that this is a big deal and a useful feature to have. I’m going to bring this up with the client team and see what we can do about it. Thanks for pointing it out – it’s really helpful feedback. :slight_smile:

2 Likes

Great, thank you! We’re having this issue since beta-2 and were hoping that it’s an obvious problem and were waiting for the fix which didn’t come :smiley: Next time will file such problems right away

1 Like

I do apologize for this, @mpoplavkov and I really appreciate you guys for being patient with us :pray:

1 Like

It’s impossible to avoid such problems in an actively developing project, there is nothing to apologize for :raised_hands: It’s our bad that we haven’t filed this issue earlier :slight_smile:

Green from our client team is the GOAT

:eyes: :eyes: :eyes:

3 Likes

Awesome! Hope to see this change in the API soon!

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.