🔌GraphQL
Also known as GraphQL API, Graph Query Language
A way to ask an API for just the fields you want, in one go.
Think of it like
Think of it like a buffet. You fill your plate with just the dishes you want, in one trip.
Example
Lucy's phone app needs a user's name and their last 3 orders. One GraphQL query fetches both, with no extra fields.
Why it matters
Apps on slow phone networks can fetch just what one screen needs in a single trip.
Definition
Example code
graphql
{
user(id: 42) {
name
orders(last: 3) { total }
}
}Common mistake
Key takeaways
- 1Ask for exact fields. No more, no less.
- 2One address. Every query goes there.
- 3A schema lists it all. Every type and field.