← All problems
Problem

The empty list

The problem

An empty list holds no objects, so it carries no object keys: once cached, "no reviews yet" can outlive the first review. And a new item in a list that already had items is in no cached answer yet, so its own key clears nothing.

With GraphPilot

GraphPilot tags an empty list with its type, so a mutation that returns that type clears it. For a list with items, a static key on the list field, named in the Surrogate-Key header of the create's response, clears the list; or the mutation returns the parent the list hangs off.

Docs: Lists and creates ↗
Transcript

Dune has no reviews yet. The page shows an empty list, and that empty answer is cached.

Then someone writes the first review.

An empty list holds no objects, so a cache that only reads the response has no key to purge it by. The page keeps saying: no reviews yet.

GraphPilot tags an empty list with its type: an empty list of reviews.

When a mutation returns a review, GraphPilot clears the cached empty review lists.

The next visitor sees the first review.

And once the list has reviews? A new review is in no cached answer yet, so its own key clears nothing.

Give the list a key of its own in your schema: @surrogateKey(static: "review-list").

When the review is saved, your origin names that key in the response header (Surrogate-Key: review-list), and the list is fetched fresh.

Or, when the list hangs off the book, let the mutation return the book: its key clears the list along with it.

Cleared for takeoff

Start on Glider (Free).
No credit card, no commitment.

Prefer to talk first? Book a call