chore: add MCP integration and refactor documentation into modular how-to guides
- 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`.
This commit is contained in:
parent
2a82fe6cf2
commit
4ec61ffba1
33 changed files with 439 additions and 165 deletions
41
docs/howtos/hierarchical_data_mapping.md
Normal file
41
docs/howtos/hierarchical_data_mapping.md
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
## 🗂️ 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:
|
||||
```json
|
||||
{
|
||||
"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
|
||||
|
||||
1. **Key Naming**: Zabbix item keys (or tags) must match the GraphQL field names.
|
||||
2. **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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue