newOS for Developers
Back to Graph Traversal
Folder Posts Edge
Get posts in a folder via edge traversal
beginner
folder+{id}+attachment+postOverview
The folder→posts edge is the most common graph traversal pattern. It returns all posts attached to a specific folder (mood).
This powers mood galleries, post grids, and content browsing.
Edge Pattern
// Edge key
folder+{folderId}+attachment+post
// Example
folder+abc123+attachment+post
// Returns array of post IDs
["post-1", "post-2", "post-3"]Usage Example
import { readPosts } from "@newgraph-signals/actions/folder";
// Get posts in a folder using the action
const posts = readPosts({ folderId: "abc123" });
// The action uses edge traversal internally
effect(() => {
posts.value.forEach(post => {
console.log(post.title, post.contentUrl);
});
});
// Direct edge query
import { getEdges } from "@/lib/cache";
const postIds = await getEdges(
"folder",
"abc123",
"attachment",
"post"
);
// Then fetch full post data
const fullPosts = await Promise.all(
postIds.map(id => getPost({ id }))
);Response Schema
// From readPosts() action
{
value: [
{
id: string;
title: string;
description: string;
contentUrl: string;
contentType: string; // "image" | "video" | "text"
author: {
id: string;
username: string;
};
folder: {
id: string;
title: string;
};
created: string;
watts: number;
}
]
}Graph Structure
┌──────────┐
│ Folder │ (mood)
└────┬─────┘
│ attachment (edge)
▼
┌──────────┐
│ Post │ (content)
├──────────┤
│ Post │
├──────────┤
│ Post │
└──────────┘