feat: Better handle multiple queries
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 155
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 20
Description
We should come up with a better solution to handle multiple queries in Faustjs. Discussion around useFaustQuery and multiple queries: #2110
Summary:
useFaustQueryadds an elegant way to access multiple queries on client side.
- But it don't support to get the same queries with different variables.
- It's also adding a duplicate cache, where we already have the same data in Apollo cache.
We can use Apollo's
useQueryto access server-fetched data with more control.
- To do this we need to have the correct query variables that server uses to fetch data, mostly based on seed query.
- Template passes seed query data inside props. But it's not a developer friendly way to access that data, also requires prop drilling for child components.
Next steps:
A better way to access the data on client side should be explored.
- One option is to have
useSeedQueryutility to access the seed node anywhere underFaustProvider.- Another way is to wrap useQuery with
useFaustQuerywithout restricting the capabilities ofuseQuery.We should avoid breaking changes.
We may consider a config option to disable useFaustQuery-related cache for those who want it.
We should well document the capabilities of Faust for the multiple queries.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the discussion in #2110 and inspect the existing useFaustQuery and FaustProvider paths described in the issue. Compare the proposed useSeedQuery and useQuery approaches, then define a solution that supports the same query with different variables, avoids duplicate caching, preserves existing behavior, and documents multiple-query usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100