GraphQL Query

GraphQL 질의

Clients select the fields they need, and responses follow that selection.

···
html
<div class="viz"><h3>SELECT FIELDS</h3><div class="row"><div class="box code" id="query">product { name }</div><span class="arrow">→</span><div class="box code" id="data">{ name: "Pen" }</div></div><div class="muted" id="size">1 field · smaller response</div></div>
css
.viz{width:94%;height:88%;max-width:960px;padding:clamp(10px,2vmin,18px);border:1px solid var(--line);border-radius:14px;background:var(--surface);font:600 clamp(12px,1.35vw,16px)/1.35 var(--font-sans,system-ui,sans-serif);display:flex;flex-direction:column;gap:clamp(7px,1.8vmin,13px);overflow:hidden}.viz h3{margin:0;color:var(--accent);font:700 clamp(12px,1.35vw,16px)/1.2 var(--font-sans,system-ui,sans-serif);letter-spacing:.04em}.viz .row{display:flex;align-items:center;justify-content:center;gap:clamp(5px,1.4vmin,12px);flex:1;min-height:0}.viz .box{padding:clamp(5px,1.5vmin,12px);border:1px solid var(--line);border-radius:9px;background:var(--bg);text-align:center}.viz .muted{color:var(--muted)}.viz .accent{color:var(--accent)}.viz .code{font-family:ui-monospace,monospace}.viz .pill{padding:3px 7px;border:1px solid var(--line);border-radius:99px;white-space:nowrap}.viz .active{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 12%,var(--surface))}.viz .arrow{color:var(--accent);font:700 18px ui-monospace,monospace}#query,#data{max-width:45%;overflow-wrap:anywhere}
js
let more=false;function draw(){more=!more;document.getElementById('query').textContent=more?'product { name price }':'product { name }';document.getElementById('data').textContent=more?'{ name: "Pen", price: 3 }':'{ name: "Pen" }';document.getElementById('size').textContent=more?'2 fields · larger response':'1 field · smaller response'}draw();setInterval(draw,1700)

A GraphQL query selects fields from schema types. The server resolves that selection and returns a matching response shape. Screens with different data needs can adjust the query instead of adding a new endpoint for each shape.

In the demo, selecting price alongside name expands both the response tree and payload size. Flexible selection does not make every query cheap or authorized; control depth, complexity, and field access.

When to use

Use it when different screens often need different subsets of the same entities.

Open as page ↗