bug: GraphQLQueryAnalyzer complexity for depth and height doesn't consider fragments #5562
Labels
group/backend
Issue related to the backend (API Server, Git Agent)
state/backlog
This issue is part of the backlog
type/bug
Something isn't working as expected
Component
API Server / GraphQL, Python SDK
Infrahub version
v1.2.0a0
Current Behavior
When adding a GraphQL Query to Infrahub we currently calculate the complexity and indicate the queries height and depth. As an example the following query will have depth: 8 and height: 11 where height indicates the number of returned elements and depth indicates how deeply the query is nested (often indicating relationship lookups)
If you instead use fragments this calculation doesn't work, for instance:
This query gets reported as having depth: 7 and height: 7 indicating that we only consider the graphql query itself (MyQuery), where we should in fact also include the fragment within this evaluation.
Expected Behavior
The entire query should be included in the evaluation.
Steps to Reproduce
Additional Information
Something to consider is that the methods for evaluating height and depth comes from the SDK today, where we could consider moving this logic to Infrahub server to use the information already processed by the improved InfrahubGraphQLQueryAnalyzer.
Also note, currently we don't use these values for anything so it might not be something that's urgent for the moment but it's something to consider. Another aspect is that all of this would currently be queried without considering the
@expand
directive we added. If we keep that directive we should probably rewrite it and include it as part of the Query Analyzer and manage the update of the GraphQL Query document inline instead of doing it later where we aren't able include the added fields within the complexity calculation.Finally the above query is also problematic today due to #5322, probably for the same reason (we extract the fields of the base query and don't include the names fragment when processing the query)
The text was updated successfully, but these errors were encountered: