Skip to content

Commit cbefaed

Browse files
committedMar 12, 2025
docs: stub out guides for SchemaRecord, LinksMode, PolarisMode etc.
1 parent d69135c commit cbefaed

File tree

5 files changed

+97
-0
lines changed

5 files changed

+97
-0
lines changed
 

‎guides/reactive-data/legacy/overview.md

Whitespace-only changes.

‎guides/reactive-data/polaris/overview.md

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# LinksMode
2+
3+
-[Relationships Guide](../index.md)
4+
5+
---
6+
7+
**LinksMode** is a special feature that can be activated for any `belongsTo` or `hasMany` relationship.
8+
9+
It allows that relationship to be fetched using the standard `request` experience instead of via the legacy `adapter` interface.
10+
11+
LinksMode behaves *slightly* differently depending on whether
12+
you are using Model (including via [Legacy Mode](../../reactive-data/legacy/overview.md)) or [Polaris Mode](../../reactive-data/polaris/overview.md). We'll explain this nuance below.
13+
14+
> [!TIP]
15+
> The next-generation of reactive data which replaces Model is SchemaRecord.
16+
> SchemaRecord has two modes, Legacy - which emulates all of Model's
17+
> behaviors and APIs, and Polaris - a new experience which we intend
18+
> to make default in Version 6.
19+
20+
## Activating LinksMode
21+
22+
#### For A Relationship on a Model
23+
24+
Add `linksMode: true` to the relationship's options.
25+
26+
```ts
27+
import Model, { belongsTo, hasMany } from '@ember-data/model';
28+
29+
export default class User extends Model {
30+
@belongsTo('address', {
31+
async: false,
32+
inverse: 'residents',
33+
linksMode: true
34+
})
35+
homeAddress;
36+
}
37+
```
38+
39+
This works for both `async` and `non-async` relationships and only changes the fetching behavior the field it is defined on. So for instance, in the example above, `homeAddress` is fetched in links mode while `<Address>.residents` might still be using the legacy adapter experience.
40+
41+
#### For A SchemaRecord in LegacyMode
42+
43+
```ts
44+
import type { ResourceSchema } from '@warp-drive/core-types/schema/fields';
45+
46+
const UserSchema = {
47+
type: 'user',
48+
// this is what puts the record instance into legacy mode
49+
legacy: true,
50+
fields: [
51+
{
52+
kind: 'belongsTo',
53+
name: 'homeAddress',
54+
options: {
55+
async: false,
56+
inverse: 'residents',
57+
linksMode: true
58+
}
59+
}
60+
]
61+
} satisfies ResourceSchema;
62+
```
63+
64+
The behavior of relationships for a SchemaRecord in LegacyMode is always identical to that of Model's.
65+
66+
#### For A SchemaRecord in PolarisMode
67+
68+
```ts
69+
import type { ResourceSchema } from '@warp-drive/core-types/schema/fields';
70+
71+
const UserSchema = {
72+
type: 'user',
73+
fields: [
74+
{
75+
kind: 'belongsTo',
76+
name: 'homeAddress',
77+
options: {
78+
async: false,
79+
inverse: 'residents',
80+
linksMode: true
81+
}
82+
}
83+
]
84+
} satisfies ResourceSchema;
85+
```
86+
87+
The only difference here is that we don't mark the resource schemas as `legacy`. This puts us in the standard/default mode (`polaris`);
88+
89+
Async relationships are not supported in Polaris mode!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Relationship Polymorphism
2+
3+
-[Relationships Guide](../index.md)
4+
5+
---

‎guides/relationships/index.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Feature Overview
44
- [Inverses](./features/inverses.md)
5+
- [LinksMode](./features/links-mode.md)
6+
- [Polymorphism](./features/polymorphism.md)
7+
58
<!--
69
- [Resource Relationships]()
710
- [Collection Relationships]()

0 commit comments

Comments
 (0)