Delete
Content: Delete
User Intent
"I want to delete specific content or bulk delete multiple content items"
Operation
SDK Method:
graphlit.deleteContent(),graphlit.deleteContents(),graphlit.deleteAllContents()GraphQL:
deleteContent,deleteContents,deleteAllContentsmutationsEntity Type: Content
Common Use Cases: Remove outdated content, cleanup test data, bulk deletion by filter
TypeScript (Canonical)
import { Graphlit } from 'graphlit-client';
import { ContentTypes, EntityState, SearchTypes } from 'graphlit-client/dist/generated/graphql-types';
const graphlit = new Graphlit();
// Delete single content by ID
const response = await graphlit.deleteContent('content-id-here');
if (response.deleteContent?.id) {
console.log(`Deleted content: ${response.deleteContent.id}`);
}
// Delete multiple specific content items (by IDs)
const contentIds = ['id-1', 'id-2', 'id-3'];
const bulkResponse = await graphlit.deleteContents(
contentIds,
true // isSynchronous - wait for deletion to complete
);
console.log(`Deleted ${contentIds.length} content items`);
// Delete ALL content (use with caution!)
const deleteAllResponse = await graphlit.deleteAllContents(
true // isSynchronous
);
console.log('All content deleted');Delete single content (snake_case method)
response = await graphlit.deleteContent(id="content-id-here")
Delete multiple content items
content_ids = ["id-1", "id-2", "id-3"] bulk_response = await graphlit.deleteContents( ids=content_ids, is_synchronous=True )
Delete all content
delete_all_response = await graphlit.deleteAllContents( is_synchronous=True )
Parameters
deleteContent
id(string): Content ID to delete
deleteContents
ids(string[]): Array of content IDs to deleteisSynchronous(boolean): Wait for deletion to completeDefault:
falseRecommended:
truefor immediate confirmation
deleteAllContents
filter(ContentFilter): Optional filter to delete subset of contentIf omitted, deletes ALL content in project
isSynchronous(boolean): Wait for deletion to completeDefault:
falseRecommended:
true
Response
Developer Hints
Deletion is Permanent
There is NO undo for delete operations:
Best Practice: Query first, confirm IDs, then delete:
Synchronous vs Asynchronous Deletion
For bulk operations, asynchronous can be faster, but you won't know if/when deletion completes.
🚨 deleteAllContents with Filters
⚡ Performance Considerations
For large deletions (>100 items):
Use
deleteAllContentswith filter (faster than individual deletes)Use
deleteContentswith batches (more control than deleteAll)
Variations
1. Delete Content by Filter (Conditional Deletion)
Delete content matching specific criteria:
2. Delete Old Content (Cleanup)
Remove content older than a certain date:
3. Delete Content from Specific Feed
Remove all content from a feed before deleting the feed:
4. Batch Delete with Progress Tracking
Delete large number of items with progress updates:
5. Safe Delete with Confirmation
Implement confirmation in production:
6. Delete Test Data
Clean up after testing:
7. Delete by Collection
Remove all content in a specific collection:
Common Issues
Issue: Content not found when deleting
Solution: Content may have already been deleted or ID is incorrect. Check with getContent() first.
Issue: Deletion returns success but content still appears in queries
Solution: If using isSynchronous: false, deletion happens in background. Wait a few seconds or use synchronous mode.
Issue: Cannot delete content with "Content is locked" error Solution: Content may be part of an active feed or workflow. Disable/delete the feed first.
Issue: deleteAllContents deletes too much
Solution: Always use a filter when calling deleteAllContents:
Issue: Bulk delete times out
Solution: Delete in smaller batches (50-100 items per batch) or use isSynchronous: false.
Production Example
Single deletion:
Bulk deletion:
Filtered deletion with count:
Last updated
Was this helpful?