3 ms·
I have noticed that what we are missing in the Frontend space is some common solution for caching and reshaping data from the api. In every codebase I have work
by faizshah 5y ago
I have noticed that what we are missing in the Frontend space is some common solution for caching and reshaping data from the api. In every codebase I have worked on we just implement this ad hoc.
We have agreed upon solutions for:
Api client (fetch, axios, react query, etc.)
Ui state management (redux, mobx, xstate etc.)
Ui frameworks (vue, react etc.)
But theres an intermediate piece between the api layer and the ui state that is always implemented ad hoc. We need some common solution to caching the api data, reshaping or querying it, and managing multi api workflows (for example a synchronous process where the frontend calls multiple microservices). Most answers to this end up being something like “get ur backend team to implement better apis” but thats not realistic in many cases.
- giancarlostoro 5y agoIndexedDB technically does this rather well unless I’m crazy, what a WebWorker really needs is a “am I even online” mode, the event handlers are one thing but browsers dont convey online state very well is what I run into. If you build a PWA though you get up to a gig of caching you wouldn't get with normal frontend DOM APIs.
- musingsole 5y agoGraphQL (coupled with get ur backend team to build it well) addresses these points. If you're a real zealot, you can use GraphQL to access and modify app state so all data operations across the stack have the same shape
- sj3k 5y agoYes! Every. Single. Time. Apollo Client is the closest thing I have used with that works decent out of the box.
- awinter-py 5y agoyes to 'reshaping' frontend schemas differ from backend schemas because they need to support sync, but it should still be possible to inherit the backend schema, transform it in predictable ways, save a lot of work 'full stack schemas' would be a 'pit of success' change IMO
- machiaweliczny 5y agoI think modern solution is https://react-query.tanstack.com/ https://react-query.tanstack.com/ Haven't tested it though yet.