The Simplicity of tRPC with the Power of GraphQL | HackerNoon

United States News News

The Simplicity of tRPC with the Power of GraphQL | HackerNoon
United States Latest News,United States Headlines
  • 📰 hackernoon
  • ⏱ Reading Time:
  • 80 sec. here
  • 3 min. at publisher
  • 📊 Quality Score:
  • News: 35%
  • Publisher: 51%

- cc: stefantmd jensneuse_de graphql trpc

explained this diagram in depth and at first glance, it makes a lot of sense. tRPC doesn't require a compile-time step, the developer experience is incredible, and it's a lot simpler than GraphQL.

If we were to use tRPC, we would create a "procedure" to load all this data in one go. We'd call this procedure at the top of the page and then propagate the data down to the components.import { trpc } from '../utils/trpc' export function NewsFeed { const feed=trpc.newsFeed.useQuery return }export function NewsFeedList { return => )} {feed.

Keep in mind that this is just one single page. What happens if we add similar but slightly different pages? Does this approach scale well if we're adding more and more pages? Does this not sound like the problem we've had with REST APIs? We've even got famous names for these problems, like Overfetching and Underfetching, and we haven't even gotten to the point where we're talking about the N+1 problem.

Let's look at the same example using GraphQL, Fragments, and Relay. For laziness reasons, the code is not 100% correct because I'm using Copilot to write it, but it should be very close to what it would look like in a real app.Next, let's look at the feed list component. The feed list component declares a fragment for itself, and includes the fragment for the feed item component.

It's important to understand that this is a trade-off. There's no free lunch. The simplicity of tRPC comes at the cost of flexibility. Both REST and GraphQL are built with collaboration in mind. Not all teams will be using TypeScript, and if you're crossing company boundaries, you'll want to expose APIs in a way that's easy to understand and consume.

We have summarized this news so that you can read it quickly. If you are interested in the news, you can read the full text here. Read more:

hackernoon /  🏆 532. in US

United States Latest News, United States Headlines

Similar News:You can also read news stories similar to this one that we have collected from other news sources.

NASA Wants to Power Moon Missions With Nuclear Power Within 10 YearsNASA Wants to Power Moon Missions With Nuclear Power Within 10 YearsNASA is calling on private firms to develop the technology.
Read more »

Power Polls: Northeast Florida high school basketball and soccer power rankings, Dec. 11Power Polls: Northeast Florida high school basketball and soccer power rankings, Dec. 11The Times-Union highlights top high school boys and girls basketball and soccer teams across Northeast Florida through Saturday, December 10 games.
Read more »

House committee's first-ever documentary taps into 'immense power' of personal stories to spotlight economic disparityHouse committee's first-ever documentary taps into 'immense power' of personal stories to spotlight economic disparityU.S. lawmakers tasked with examining economic inequality will premiere a first-of-its-kind documentary film Tuesday evening in Washington, D.C., featuring three American stories from across the country.
Read more »

Live blog: US sends first shipment of power gear to aid UkraineLive blog: US sends first shipment of power gear to aid UkraineUS ships first part of its power equipment aid to Ukraine, US officials say, as Washington works to support the country's energy infrastructure against intensifying attacks from Russia Follow our live coverage:👇
Read more »

Editorial: N.C. grid attack calls for vigilance, actionEditorial: N.C. grid attack calls for vigilance, actionThe domestic terrorist attack on two power substations in North Carolina urges more...
Read more »



Render Time: 2025-03-09 20:33:14