GraphQL & GAP Basics
New to GraphQL or agent gateways? This zero-jargon guide builds your intuition from scratch: why AI agents benefit from one unified menu, how Types work like labeled boxes, and how a query mirrors JSON 1:1.
What you'll learn
- Visualize a GAP Supergraph as a single coordinated order counter in front of REST, SQL, gRPC, MCP, and Code backends.
- Read schemas effortlessly: Object types (
shop_CustomersResult), Scalars (Int,String,JSON), Enums, Lists, and Non-Null (!). - Use the Interactive Query Builder below to toggle fields and watch valid GAP-QL match its JSON output 1:1.
On this page
Mental Model: One Order Counter vs. Twenty Separate Vendors
Imagine an AI assistant is a dinner guest arriving at a busy food court with twenty specialized kitchens: one serves customer profiles (REST API), another tracks shipping orders (SQL database), and a third keeps support notes (MCP server).
- Without GAP (Flat Direct-MCP): Before taking a single order, the host hands the agent every binder from all 20 kitchens at once—hundreds of thousands of tokens of repetitive JSON schemas. Worse, combining a customer with their notes forces the agent to walk back and forth turn-by-turn.
- With GAP (A Typed Supergraph): GAP places one unified, menu-indexed order counter in front of every backend. Instead of memorizing every recipe up front (
203,421tokens at 1,000 tools), the agent holds 5 tiny ordering tools (651 tokens), looks up only the dish it needs, and submits one structured request.
Types Are Labeled Shipping Boxes (! Means Guaranteed)
Every GraphQL and GAP schema is just a contract describing which labeled boxes exist and what fits inside each box:
| Building Block | Schema Example | Plain Meaning |
|---|---|---|
| Object Type | type shop_CustomersResult { id: Int! name: String! tier: ... } | A structured record representing one domain entity (like a customer row from OpenAPI). |
| Scalar | Int, String, Boolean, JSON | A leaf value where selection stops—there are no deeper nested { ... } subfields inside a scalar. |
Non-Null (!) | id: Int! vs. name: String | The exclamation mark guarantees GAP will never return null for that field on success. |
List ([...]) | orders(customer_id: Int): [shop_OrdersResult!] | Returns zero or more items of that type in an array. |
| Enum | shop_CustomersResultTier (vip, standard) | A fixed allowlist of string values validated before hitting backends. |
Going deeper: Why does customer_notes(customer_id: 1) have NO curly braces after it?
In examples/walking-skeleton, the OpenAPI REST endpoints (shop_CustomersResult, shop_OrdersResult) compile into strongly typed Object types whose subfields you select inside { id name tier }. By contrast, external MCP tool customer_notes(customer_id: Int!): JSON returns the custom JSON leaf scalar—so writing customer_notes(customer_id: 1) { notes } triggers a GraphQL validation error! Treat scalars as leaves with zero brace sub-selection.
How a Query Mirrors Its JSON 1:1 (Interactive Builder)
Unlike REST URLs where the server guesses which 40 fields you want, a GAP-QL query acts like a fillable JSON template: every field you ask for comes back in the exact same nesting shape, and unrequested fields stay off the wire.
Click Fields to Build a Live Walking Skeleton Query
1 GAP request · vs. 3 Direct callsquery {
customer(id: 1) {
id
name
tier
}
customer_notes(customer_id: 1)
}
{
"data": {
"customer": {
"id": 1,
"name": "Ada Lovelace",
"tier": "vip"
},
"customer_notes": {
"customer_id": 1,
"notes": [
{
"note_id": "n-1",
"summary": "Prefers consolidated monthly invoice"
}
]
}
}
}
Continue to Arguments, Mutations & Joins or start coding right away in GAP Academy.