# GraphQL basics

> How GraphQL works and why the Loco API uses it.

Source: https://docs.gastrogate.io/docs/concepts/graphql

GraphQL lets you ask for exactly the data you need, in one request, from one endpoint.

## Queries read, mutations write

- **Queries** fetch data. See all [queries](https://docs.gastrogate.io/docs/api.md#queries).
- **Mutations** change data. See all [mutations](https://docs.gastrogate.io/docs/api.md#mutations).

## You choose the shape

The response mirrors your query. If you only select `id`, you only get `id`:

```graphql
query { me { id } }
```

## Types

Every field has a type. A trailing `!` means the value is never null, and `[T]` means a list of `T`. Click any type in the [reference](https://docs.gastrogate.io/docs/api.md) to see its fields.

## Variables

Pass dynamic values as variables rather than string-building queries:

```graphql
query Restaurant($id: ID!) {
  restaurant(id: $id) { id }
}
```

```json
{ "id": "…" }
```
