KEEP LEARNING
Build the bigger picture.
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
Tips > Building Workflows
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:
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"
}
}
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" }
}
}
]
}
}
]
}
}
}
}
Compare the data volume:
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
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 · Use Edit Fields in "Map Each" Mode for Simple Renames
KEEP LEARNING
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
APPLY IT TO YOUR SYSTEM
Bring the process, the tools involved and an example of where the current workflow gets stuck.