Poll for Completion
User Intent
Operation
TypeScript (Canonical)
import { Graphlit } from 'graphlit-client';
const graphlit = new Graphlit();
// After creating a feed
const feedResponse = await graphlit.createFeed(feedInput);
const feedId = feedResponse.createFeed.id;
console.log(`Feed created: ${feedId}`);
// Poll for completion
const maxAttempts = 60; // 10 minutes max (60 * 10 seconds)
for (let attempts = 1; attempts <= maxAttempts; attempts++) {
const status = await graphlit.isFeedDone(feedId);
if (status.isFeedDone.result) {
console.log('Feed sync complete!');
const contents = await graphlit.queryContents({
feeds: [{ id: feedId }],
});
console.log(`Synced ${contents.contents.results.length} items`);
return;
}
console.log(`Still syncing... (${attempts}/${maxAttempts})`);
await new Promise((resolve) => setTimeout(resolve, 10_000));
}
console.log('Feed sync timeout - still processing');Parameters
Required
Response
Developer Hints
Only for Initial Sync
Recommended Polling Interval
🕐 Timeout Considerations
Helper Function Pattern
Variations
1. Basic Polling with Progress
2. Polling with Content Count Tracking
3. Parallel Feed Polling
4. Exponential Backoff Polling
5. Polling with Timeout Promise
6. Query Content After Completion
Common Issues
Production Example
Last updated