Poll for Completion
Content: Poll for Completion
User Intent
Operation
TypeScript (Canonical)
import { Graphlit } from 'graphlit-client';
import { Types } from 'graphlit-client/dist/generated/graphql-types';
const graphlit = new Graphlit();
// After async ingestion
const contentResponse = await graphlit.ingestUri(
'https://example.com/document.pdf',
undefined, undefined, undefined,
false // isSynchronous = false (async)
);
const contentId = contentResponse.ingestUri.id;
console.log('Content ingestion started, polling for completion...');
// Poll for completion
let isDone = false;
let attempts = 0;
const maxAttempts = 60; // 10 minutes max
while (!isDone && attempts < maxAttempts) {
const status = await graphlit.isContentDone(contentId);
isDone = status.isContentDone.result || false;
if (!isDone) {
attempts++;
console.log(`Still processing... (${attempts}/${maxAttempts})`);
await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10 seconds
}
}
if (isDone) {
console.log(' Content processing complete!');
// Now safe to access content
const content = await graphlit.getContent(contentId);
console.log(`Extracted ${content.content.markdown?.length || 0} chars`);
} else {
console.log('⏰ Timeout - still processing');
}After async ingestion
Poll for completion (snake_case)
Parameters
Response
Developer Hints
Async vs Sync Ingestion
Polling Helper Function
Last updated