vuex-orm / vuex-orm-next

The next iteration of Vuex ORM.
https://next.vuex-orm.org
MIT License
189 stars 11 forks source link

Add `withAll()` and `withAllRecursive()` to Query Builder #94

Closed M3psipax closed 2 years ago

M3psipax commented 2 years ago

Type of PR:

Breaking changes:

Details

Adds withAll() and withAllRecursive() utility methods to fetch all relationships on a model.

Still needs a lot more unit tests though.

M3psipax commented 2 years ago

Hey @kiaking I reverted the changes to belongs_to_retrieve.spec.ts and created a new spec for it. I called it eager_loads instead of recursive because it does not only test withAllRecursive(), but also withAll().

If you run the test, you'll see that one is failing at: https://github.com/M3psipax/vuex-orm-next/blob/97e6ee8af47dfbb25e53127fa6d4ef43cbb3a297/test/feature/relations/eager_loads/eager_loads.spec.ts#L67

When loading only top level relations, I would expect all further relations to be filled with null, just as they would be when loading only a specific relation on an object using with("relation"). However, they seem to be undefined instead. I'm not sure why that is. Can I get some help there?

cuebit commented 2 years ago

@M3psipax i wouldn't worry about the relations being undefined, that's a wider concern as mentioned in #96.

M3psipax commented 2 years ago

Okay, I adjusted the test to allow undefined for that.

codecov[bot] commented 2 years ago

Codecov Report

Merging #94 (5963742) into master (e203096) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #94   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           36        38    +2     
  Lines         1122      1175   +53     
  Branches       164       172    +8     
=========================================
+ Hits          1122      1175   +53     
Impacted Files Coverage Δ
src/query/Query.ts 100.00% <100.00%> (ø)
src/repository/Repository.ts 100.00% <100.00%> (ø)
src/model/Model.ts 100.00% <0.00%> (ø)
src/model/attributes/relations/MorphOne.ts 100.00% <0.00%> (ø)
.../model/decorators/attributes/relations/MorphOne.ts 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e203096...5963742. Read the comment docs.

M3psipax commented 2 years ago

Hey, thanks for merging. When is the next release planned?

kiaking commented 2 years ago

As soon as the docs for this feature is ready, we can release a new version 👍

👀 @cuebit 😃