Request Only Needed Fields
Avoid over-fetching by requesting only the fields you actually need.
Anti-Patternβ
# BAD: Fetching all fields when you only need a few
query GetAtoms {
atoms(limit: 10) {
term_id
data
label
image
emoji
type
wallet_id
block_number
created_at
transaction_hash
creator_id
creator {
id
label
image
atom_id
type
}
# ... many more fields you don't need
}
}
Best Practiceβ
# GOOD: Request only what you need
query GetAtoms {
atoms(limit: 10) {
term_id
label
image
}
}
Benefitsβ
- Faster queries: Less data to fetch and serialize
- Reduced bandwidth: Smaller response payloads
- Lower memory usage: Less data to process client-side
- Better caching: Smaller cache footprints
Tipsβ
- Start minimal and add fields as needed
- Remove unused fields from queries
- Use fragments for commonly requested field sets
- Profile queries to identify over-fetching