wpengine / wpengine/faustjs

feat: Better handle multiple queries

Open
#2,121 0 comments 2 reactions 0 assignees View on GitHub

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:
  • useFaustQuery adds 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 useQuery to 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 useSeedQuery utility to access the seed node anywhere under FaustProvider.
    • Another way is to wrap useQuery with useFaustQuery without restricting the capabilities of useQuery.
  • 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.