reststate / reststate-vuex

Zero-configuration web service client for Vuex
https://vuex.reststate.codingitwrong.com
Other
72 stars 19 forks source link

Support Compound Documents #21

Open mhluska opened 5 years ago

mhluska commented 5 years ago

It would be nice if the library could support compound documents and automatically restructure the data so that I can do user.todos if user is my primary resource with included todo resources.

CodingItWrong commented 5 years ago

Thanks for your suggestions, I should be able to respond to them in detail tomorrow morning!

CodingItWrong commented 5 years ago

I use compound documents as well, so this'd definitely be useful. I think it'll take some nontrivial restructuring of the library, because right now each store module is pretty independent, whereas to support compound documents the modules would need to know about one another. I'll think through what changes could be made to support this.

cmygray commented 5 years ago

there are two options:

  1. store included within the record(along with data)
    • need to pass the whole results to STORE_RECORD, STORE_RECORDS mutations
  2. store included to another store module
    • need to create a new mutation which committed from parent's store module
    • use mutation with { root: true } option OR dynamically attach a new module

Or, there can be the relationships store module knows the relation of other modules each other.

cmygray commented 5 years ago

Currently, related getters of primary resource module are not used. But I think, they should be used to get related resource from the other module.

As is:

To be:

mrcage commented 5 years ago

It would be really great if this feature could be implemented; there is a PR for it. It would save a lot of requests / data in my use case

CodingItWrong commented 5 years ago

@mrcage I agree; I've run into the same pain point on my own apps.

I've just taken some time to implement a first shot at handling relationships in a way I think fits best with how the library is set up.

@cmygray before I publish the info publicly I'll compare with your PR to see if there's anything from it I want to pull. Thanks for creating that PR as a demonstration that this feature was doable. I haven't included pluralization; I'll consider whether we want to include that separately.

@mrcage @cmygray @mhluska I haven't yet included the documentation in the doc site, but you can see how included records work in #122, in its description and in the tests that it adds. If you'd like to give version 0.1.2 it a try to see if it matches your use case, I'd be happy to know about other things that are needed.

CodingItWrong commented 5 years ago

Also I'll give it a try on my own app using reststate-vuex, to try to find any bugs or missing edge cases.

CodingItWrong commented 3 years ago

FYI, this library will be unmaintained going forward.

If you need new features or fixes, I recommend forking the repo and making changes, or finding an alternate library that meets your needs.