Open tianyingchun opened 2 years ago
We are also experiencing this issue. When data is being loaded ListQueryBuilder
the method parallelLoadRelations
joins customFields.[translatableRelationName]
but not the nested translations
. If the property was null, the relation would be loaded here: https://github.com/vendure-ecommerce/vendure/blob/master/packages/core/src/api/config/generate-resolvers.ts#L184 which happens when single entities are being loaded.
I see two possible angles to fix this and would be open to create a PR.
customFieldResolver
by detecting if a language relation exists in the TypeORM metadata. If the property is null in this case the entity should be reloaded using the existing functionality.ListQueryBuilder
- however as I understand it should be on the same abstraction level as TypeORM so it should probably not include logic for language.As I already worked on solution 1 while debugging I will create a PR based on that idea. But if you see a better way or prefer solution 2 please let me know.
While writing a test using default entities I noticed that this issue does not occur on stock entities. There are already field resolvers in place for this case. I just had to add them to our custom entities. 🤦🏽♂️
e.g. the product resolver has:
@ResolveField()
name(@Ctx() ctx: RequestContext, @Parent() product: Product): Promise<string> {
return this.localeStringHydrator.hydrateLocaleStringField(ctx, product, 'name');
}
Describe the bug Can not editing collection while customized fields with relation type (with translations)
To Reproduce Steps to reproduce the behavior:
campaign (relation type)
oncollection
as belowEnvironment (please complete the following information):
Additional context for Admin UI
/catalog/collections
Editing
button before redirect to collect detail page.If we expose graphql
Campaign
propertyname
asoptional
,( name: String!)==> (name: String) the admin works fine, other wise throw me error.