- Moved GraphQL query samples into a new `docs/queries` directory for better organization. - Added new queries and mutations, including `createHost.graphql` and `GetApiVersion.graphql`. - Introduced `mcp-config.yaml` and updated `docker-compose.yml` for MCP integration. - Updated IntelliJ `.idea/workspace.xml` settings to reflect project changes. - Added new how-to guides (`docs/howtos`) for permissions, tags, MCP integration, and schema usage. - Enhanced tests by updating file paths and improving sample data locations. - Refined permissions and host group structures in `zabbix-hostgroups.ts` and `resolvers.ts`.
1.5 KiB
🗂️ Hierarchical Data Mapping
The API automatically maps Zabbix items to nested GraphQL objects using the createHierarchicalValueFieldResolver function.
How it Works
Zabbix item keys are used to define the structure in GraphQL. A dot (.) acts as a separator to represent nested object structures.
Example:
Zabbix item key state.current.values.temperature is automatically mapped to:
{
"state": {
"current": {
"values": {
"temperature": 25.5
}
}
}
}
Type Hinting
You can guide the type conversion by prepending a type hint and an underscore to the last token of the Zabbix item key:
json_: Parses the value as a JSON object (useful for complex types).str_: Forces the value to be treated as a string.bool_: Forces the value to be treated as a boolean.float_: Forces the value to be treated as a number.
Preconditions
- Key Naming: Zabbix item keys (or tags) must match the GraphQL field names.
- Dot Separation: Use dots to represent the desired hierarchy.
The createHierarchicalValueFieldResolver function (found in ../../src/api/resolver_helpers.ts) dynamically creates these resolvers, eliminating the need for manual resolver definitions for each hierarchical field.
For more information, see the comments in ../../schema/device_value_commons.graphql and ../../src/api/resolver_helpers.ts.
See ../queries/sample_all_devices_query.graphql for examples of hierarchical data in query results.