getsentry / sentry

Developer-first error tracking and performance monitoring
https://sentry.io
Other
39.18k stars 4.2k forks source link

[Perf Issue Idea] Data fetchers inside components #59990

Open nanoburd opened 1 year ago

nanoburd commented 1 year ago

Problem Statement

From this tweet: https://twitter.com/thdxr/status/1724417895763980306

i have a question but it's going to take some explaining so bear with me

with frameworks like remix or astro, you are asked to define all of the data requirements for a route at the top of the request

developers don't love this because when you add a new component to the page, you have to think about what data it needs and make sure you load it and pass it through

basically it's not as composable and you can't solely declare data requirements near the components

to try and solve this RSCs let you define fetchers inside your components and they'll automatically be run during rendering

at the route level you don't have to do anything, can drop a component in and the data will get loaded

so here's my question - doesn't this lead to all the same pains that graphql has like n+1 queries? a component is a resolver, and your component tree is the query

eg if you have a FriendsList component which fetches a list of friend ids and that renders 20 Friend components which does 20 round trips to the database

moving rendering away from edge doesn't solve this - you'll have to use things like data loaders

wasn't relay invented to allow for defining data requirements near the component but allow for a single query to be hoisted at compile time?

the route data model seems a lot simpler in comparison, accept you have to be explicit and you control exactly what happens per route

Solution Brainstorm

No response

Product Area

Performance

getsantry[bot] commented 1 year ago

Routing to @getsentry/product-owners-performance for triage ⏲️

nanoburd commented 1 year ago

This is for backlog consideration