---
title: Link Filter
feature: true
featureGroup: core
featureState: ga
description: Filter entities by their relationships to other entities
date: 2026-06-05
tags: [features, filters, relationships]
---

## 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](/data/relations) — 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:

1. **Type selection** — pick which target type to filter by (e.g. "Contacts"). Restricted to the property's `allowedTypeIds`, or any type when unset.
2. **Entity selection** — pick the specific target record (e.g. "Yannic Buchwald").

### Filter Logic

When a relation filter is applied:

1. The system queries the `relations` collection for edges that involve the selected target and are tagged with the filtered property.
2. It extracts the IDs of the current-collection records on the other side of those edges.
3. 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 an `id` selector.

### 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`:

```typescript
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

1. Create a project with the Real Estate template.
2. Add some contacts (e.g. "Yannic Buchwald", "Max Mustermann").
3. Add real estate properties and link them to contacts.
4. Navigate to the real estate data view and open the filter panel.
5. Find the **Verlinkungen** filter, pick "Kontakte", then a specific contact.
6. Verify only linked properties are displayed.
