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

GraphQL big results/pagination #796

Open
RdeWilde opened this issue Jan 4, 2023 · 2 comments
Open

GraphQL big results/pagination #796

RdeWilde opened this issue Jan 4, 2023 · 2 comments
Labels
question Further information is requested

Comments

@RdeWilde
Copy link

RdeWilde commented Jan 4, 2023

Ask a question

When doing a GraphQL query which has a large result-set, it might be efficient to use pagination. One can do this by using a combination of limit and offset. This works fine for smaller offsets, but as it increase, response time also seems to increase. So my guess would be, that the full query result is generated, and only the offset - limit part is being returned. But as process time increase, really large offsets take forever to finish, while the number of results might be the same as offset 0.

Is there any way to improve this?

Or if not, is there any other way to accomplish the same thing?

The query used:

query delegatorData (
    $whereStake: ActiveStake_bool_exp,
    $whereReward: Reward_bool_exp,
    $limit: Int
    $offset: Int
) {
    activeStake (where: $whereStake, limit: $limit, offset: $offset) {
      address
      amount
      epochNo
      stakePoolId
    },
    rewards (where: $whereReward, limit: $limit, offset: $offset) {
        address
        amount
        stakePool {
          id
        }
    }
}

With variables:

{
    "limit": 2500,
    "offset": 60000,
    "whereStake": {
        "epochNo": {
            "_eq": 370
        }
    },
    "whereReward": {
        "earnedIn": {
            "number": {
                "_eq": 370
            }
        }
    }
}
@RdeWilde RdeWilde added the question Further information is requested label Jan 4, 2023
@RdeWilde
Copy link
Author

RdeWilde commented Jan 5, 2023

Hasura graphql engine v2 seems to support 'edges', but as we are depending on v1.3.3 we can't use that yet.
https://github.com/input-output-hk/cardano-graphql/blob/b632720ae5402ec8adec3721a59b538cd77a112b/packages/server/package.json#L27
https://www.npmjs.com/package/@cardano-graphql/api-cardano-db-hasura?activeTab=explore
Code > hasura > Dockerfile

FROM hasura/graphql-engine:v1.3.3.cli-migrations-v2

Any plans for v2?
https://hasura.io/blog/cursor-offset-pagination-with-hasura-graphql/

Hasura now supports the relay spec and you can get started here

@rhyslbw
Copy link
Contributor

rhyslbw commented Feb 8, 2023

We've just updated to Hasura 2, and it's now out in v8.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants