Advanced Usage
This guide covers advanced SDK features for power users.Custom GraphQL Client
The SDK comes pre-configured to usehttps://dao.cafe/graphql, but you can create custom clients for different scenarios.
Creating a Custom Client
Adding Request Headers
Modifying Default Client Headers
If you want to add headers to all requests globally:Accessing the Default Client
Cache Invalidation
When using React hooks with TanStack Query, you can invalidate cached data to trigger refetches.Basic Invalidation
Targeted Invalidation
Invalidate only specific queries for better performance:Query Key Reference
| Export | Available Keys |
|---|---|
daoKeys | .all, .lists(), .list(params), .byManager(params), .details(), .detail(id) |
proposalKeys | .all, .lists(), .list(params), .byDAO(daoId), .active(params), .details(), .detail(id) |
voteKeys | .all, .lists(), .list(params), .byProposal(id), .byVoter(voter), .details(), .detail(id) |
delegateKeys | .all, .lists(), .byDAO(daoId), .delegationsFrom(addr), .delegationsTo(addr), .details(), .detail(id) |
tokenHolderKeys | .all, .lists(), .byDAO(daoId), .byAddress(addr), .details(), .detail(id) |
Error Handling
With React Hooks
TanStack Query provides built-in error handling:With Query Functions
Use try/catch for promise-based functions:Common Error Types
| Error | Cause | Solution |
|---|---|---|
| Network Error | No internet / API unreachable | Check connection, retry |
| GraphQL Error | Invalid query parameters | Check parameter types |
| Rate Limit | Too many requests | Add retry with backoff |
Retry Configuration
Configure TanStack Query’s retry behavior:Tree-Shaking
The SDK is designed for optimal bundle sizes. Only import what you need:Bundle Size Tips
- Import specific hooks instead of entire modules
- Use
typeimports for TypeScript types - React hooks are optional - if you don’t import them, they’re not bundled