graphql-engine/v3/crates/query-usage-analytics
Rakesh Emmadi d5909e8c48 Fix permission filter usage reporting in query analytics (#933)
<!-- The PR description should answer 2 important questions: -->

### What

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

<!-- Does this PR introduce new validation that might break old builds?
-->

<!-- Consider: do we need to put new checks behind a flag? -->
Fields involved in the relationship's inner predicates were incorrectly
reported as fields of the root model. This PR resolves the issue. Also,
fixes the predicates inside `And` or `Or` are not reported.

Note: Changelog not required, as query usage analytics are Hasura
internal and hidden from users.
### How

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->
- Use `for` loop instead of `Iterator map` to avoid confusion around the
execution of lambda passed to the `map` function (more context in this
[slack](https://hasurahq.slack.com/archives/C04PUMV4X16/p1722871834852519)
thread)
- Introduce a new struct, to report predicate relationship fields, that
has a field to report its inner filter predicate usage.

V3_GIT_ORIGIN_REV_ID: 9ca23e6005ccb09f2321a2ae30ef575f99e84e06
2024-08-06 05:57:25 +00:00
..
src Fix permission filter usage reporting in query analytics (#933) 2024-08-06 05:57:25 +00:00
Cargo.toml Improvements to query usage analytics data shape (#715) 2024-06-25 07:57:15 +00:00
query_usage_analytics.jsonschema Fix permission filter usage reporting in query analytics (#933) 2024-08-06 05:57:25 +00:00
README.md data shape for query usage analytics (#606) 2024-05-28 09:51:09 +00:00

Query Usage Analytics

We want to gather usage analytics from a GraphQL query. Usage analytics of models, commands, fields, permissions, relationships etc. being used in the query.

For now, this crate defines the types we would construct for gathering usage analytics. Later, this can also include functions required to build up these types. Ideally, this crate should expose an API which the engine IR generation or query plan generation can use to create a usage analytics type and serialize and emit it.

The types here are a simplified version of the GraphQL query AST, OpenDD and metadata-resolve types.