Skip to content

Feature request: Dependent Data Hydration ("Graph Sync") for Sliding Window Patterns #3651

@dsanmart

Description

@dsanmart

Is your feature request related to a problem? Please describe.
I am building a local-first mobile application (React Native) involving high-frequency data (messaging) where we need to sync a "sliding window" of recent activity (e.g., messages WHERE created_at > 30 days ago).

The problem is Data Hydration (orphaned Foreign Keys). When we sync the last 30 days of messages, we also need the Conversation and Customer rows associated with those messages to render the UI. However:

  1. The Conversation might be 2 years old (outside the sync window).
  2. Syncing all Conversations is not feasible (dataset too large).
  3. We cannot easily identify which old conversations to fetch without first fetching the messages.
    This leaves us with orphaned foreign keys on the client and a broken UI.

Describe the solution you'd like
I would like a mechanism to define Dependent Shapes or Include Trees where the presence of a child row in a shape forces the sync of its parent row, regardless of the parent's timestamp.

Ideal Syntax (Conceptual):

const { data } = useShape({
  table: 'messages',
  where: `created_at >= now() - interval '30 days'`,
  include: {
    // Automatically fetch the specific Conversation row referenced by messages.conversation_id
    conversation: {
      include: {
        // And the Customer referenced by that conversation
        customer: true
      }
    }
  }
})

I understand include was removed in v1.0, but the use case for "Graph Sync" remains critical for partial replication.

Additional context

  • Stack: Postgres -> ElectricSQL -> SQLite

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions