Why is GraphQL not suitable for reports?

GraphQL, C#, and Data Aggregations

Disclaimer

This article describes my personal experience dealing with GraphQL usage for reports in the Asp.Net Core application. I’m not claiming that my solution is the best one. However, I was focused on achieving low maintenance costs and simple implementation.

What is GraphQL?

GraphQL is a tool that provides dynamic queries against application data.

How I tried to use GraphQL?

Imagine a read-only reporting application as an example. Read-only means that the data is already collected and validated elsewhere and then just pushed into our database.

Denormalized Structure Example
  • The metrics table contains a description of each Metric.
  • Tenants table contains information about tenants and refers to the multitenant application as a source of Metrics.
Get Metrics with Hot Chocolate

The problem of Data Aggregations

Group data on the client

The first and simplest decision would be to group data on the client and calculate all aggregated values.

Group data inside Query class

Another option would be to group data inside the query class.

GraphQL Aggregate data inside Query
GraphQL filter by Country

Group data with custom HotChocolate Extension

There is a possibility to implement a custom extension for Hot-Chocolate that will possibly allow having data aggregations. A description of this approach can be found HERE and HERE.

The solution

Analyzing all challenges GrpahQL created when used together with denormalized data, I had to switch from GraphQL to my custom package called QueryNinja.

QueryNinja and denormalized data

Conclusion

This article describes the problem that I was dealing with recently. I did my best to research all possible options and refuse the usage of my package in favor of already existing GraphQL packages. Including:

  • Schema Stitching allows joining multiple different data sources under the same GraphQL endpoint.
  • Define the Security rules to limit malicious usage of GraphQL endpoint.

References

GraphQL

QueryNinja

https://github.com/Lex45x/QueryNinja/wiki/QuickStart

Lead Software Engineer at EPAM

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store