feat(query-optimization): implement GraphQL query optimization and enhance regression suite
- **Optimization**: Implemented automatic Zabbix parameter optimization by analyzing GraphQL selection sets. - **ZabbixRequest**: Added optimizeZabbixParams with support for skippable parameters and implied field dependencies (e.g., state -> items). - **Resolvers**: Updated allHosts, allDevices, allHostGroups, and templates to pass requested fields to data sources. - **Data Sources**: Optimized ZabbixQueryHostsGenericRequest and ZabbixQueryTemplatesRequest to skip unnecessary Zabbix API calls. - **Regression Tests**: Enhanced RegressionTestExecutor with new tests for optimization (REG-OPT, REG-OPT-NEG), state retrieval (REG-STATE), dependent items (REG-DEP), and empty results (REG-EMPTY). - **Documentation**: Created query_optimization.md How-To guide and updated roadmap.md, README.md, and tests.md. - **Bug Fixes**: Fixed deviceType tag assignment during host import and corrected ZabbixCreateHostRequest to support tags.
This commit is contained in:
parent
ad104acde2
commit
97a0f70fd6
16 changed files with 835 additions and 69 deletions
26
src/datasources/graphql-params-to-zabbix-output.ts
Normal file
26
src/datasources/graphql-params-to-zabbix-output.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import {GraphQLResolveInfo} from "graphql";
|
||||
import {getRequestedFields} from "../api/graphql_utils.js";
|
||||
import {
|
||||
QueryAllDevicesArgs,
|
||||
QueryAllHostGroupsArgs,
|
||||
QueryAllHostsArgs,
|
||||
QueryTemplatesArgs
|
||||
} from "../schema/generated/graphql.js";
|
||||
|
||||
export class GraphqlParamsToNeededZabbixOutput {
|
||||
static mapAllHosts(args: QueryAllHostsArgs, info: GraphQLResolveInfo): string[] {
|
||||
return getRequestedFields(info);
|
||||
}
|
||||
|
||||
static mapAllDevices(args: QueryAllDevicesArgs, info: GraphQLResolveInfo): string[] {
|
||||
return getRequestedFields(info);
|
||||
}
|
||||
|
||||
static mapAllHostGroups(args: QueryAllHostGroupsArgs, info: GraphQLResolveInfo): string[] {
|
||||
return getRequestedFields(info);
|
||||
}
|
||||
|
||||
static mapTemplates(args: QueryTemplatesArgs, info: GraphQLResolveInfo): string[] {
|
||||
return getRequestedFields(info);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue