Database Functions
Leverage backend functions for complex queries that would be inefficient client-side.
Available Functionsβ
followingβ
Get accounts a user follows:
query GetFollowing($address: String!) {
following(args: { address: $address }) {
id
label
image
atom {
term_id
label
}
}
}
positions_from_followingβ
Get positions from followed accounts:
query GetPositionsFromFollowing($address: String!, $limit: Int!) {
positions_from_following(
args: { address: $address }
limit: $limit
order_by: { created_at: desc }
) {
id
shares
account { label }
vault { term_id }
}
}
search_termβ
Semantic search:
query SemanticSearch($query: String!, $limit: Int!) {
search_term(args: { query: $query }, limit: $limit) {
atom {
term_id
label
type
}
}
}
search_positions_on_subjectβ
Complex position filtering:
query SearchPositions($addresses: _text!, $searchFields: jsonb!) {
search_positions_on_subject(
args: {
addresses: $addresses
search_fields: $searchFields
}
) {
id
shares
vault { term_id }
}
}
Best Practicesβ
- Use backend functions for complex filtering
- Faster execution in database vs client
- Less data transfer over network
- More maintainable code