This Pull Request introduces several changes to address a key issue and improve the functionality and testing of the application:
Problem Solved: The application was previously unable to handle queries for a resource with multiple nested resources simultaneously. If multiple nested resources were included in the query, only the last one was returned. This issue has been resolved with the changes in this PR.
Enhancement in knex-processor.ts: The parseOperationIncludedRelationships function has been updated to ensure that the acumRelationships object correctly accumulates relationships without overwriting existing ones. This is achieved by spreading the existing relationships before adding a new one. This change is part of the solution to the problem described above.
Refactoring in serializer.ts: The serialization process has been simplified. Previously, the code was creating a new array with unique type_id combinations from includedData and then mapping over this array to find the corresponding items in includedData. This has been replaced with a direct return of includedData, which simplifies the code and may improve performance.
Addition of a new test in nestedResources.test.ts: A new test has been added to verify the correct retrieval of the first article's author's votes and comments. This test will help ensure that the application's data retrieval and serialization processes are working as expected, and that multiple nested resources can be retrieved simultaneously.
This Pull Request introduces several changes to address a key issue and improve the functionality and testing of the application:
Problem Solved: The application was previously unable to handle queries for a resource with multiple nested resources simultaneously. If multiple nested resources were included in the query, only the last one was returned. This issue has been resolved with the changes in this PR.
Enhancement in
knex-processor.ts
: TheparseOperationIncludedRelationships
function has been updated to ensure that theacumRelationships
object correctly accumulates relationships without overwriting existing ones. This is achieved by spreading the existing relationships before adding a new one. This change is part of the solution to the problem described above.Refactoring in
serializer.ts
: The serialization process has been simplified. Previously, the code was creating a new array with uniquetype_id
combinations fromincludedData
and then mapping over this array to find the corresponding items inincludedData
. This has been replaced with a direct return ofincludedData
, which simplifies the code and may improve performance.Addition of a new test in
nestedResources.test.ts
: A new test has been added to verify the correct retrieval of the first article's author's votes and comments. This test will help ensure that the application's data retrieval and serialization processes are working as expected, and that multiple nested resources can be retrieved simultaneously.