Poll for Completion
Content: Poll for Completion
User Intent
"I want to know when content processing has finished"
Operation
SDK Method:
graphlit.isContentDone()GraphQL:
isContentDonequeryEntity Type: Content
Common Use Cases: Wait for async ingestion, check processing status
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
content_response = await graphlit.ingestUri( uri="https://example.com/document.pdf", is_synchronous=False )
content_id = content_response.ingest_uri.id
Poll for completion (snake_case)
is_done = False attempts = 0 max_attempts = 60
while not is_done and attempts < max_attempts: status = await graphlit.isContentDone(content_id) is_done = status.is_content_done.result if status.is_content_done else False
if is_done: print(" Content processing complete!")
Parameters
id(string): Content ID to check
Response
Developer Hints
Async vs Sync Ingestion
Polling Helper Function
Last updated
Was this helpful?