When an API supports GraphQL, use it instead of REST.
When an API supports GraphQL, use it instead of REST. GraphQL lets you request exactly the fields you need in a single request, eliminating over-fetching (receiving 50 fields when you need 3) and under-fetching (needing a second request to get related data). The HTTP Request node works fine for GraphQL, but the dedicated approach makes queries more readable.
Real-world example: You need to fetch GitHub pull requests with their reviews and check statuses. With REST, this requires 3 separate API calls per PR. With GraphQL, it is one request.
URL: https://api.github.com/graphql
Method: POST
Headers:
Authorization: Bearer {{ $credentials.githubToken }}
Body:
```text
```json title="GraphQL Request Body"
{
"query": "query($owner: String!, $repo: String!) { repository(owner: $owner, name: $repo) { pullRequests(last: 10, states: OPEN) { nodes { number title createdAt author { login } reviews(last: 5) { nodes { state author { login } } } commits(last: 1) { nodes { commit { statusCheckRollup { state } } } } } } } }",
"variables": {
"owner": "my-org",
"repo": "my-repo"
}
}
```text
```json title="Response: Everything in One Request"
{
"data": {
"repository": {
"pullRequests": {
"nodes": [
{
"number": 142,
"title": "Add user authentication",
"createdAt": "2025-01-14T09:00:00Z",
"author": { "login": "developer123" },
"reviews": {
"nodes": [
{ "state": "APPROVED", "author": { "login": "reviewer1" } }
]
},
"commits": {
"nodes": [
{
"commit": {
"statusCheckRollup": { "state": "SUCCESS" }
}
}
]
}
}
]
}
}
}
}
```text
Compare the data volume:
```text title="REST vs GraphQL Comparison"
REST approach:
Request 1: GET /repos/{owner}/{repo}/pulls -> 50 KB (all PR fields)
Request 2: GET /repos/{owner}/{repo}/pulls/142/reviews -> 12 KB
Request 3: GET /repos/{owner}/{repo}/commits/{sha}/status -> 8 KB
Total: 3 requests, ~70 KB, 3 round trips
GraphQL approach:
Request 1: POST /graphql (query above) -> 2 KB response
Total: 1 request, ~2 KB, 1 round trip
```text
GraphQL is especially valuable for workflows that process many records, where the per-record overhead of multiple REST calls adds up to significant execution time and API rate limit consumption.
**Related:** [Use Path Parameters in Webhook URLs for Dynamic Routing](../webhook-mastery/01-use-path-parameters-in-webhook-urls-for-dynamic-routing.md) | [Use Edit Fields in "Map Each" Mode for Simple Renames](../data-transformation/01-use-edit-fields-in-map-each-mode-for-simple-renames.md)
I build production n8n and Cloudflare automation for teams — the same engineering behind HarperFlow. Fixed-price, escrow-protected, US-based.