Skip to content

Commit

Permalink
fix: safely stringifies ObjectIDs while populating relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikrut committed Jun 22, 2021
1 parent 59e66c4 commit d6bc6f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/fields/relationshipPopulationPromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const populate = async ({
if (accessResult && (depth && currentDepth <= depth)) {
let idString = Array.isArray(fieldAsRelationship.relationTo) ? data.value : data;

if (typeof idString !== 'string') {
if (typeof idString !== 'string' && typeof idString?.toString === 'function') {
idString = idString.toString();
}

Expand Down

0 comments on commit d6bc6f9

Please sign in to comment.