You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When querying multiple entities with customFieldsListQueryBuilder.parallelLoadRelations is being called. The method loads relations that are part of the original GraphQL query to make sure they don't need to be fetched sequentially. When querying multiple customFields relations only the first one will be populated due to the way the fetched relationPaths are being handled.
results.map(r => ({ relation: relationPaths[0] as keyof T, entity: r })), only writes the first relation with a common prefix to the entitiesIdsWithRelations array which is fine if the rest of the relation path are nested relations that are already part of the quer result.
In case of customFields the relationsPaths might look similar to this:
entitiesIdsWithRelations will only contain customFields.relationA and thus only populate customFields.relationA event though customFields.relationB has been fetched as well.
To Reproduce
Steps to reproduce the behavior:
Create at least two customFields with relations
Use a list query and fetch both relations simultaneously
Inspect the database queries executed to resolve the second relation in customFields
Expected behavior
The relation is not fetched on a per-parent basis but in a single query that fetches all children of all parent entities at once.
Environment (please complete the following information):
@vendure/core version: 2.1.2
Nodejs version: v18.17.0
Database (mysql/postgres etc): postgres
Additional context
A potential fix would be to write all relation paths into entitiesIdsWithRelations and add a loop during the assignment. Please let me know if you would like to accept a PR on this.
The text was updated successfully, but these errors were encountered:
Describe the bug
When querying multiple entities with
customFields
ListQueryBuilder.parallelLoadRelations
is being called. The method loads relations that are part of the original GraphQL query to make sure they don't need to be fetched sequentially. When querying multiplecustomFields
relations only the first one will be populated due to the way the fetchedrelationPaths
are being handled.The issue seems to be in the area:
https://github.com/vendure-ecommerce/vendure/blob/master/packages/core/src/service/helpers/list-query-builder/list-query-builder.ts#L486C9-L499C35
results.map(r => ({ relation: relationPaths[0] as keyof T, entity: r })),
only writes the first relation with a common prefix to theentitiesIdsWithRelations
array which is fine if the rest of the relation path are nested relations that are already part of the quer result.In case of
customFields
therelationsPaths
might look similar to this:entitiesIdsWithRelations
will only containcustomFields.relationA
and thus only populatecustomFields.relationA
event thoughcustomFields.relationB
has been fetched as well.To Reproduce
Steps to reproduce the behavior:
Expected behavior
The relation is not fetched on a per-parent basis but in a single query that fetches all children of all parent entities at once.
Environment (please complete the following information):
Additional context
A potential fix would be to write all relation paths into
entitiesIdsWithRelations
and add a loop during the assignment. Please let me know if you would like to accept a PR on this.The text was updated successfully, but these errors were encountered: