Apply Fetcher Pattern to Strawberry GraphQL Resolvers
Motivation
Currently, some GraphQL resolvers use delayed imports within resolver functions to prevent cyclic imports. This pattern reduces code readability and mixes business logic with resolver definitions, making maintenance difficult.
By introducing fetcher.py in the artifact module and separating data fetching logic, we achieved:
-
Resolution of cyclic import issues
-
Resolvers focus only on request handling/routing
-
Fetchers focus only on data retrieval logic
-
Type definition files (
types.py) can safely import fetchersWe aim to apply this pattern consistently across other Strawberry GraphQL modules to improve codebase consistency and maintainability.
Objective
Apply the fetcher pattern to all non-federated Strawberry GraphQL modules under src/ai/backend/manager/api/gql/:
- Create
fetcher.pyfile for each module - Separate data retrieval logic from resolvers into fetchers
- Rename
resolve_*functions tofetch_*and move them - Move pagination spec helper functions to fetchers
Expected Sub Issues
- [ ] Apply fetcher pattern to
huggingface_registrymodule - [ ] Apply fetcher pattern to
reservoir_registrymodule - [ ] Apply fetcher pattern to
scaling_groupmodule - [ ] Apply fetcher pattern to
notificationmodule - [ ] Apply fetcher pattern to
model_deploymentmodule - [ ] Apply fetcher pattern to
storage_namespacemodule - [ ] Apply fetcher pattern to
object_storagemodule - [ ] Apply fetcher pattern to
vfs_storagemodule - [ ] Apply fetcher pattern to
schedulermodule - [ ] Apply fetcher pattern to
background_taskmodule - [ ] Apply fetcher pattern to
agent_statsmodule - [ ] Apply fetcher pattern to
app_configmodule - [ ] Apply fetcher pattern to
artifact_registrymodule - [ ] Apply fetcher pattern to
artifact_registry_metamodule
JIRA Issue: BA-3494