-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Description
As identified in PR #32 review, the centralized GraphQL queries in queries.py could benefit from optimization features to reduce payload size and improve performance.
Current State
- All queries are static and fetch all available fields
- No support for query batching
- No ability to select specific fields
Proposed Solutions
1. Query Fragments
Define reusable fragments for common field sets:
fragment CharacterBasic on Character {
id
name
server { name slug }
}
fragment CharacterDetailed on Character {
...CharacterBasic
lodestoneID
canonicalID
hidden
}2. Field Selection
Allow users to specify which fields to include:
# Only get name and server
character = await client.get_character_by_id(
id=12345,
fields=['name', 'server.name']
)3. Query Batching
Support multiple operations in a single request:
# Batch multiple character lookups
results = await client.batch_query([
client.prepare_query('get_character_by_id', id=12345),
client.prepare_query('get_character_by_id', id=67890),
])Implementation Notes
- Maintain backward compatibility (default to full queries)
- Consider using graphql-core for dynamic query building
- Cache commonly used query variations
- Ensure type safety is maintained
Benefits
- Reduced network payload
- Improved response times
- Lower API usage for rate-limited accounts
- More efficient for mobile/limited bandwidth scenarios
Challenges
- Dynamic query generation complexity
- Type safety with partial responses
- Documentation of available fields
References
- PR Release v0.2.0b1 - First Beta Release #32 review feedback
- GraphQL best practices for query optimization
Metadata
Metadata
Assignees
Labels
No labels