Skip to content

Commit

Permalink
fix(core): Improved loading of eager-loaded custom field relations
Browse files Browse the repository at this point in the history
Closes #2775, Relates to #2687
  • Loading branch information
michaelbromley committed Apr 25, 2024
1 parent 3fbf4e4 commit 025a9c7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/core/src/api/config/generate-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { shopErrorOperationTypeResolvers } from '../../common/error/generated-gr
import { Translatable } from '../../common/types/locale-types';
import { ConfigService } from '../../config/config.service';
import { CustomFieldConfig, RelationCustomFieldConfig } from '../../config/custom-field/custom-field-types';
import { Logger } from '../../config/logger/vendure-logger';
import { Region } from '../../entity/region/region.entity';
import { getPluginAPIExtensions } from '../../plugin/plugin-metadata';
import { CustomFieldRelationResolverService } from '../common/custom-field-relation-resolver.service';
Expand Down Expand Up @@ -212,7 +213,17 @@ function generateCustomFieldRelationResolvers(
const eagerEntity = source[fieldDef.name];
// If the relation is eager-loaded, we can simply try to translate this relation entity if they have translations
if (eagerEntity != null) {
return customFieldRelationResolverService.translateEntity(ctx, eagerEntity, fieldDef);
try {
return await customFieldRelationResolverService.translateEntity(
ctx,
eagerEntity,
fieldDef,
);
} catch (e: any) {
Logger.debug(
`Error resolving eager-loaded custom field entity relation "${entityName}.${fieldDef.name}": ${e.message as string}`,
);
}
}
const entityId = source[ENTITY_ID_KEY];
return customFieldRelationResolverService.resolveRelation({
Expand Down

0 comments on commit 025a9c7

Please sign in to comment.