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

Store query parameters in states for aggregate queries refetch #8542

Open
lucasbordeau opened this issue Nov 18, 2024 · 1 comment
Open

Store query parameters in states for aggregate queries refetch #8542

lucasbordeau opened this issue Nov 18, 2024 · 1 comment
Assignees
Labels
blocked: tech spec needed prio: high scope: front Issues that are affecting the frontend side only

Comments

@lucasbordeau
Copy link
Contributor

Scope & Context

New aggregates feature handling of frontend queries and cache.

Current behavior

Currently the total count aggregate is part of any request that fetches data.

The problem is that we cannot easily do optimistic rendering of aggregates.

Expected behavior

We want to separate data request from aggregate request, so that we can do optimistic rendering for the data part and trigger a network refresh for the aggregate part.

The difficulty to keep things clean is to tie each data request to its aggregate counterpart and be able to easily refresh the aggregate request from any part of the app.

For example we could have a Pill component in the ViewBar dropdown and this component would display the total count for each view and their filter, thus we would need to fetch only the aggregate for each request parameters of each view.

We could copy the prefetch query system and have generic logic to get aggregate / data query from a unique map of queries, this could be a meaningful family state like "record-table-data-query" => { filters: { ... }, orderBy: { ... } }, this recoil state would be updated by the parts of the code that compute the parameters of the request.

@lucasbordeau lucasbordeau changed the title Store query in states for aggregate queries Store query parameters in states for aggregate queries refetch Nov 18, 2024
@Bonapara
Copy link
Member

Can you add labels @lucasbordeau 🙏

raj921 added a commit to raj921/twenty that referenced this issue Nov 18, 2024
This commit implements a new system for managing aggregate queries separately
from data queries, enabling optimistic rendering and independent refresh of
aggregate data.

Key changes:
- Add aggregateQueriesState to store query parameters
- Create useAggregateQueries hook for managing aggregate queries
- Add query key generation utilities
- Implement useLinkedAggregateQuery hook to tie data and aggregate queries

This addresses issue twentyhq#8542 by:
1. Separating data and aggregate requests
2. Enabling optimistic rendering of aggregates
3. Supporting independent refresh of aggregate data
4. Providing clean integration with ViewBar Pill components

Breaking Changes: None
@ijreilly ijreilly self-assigned this Nov 19, 2024
@lucasbordeau lucasbordeau added scope: front Issues that are affecting the frontend side only blocked: tech spec needed prio: high labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: tech spec needed prio: high scope: front Issues that are affecting the frontend side only
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants