A query language for APIs: the client asks for exactly the fields it needs from a single endpoint, against a strongly typed schema. ✎ Exam: With ___, the mobile app fetches the user's name and last two orders in one request to /___.
2
New cards
Over-fetching
An endpoint returns more data than the client needs (ID, name, email, address when only the name is needed). ✎ Exam: GET /users/1 over-___: it returns the full profile but the app only shows the name.
3
New cards
Under-fetching
One endpoint isn't enough, so the client makes several calls (/users/1, then /users/1/orders, then /orders/7/items): the N+1 problem. ✎ Exam: Showing a user's orders and items ___-___ in REST: three calls instead of one.
4
New cards
Query
GraphQL operation to read data (REST analogue: GET). ✎ Exam: ___ { user(id: 1) { name } } reads the user's name.
5
New cards
Mutation
GraphQL operation to create, update or delete (REST analogue: POST/PUT/PATCH/DELETE). ✎ Exam: A ___ createOrder(...) adds an order.
6
New cards
Subscription
GraphQL operation that pushes real-time updates to the client (e.g. over WebSocket). REST has no analogue (polling). ✎ Exam: A ___ pushes the driver's location to the rider's app live.
7
New cards
Schema
In GraphQL, the strongly typed definition of all types and fields; invalid queries are rejected automatically. ✎ Exam: The GraphQL ___ rejects a query asking for a field that doesn't exist.
8
New cards
Resolver
The server function that fetches the data for one field of a GraphQL query. ✎ Exam: The orders ___ loads a user's orders from the database.
9
New cards
Single endpoint
GraphQL exposes one ___ (e.g. POST /graphql); the query says what to return. REST has one ___ per resource. ✎ Exam: Unlike REST, GraphQL has a ___.
10
New cards
GraphQL
Scenario: A mobile app on a slow network needs a user's name plus their last 2 orders and items, without extra fields or several calls. Why: ___: one request, client chooses the fields, no over- or under-fetching.
11
New cards
Over-fetching
Scenario: The REST call returns ID, name, email and address, but the screen only shows the name. Why: ___: more data than needed.
12
New cards
Under-fetching
Scenario: To build one screen the client calls /users/1, then /users/1/orders, then /orders/7/items. Why: ___ (N+1 requests).
13
New cards
Mutation
Scenario: In GraphQL, which operation adds a new review? Why: A ___ (writes); queries only read.
14
New cards
Single endpoint
Scenario: What is the most important benefit of GraphQL in the lecture? (past MCQ) Why: Clients get exactly the data they ask for, from a ___ (no over-/under-fetching).