TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The Architect's Dilemma: Navigating the World of GraphQL

7 点作者 tristenharr超过 1 年前

2 条评论

andrewfromx超过 1 年前
It&#x27;s very well written and super pro-graphql. My favorite way to solve the under-fetching over-fetching problem was this method I wrote once called &quot;decorate&quot;. It would go through the entire json object recursively and look for any fields ending in _id. It would then do a sql select where id in (id1,id2,id3,etc) and replace the foo_id with just foo and the real json of a foo. And you could give it a recursive level limit so you only go 2 levels down if foo has its own thing_id as well.<p>When I added a new rest endpoint I did NOT include &quot;decorate&quot; but I waited for the ios or android developer consuming the api to ask for it. Worked out great and it avoids all the complexity that often gets PUSHED down to the ios and android developer. If the goal is to write perfect graphql that solves the under-fetch over-fetch problem better than my decorate function, you don&#x27;t end up with that. You get the mobile developers writing their dream queries and making a bigger mess! (Sometimes.)
tristenharr超过 1 年前
Hello! I’m the author of this blog, and I recently joined Hasura as a Technical Evangelist. This is one of my first blog posts and I’m new to this kind of thing so any feedback is welcome, good or bad!