Query Collections
Collection: Query Collections
User Intent
Operation
TypeScript (Canonical)
import { Graphlit } from 'graphlit-client';
import { ContentTypes, EntityState } from 'graphlit-client/dist/generated/graphql-types';
const graphlit = new Graphlit();
// Query all collections
const collections = await graphlit.queryCollections();
console.log(`Total collections: ${collections.collections.results.length}`);
collections.collections.results.forEach(coll => {
console.log(`- ${coll.name} (${coll.state})`);
});
// Search by name
const searchResults = await graphlit.queryCollections({
search: 'Documentation'
});
console.log(`\nFound ${searchResults.collections.results.length} documentation collections`);
// Get specific collection
// Replace with ID from creating a collection or from queryCollections results above
const collectionId = 'collection-id-here';
const collection = await graphlit.getCollection(collectionId);
console.log(`\nCollection: ${collection.collection.name}`);
console.log(`Created: ${collection.collection.creationDate}`);
// Count content in collection
const contents = await graphlit.queryContents({
collections: [{ id: collectionId }]
});
console.log(`Content items: ${contents.contents.results.length}`);Query all collections (snake_case)
Search by name
Get specific collection
Parameters
queryCollections (Optional Filter)
getCollection (Required)
Response
Developer Hints
Collections Don't Store Content Count
Find Collection by Name
Collection Inventory
Variations
1. List All Collections
2. Search by Name
3. Get Collection Details
4. Collection with Content Count
5. Filter Active Collections
Common Issues
Production Example
Last updated