Skip to content

feat: Better handle multiple queries #2121

@ahuseyn

Description

@ahuseyn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    🆕 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions