Use Database Functions
Use backend functions for complex queries instead of client-side filtering.
Anti-Patternβ
# BAD: Manual filtering for social queries
query GetFollowingManually($address: String!) {
my_positions: positions(where: { account_id: { _eq: $address } }) {
vault {
term {
triple {
# Complex filtering in application code...
}
}
}
}
}
Best Practiceβ
# GOOD: Using database functions
query GetFollowingEfficiently($address: String!) {
following(args: { address: $address }) {
id
label
atom {
term_id
label
}
}
}
Available Functionsβ
following: Get accounts a user followspositions_from_following: Social feed of positionssearch_term: Semantic searchsignals_from_following: Activity from followed accounts
Benefitsβ
- Faster execution: Runs in database
- Less data transfer: Filtered server-side
- More maintainable: Logic in one place