Skip to content

Commit 8ad51f6

Browse files
committed
serialize to relative url only when id does not exist
set null only when card.id does not exist
1 parent 58676fa commit 8ad51f6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/base/card-api.gts

+3-1
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,12 @@ class Contains<CardT extends FieldDefConstructor> implements Field<CardT, any> {
697697
serialize(
698698
value: InstanceType<CardT>,
699699
doc: JSONAPISingleResourceDocument,
700+
_visited: Set<string>,
701+
opts?: SerializeOpts,
700702
): JSONAPIResource {
701703
let serialized: JSONAPISingleResourceDocument['data'] & {
702704
meta: Record<string, any>;
703-
} = callSerializeHook(this.card, value, doc);
705+
} = callSerializeHook(this.card, value, doc, undefined, opts);
704706
if (primitive in this.card) {
705707
return { attributes: { [this.name]: serialized } };
706708
} else {

packages/host/app/services/card-service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ export default class CardService extends Service {
213213
// for a brand new card that has no id yet, we don't know what we are
214214
// relativeTo because its up to the realm server to assign us an ID, so
215215
// URL's should be absolute
216-
maybeRelativeURL: null, // forces URL's to be absolute.
216+
maybeRelativeURL: card.id ? undefined : null, // forces URL's to be absolute when no ID
217217
});
218+
218219
// send doc over the wire with absolute URL's. The realm server will convert
219220
// to relative URL's as it serializes the cards
220221
let realmURL = await this.getRealmURL(card);

0 commit comments

Comments
 (0)