Link Filter
Filter entities by their relationships to other entities
Overview
The link filter lets users filter entities by their relationships to other
entities. For example, you can filter all real estate properties linked to a
specific contact like "Yannic Buchwald". It is the filter side of the unified
relation property — the free-floating links property and
any other relation property are filtered the same way.
How It Works
Automatic Activation
A relation filter appears in the filter panel for every relation property on the
type — including the built-in links property when the type enables links
(Verlinkungen section of the type settings page). There is no longer a
separate linksConfiguration flag; the filter is driven by the property's
allowedTypeIds and descriptions.
User Interface
The filter provides a two-step selection process:
- Type selection — pick which target type to filter by (e.g. "Contacts"). Restricted to the property's
allowedTypeIds, or any type when unset. - Entity selection — pick the specific target record (e.g. "Yannic Buchwald").
Filter Logic
When a relation filter is applied:
- The system queries the
relationscollection for edges that involve the selected target and are tagged with the filtered property. - It extracts the IDs of the current-collection records on the other side of those edges.
- The data view is filtered to
{ id: { $in: [...] } }.
This logic lives in the shared, pure resolveRelationFilterIds helper
(packages/shared/src/typesystem/types/relation-property.ts).
Example Use Cases
Real Estate and Contacts
- Scenario: Real estate properties linked to contacts (agents, owners, managers).
- Usage: Filter all properties where "Yannic Buchwald" is linked.
- Result: Only properties with Yannic as a linked contact are displayed.
Technical Implementation
Components
RelationFilterWidget.svelte— the relation filter UI (packages/client/src/data-widgets/relation/).FilterComponent.svelte— surfaces a relation filter for each relation property.DataViewWidget.svelte— resolves the relation filter into anidselector.
Configuration
Links are configured on the type, not via a separate field. The settings page
writes a links relation property into the type's schemaOverrides; templates
and feature extensions declare it via buildLinksRelationProperty:
import { buildLinksRelationProperty } from "@smallstack/shared";
const links = buildLinksRelationProperty({
allowedTypeIds: ["contact"],
descriptions: {
contact: [
{ de: "Immobilienmakler", en: "Real Estate Agent" },
{ de: "Eigentümer", en: "Owner" }
]
}
});
// → schemaOverrides.properties.links
Testing
Unit Tests
Relation filtering logic: packages/shared/src/typesystem/types/relation-property.test.ts
(resolveRelationFilterIds). Widget tests live under
packages/client/src/data-widgets/relation/.
E2E Tests
apps/backoffice/src/e2e/features/links/ (link-filter, relation-descriptions,
entity-creation-while-linking).
Manual Testing Steps
- Create a project with the Real Estate template.
- Add some contacts (e.g. "Yannic Buchwald", "Max Mustermann").
- Add real estate properties and link them to contacts.
- Navigate to the real estate data view and open the filter panel.
- Find the Verlinkungen filter, pick "Kontakte", then a specific contact.
- Verify only linked properties are displayed.