MCPcopy Create free account
hub / github.com/TanStack/query / seedCacheOnlyTodo

Method seedCacheOnlyTodo

examples/lit/basic/src/main.ts:119–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117 }
118
119 private seedCacheOnlyTodo(): void {
120 this.cacheSeedCount += 1
121
122 const seedTodo: Todo = {
123 id: 10_000 + this.cacheSeedCount,
124 title: `Seeded cache todo ${this.cacheSeedCount}`,
125 }
126
127 demoQueryClient.setQueryData<TodosResponse>(['todos'], (existing) => {
128 if (!existing) {
129 return {
130 items: [seedTodo],
131 requestCount: 0,
132 source: 'cache',
133 }
134 }
135
136 return {
137 items: [...existing.items, seedTodo],
138 requestCount: existing.requestCount,
139 source: 'cache',
140 }
141 })
142 }
143
144 private forceNextFetchFailure(): void {
145 failNextFetchRequest()

Callers 1

renderMethod · 0.95

Calls 1

setQueryDataMethod · 0.45

Tested by

no test coverage detected