Skip to content

Add skipDuplicates parameter on @entity directive - #6458

Merged
isum merged 11 commits into
masterfrom
ion/skip-duplicates
Apr 9, 2026
Merged

isum merged 11 commits into
masterfrom
ion/skip-duplicates

Conversation

@isum

@isum isum commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add skipDuplicates parameter to the @entity directive for immutable entities. @entity(immutable: true, skipDuplicates: true) skips duplicate inserts instead of failing indexing. This unblocks subgraph composition on Amp-powered subgraphs where SQL queries can produce the same entities across block ranges.

Changes

  • Parse and validate skipDuplicates from @entity directive (requires immutable: true)
  • Write-batch layer: skip instead of failing on cross-block duplicate inserts
  • Store layer: skip on unexpected update/delete for skip-duplicates entities
  • DB layer: ON CONFLICT (id) DO NOTHING for skip-duplicates INSERT queries, with affected-rows logging
  • Runner test for end-to-end validation

Default behavior (skipDuplicates: false) is unchanged - duplicates still fail indexing.

@isum isum self-assigned this Mar 26, 2026
@fordN
fordN requested a review from lutter March 26, 2026 15:51
@isum
isum force-pushed the ion/skip-duplicates branch from 3a426e4 to 78c451c Compare March 26, 2026 17:31

@lutter lutter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to consider here, too, is that there is really a strict hierarchy of mutability: mutable entities, immutable entities, and immutable with skipUpdates entities. That's currently expressed with 2 booleans. It might be clearer to express that with an enum

Comment thread graph/src/components/store/write.rs Resolved