인셔셔RSS 관심 있는 블로그, 뉴스, 기술 정보를 효율적으로 추적하고 읽으세요
원문 읽기 InertiaRSS에서 열기

추천 피드

阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
L
LangChain Blog
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
MyScale Blog
MyScale Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
U
Unit 42
Martin Fowler
Martin Fowler
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
博客园 - 聂微东
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
V
V2EX

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How Shared GraphQL Fragments Silently Killed Our List Per...
Ryo Tsugawa · 2026-05-24 · via DEV Community

Something felt slow

Our product backlog list page was sluggish. Not dramatically broken — just… off. The kind of slowness you notice when you switch from a fresh demo tenant to a real one with actual data.

So I measured it:

  • 8 items: 206ms TTFB (Time To First Byte)
  • 67 items: 675ms TTFB

That's a +469ms difference, or roughly 8ms per item of linear degradation. Every single backlog item added ~8ms to the response time. Not great.

The first instinct was to blame the frontend — maybe the component tree was re-rendering too aggressively. But TTFB ruled that out immediately. The browser hadn't even started rendering; the server was taking that long to respond.

So the bottleneck was somewhere between the API server and the database. Time to dig deeper.

How our preloading works

We run Go + gqlgen + GORM on Cloud Run, talking to Cloud SQL (MySQL). The GraphQL layer is designed around a simple principle:

The client requests only the fields it needs. The server preloads only what's requested.

In practice, our resolver inspects the incoming GraphQL selection set and translates it into GORM Preload() calls. If the frontend asks for tasks { assignees { user } }, the backend dutifully preloads Tasks → Assignees → User. If it only asks for tasks { backlogStatus }, we only preload Tasks → BacklogStatus.

This is the "right" design. The backend trusts the frontend to declare its data needs accurately, and responds with exactly that — no more, no less.

In theory.

What was actually happening

Here's the GraphQL query our list page was firing (simplified):

query GetProductBacklogItems($projectId: ID!) {
  productBacklogItems(projectId: $projectId) {
    edges {
      node {
        id
        name
        storyPoint
        priority
        progress
        backlogStatus { id name status }
        tasks {
          ...SubTaskFields
        }
      }
    }
  }
}

And SubTaskFields looked like this:

fragment SubTaskFields on Task {
  id
  name
  backlogStatus { id name status }
  assignees {
    user { id givenName familyName }
  }
}

See the problem? The list page was requesting tasks { ...SubTaskFields }, and SubTaskFields includes assignees { user { ... } }.

The list page doesn't display task assignees. Not a single component on that page reads task.assignees. But the query was asking for it anyway.

On the backend, this triggered a 4-level preload chain — executed once per backlog item:

Level Preload
1 Tasks
2 Tasks.BacklogStatus
3 Tasks.Assignees
4 Tasks.Assignees.User

For 67 items, that's 67 × 4 cascading database lookups. Every single one hitting Cloud SQL over the network. No wonder it was linear.

Why nobody caught it

This is the frustrating part: the Fragment was doing exactly what it was supposed to do — in a different context.

We have two views for backlog items:

  1. List view — shows name, status, story points, progress. No task-level assignee info.
  2. Detail view — shows everything, including who's assigned to each subtask.

The detail view legitimately needs assignees { user } inside SubTaskFields. That Fragment was written for the detail view, and it was correct there.

The list view just… borrowed it. Same Fragment, different context, wildly different performance characteristics.

At small scale, nobody noticed. 8 items × 4 preloads adds maybe 64ms. That's noise. But once you hit 50+ items, the linear cost becomes painfully visible.

There's another factor: local dev machines are too fast. In development, the database is either local or in a nearby Docker container — network round-trip is essentially zero. Each preload costs microseconds, so even 4 levels feel instant. In production, every preload is a network hop between Cloud Run and Cloud SQL. That per-hop latency, multiplied by 4 levels × N items, is what turned an invisible overhead into a real bottleneck.

The lesson: GraphQL Fragments are a convenience for the developer, not a contract about data needs. When you share a Fragment across views with different display requirements, you're silently opting into preloads you don't need.

The fix

Step 1: Remove the unnecessary field from the list query

The obvious move — stop asking for tasks { ...SubTaskFields } in the list query:

query GetProductBacklogItems($projectId: ID!) {
  productBacklogItems(projectId: $projectId) {
    edges {
      node {
        id
        name
        storyPoint
        priority
        progress
        backlogStatus { id name status }
        # tasks removed — list page doesn't render subtask details
      }
    }
  }
}

But there's a catch.

Step 2: The progress field still needs task data

The progress percentage on each backlog item is computed server-side from its child tasks. Specifically, it counts how many tasks are completed vs. total. To do that, the server needs to load Tasks and Tasks.BacklogStatus.

If the frontend stops requesting tasks, the backend stops preloading them, and progress silently returns 0 for everything. That's worse than slow.

Step 3: The EnhanceFields pattern

We already had an established pattern for this: field injection helpers that ensure required preloads exist regardless of what the frontend asks for. We use the same approach for project stats and team stats.

The idea is simple: before passing the requested fields to the preload layer, check whether the fields needed for server-side computation are present. If not, inject them.

func enhanceFields(fields []string) []string {
    // If the client didn't ask for "tasks" at all,
    // inject the minimum needed for progress calculation.
    if !contains(fields, "tasks") {
        fields = append(fields, "tasks", "tasks.backlogStatus")
    }
    return fields
}

In the resolver, this helper sits between the selection set parser and the preload builder:

func (r *resolver) ListItems(ctx context.Context, ...) {
    fields := enhanceFields(getRequestedFields(ctx))
    // fields is now guaranteed to include "tasks" + "tasks.backlogStatus",
    // but NOT "tasks.assignees" or "tasks.assignees.user"
    items := r.repo.FindAll(ctx, filters, fields)
    // ...
}

The key insight: the list and detail views now have asymmetric preload depths. The detail view still gets all 4 levels (the frontend asks for them). The list view gets only 2 — just enough to compute progress, without dragging in assignee data it never displays.

The result

Before After
Frontend requests tasks { backlogStatus, assignees { user } } (doesn't request tasks)
Backend preloads Tasks → BacklogStatus → Assignees → User Tasks → BacklogStatus
Preload depth 4 2
TTFB (67 items) 675ms 135ms

5× faster. The ~8ms/item linear degradation effectively disappeared.

And the best part: the detail view is completely unaffected. It still requests tasks { ...SubTaskFields }, and the EnhanceFields helper is a no-op when hasTasks is already true. Zero behavioral change for the detail page.

What I'd do differently

A few takeaways from debugging this:

  • TTFB is your first diagnostic. If TTFB scales linearly with item count, the problem is server-side. Don't waste time profiling React renders until you've ruled out the API.

  • Fragments are a DX convenience, not a data contract. The moment you share a Fragment across views that render different sets of fields, you've created an invisible coupling between those views' performance profiles. Consider having SubTaskFieldsList and SubTaskFieldsDetail instead of one shared Fragment.

  • "The server only loads what you ask for" only works if you ask correctly. GraphQL's promise of precise data fetching relies on the query author being precise. The server is faithfully doing what it's told — the problem is always in what you're telling it.

  • Linear degradation hides in small datasets. 8ms/item is invisible at 8 items. It's a wall at 100. If you only test with seed data, you'll never catch this class of issue. Profile with production-scale data counts.


This article is based on a real performance fix in Lasimban, a task management SaaS built for Scrum teams. It's free to use — no credit card required.

Try Lasimban for free → lasimban.team

Lasimban - Scrum-Focused Task Management Tool

Make Scrum development more intuitive and enjoyable. Lasimban is a Scrum-focused task management tool that shows your team the right direction.

favicon lasimban.team


Have you run into similar Fragment-sharing traps in your GraphQL setup? I'd be curious to hear how other teams handle the list-vs-detail preload split.