Skip to content

Commit

Permalink
use absolute url in query
Browse files Browse the repository at this point in the history
  • Loading branch information
burieberry committed Dec 17, 2024
1 parent b12c0a0 commit 4e796e8
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions packages/experiments-realm/blog-app.gts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
getCard,
SupportedMimeType,
type LooseSingleCardDocument,
relativeURL,
} from '@cardstack/runtime-common';
import {
type SortOption,
Expand Down Expand Up @@ -372,25 +371,13 @@ class BlogAppTemplate extends Component<typeof BlogApp> {
};
filter.cardRef = cardRef;

let realmUrl = this.args.model[realmURL];
if (!this.args.model.id || !realmUrl?.href) {
throw new Error(`Missing card id or realm url`);
}
let relativeTo = relativeURL(
new URL(this.args.model.id),
new URL(`${cardRef.module}/${cardRef.name}`),
realmUrl,
);
if (!relativeTo) {
throw new Error(`Missing relative url`);
if (!this.args.model.id) {
throw new Error(`Missing card id`);
}
filter.query = {
filter: {
on: cardRef,
any: [
{ eq: { 'blog.id': this.args.model.id } },
{ eq: { 'blog.id': relativeTo } },
],
eq: { 'blog.id': this.args.model.id },
},
};
}
Expand Down

0 comments on commit 4e796e8

Please sign in to comment.