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

Enable batched queries #442

Open
Vichy97 opened this issue Jan 3, 2025 · 4 comments
Open

Enable batched queries #442

Vichy97 opened this issue Jan 3, 2025 · 4 comments
Labels
enhancement New feature or request P1
Milestone

Comments

@Vichy97
Copy link
Collaborator

Vichy97 commented Jan 3, 2025

Batched queries will be vital for supporting offline mode for the mobile app. It's not realistic to do one large query as this can take upwards of a full minute for an entire state and often times out or fails. Apollo makes it super easy to split this into batches, but only if it's supported on the backend.

@Vichy97 Vichy97 added the enhancement New feature or request label Jan 3, 2025
@github-project-automation github-project-automation bot moved this to General backlog in OpenBeta Project board Jan 9, 2025
@vnugent vnugent added this to the v2 milestone Jan 9, 2025
@vnugent vnugent added the P1 label Jan 9, 2025
@Vichy97
Copy link
Collaborator Author

Vichy97 commented Jan 9, 2025

https://www.apollographql.com/docs/graphos/routing/performance/query-batching This has all the documentation including sample queries. It looks like it's just a couple lines to configure this feature.

@glassbead0
Copy link

glassbead0 commented Jan 23, 2025

I'm currently working on this. I'm new to the project, so it will likely take me a bit longer, and if anyone wants to join, ping me on discord (Infinity00)

@Vichy97, since I'm new to openbeta, can you provide more specific requirements for this? If you could give me an example of the one large query you're currently making, and what kind of batched query you want to make? Happy to chat in Discord too.

@Vichy97
Copy link
Collaborator Author

Vichy97 commented Jan 23, 2025

I would like the ability to query all the climbs and areas in an entire state. I plan to have that query automatically broken down and sent as batched queries using the Kotlin Apollo client. I believe this is basically automatically handled for you on the server side as long as you follow the configuration in that documentation I linked.

@vnugent
Copy link
Contributor

vnugent commented Jan 23, 2025

@Vichy97 according to the page you sent the batching feature is only available to Enterprise plan.
@glassbead0 once you get your development env working, I can find you an simpler task to get started.

In general the slowness you're seeing is a classic n+1 problem. Consider this query, getting info & all images for Red Rock and the next immediate children and their images.

query MyQuery {
  area(uuid: "bea6bf11-de53-5046-a5b4-b89217b7e9bc") {
    areaName
    media {
      id
    }
    children {
      areaName
      media {
        id
      }
    }
  }
}

For each child of Red Rock (let's say there's 20 of them), the backend sends a separate query to the media collection, or 20 queries. We're subclassing the mongo data source class that is supposed to be smart enough to run only 1 query,
eg select * from collection where id in ( set of child IDs), vs 20 individual "select * from media where id = child_id1".

We'll need to rewrite how we resolve the media field or add a new batch download query for mobile to download multiple areas + photos at once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P1
Projects
Status: General backlog
Development

No branches or pull requests

3 participants