Skip to content

Commit c27750b

Browse files
committed
fix(query): retrieve JSON:API relationship name in get relationship method
Fix #2
1 parent 3f470e9 commit c27750b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/lib/query.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,12 @@ Query.prototype.exec = async function exec() {
285285
}
286286

287287
return this.model.fromJsonApi(response.data);
288-
} else if (options.op === 'findRelationship') {
288+
} else if (options.op === 'findRelationship' && options.related) {
289+
const property = this.model.schema.relationships[options.related];
290+
const relationship = property?.name ?? options.related;
291+
289292
const response = await client.client.get<JsonApiBody<JsonApiResource | null>>(
290-
`/${this.model.type}/${options.id}/${options.related}`,
293+
`/${this.model.type}/${options.id}/${relationship}`,
291294
{
292295
params: this.buildParams(),
293296
}

0 commit comments

Comments
 (0)