Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction and Insights of the Hasura-based A...

KazukiHayase
September 13, 2023

Introduction and Insights of the Hasura-based Architecture

KazukiHayase

September 13, 2023
Tweet

More Decks by KazukiHayase

Other Decks in Technology

Transcript

  1. Kazuki Hayaseʢ@KazukiHayaseʣ • Frontend Engineer at BuySell Technologies • Currently

    working on the management system for listing items on e-commerce websites • GraphQL / TypeScript / Golang
  2. • OSS that automatically generates a GraphQL schema from a

    database schema • Once the tables are created, CRUD APIs get generated. So a GraphQL server can be built quickly • Authentication, authorization and federation are also available What is Hasura?
  3. • Can be authenticated and authorized by integrating with many

    popular auth services • Has a role-based authorization control at row and column level Authentication and Authorization
  4. Hasura has the ability to integrate GraphQL and REST endpoints

    • Remote Schemas • Actions Federation
  5. Federation Remote Schema is a feature that merges your remote

    GraphQL schemas and provides you with a single, unified GraphQL API
  6. • Builds a GraphQL server using Golang ◦ Merges this

    GraphQL server into Hasura as Remote Schema • Using gqlgen for schema-first development • Complex Queries and Mutations are implemented on this server Custom GraphQL Server
  7. • Adopted Elasticsearch to meet the requirements for complex searching

    • Implemented integration with Elasticsearch in Remote Schema ◦ As of today (September 13th, 2023), Hasura does not support Elasticsearch Elasticsearch
  8. • In Remote Schema, it returns only the 'id' •

    In Hasura, fetching data from the database based on the 'id' Elasticsearch
  9. Pros 01 The implementation effort has been reduced 02 Hasura

    takes on the role of the Federation Layer 03 Configurations can be managed through the GUI
  10. Pros 01 The implementation effort has been reduced 02 Hasura

    takes on the role of the Federation Layer 03 Configurations can be managed through the GUI
  11. • Simple Queries and Mutations can use auto-generated APIs •

    There is no need to implement resolvers for those parts • Overall, auto-generated APIs are used for 90% of Queries and 10% of Mutations ◦ Due to the frequent external integration, the proportion of mutations is low The implementation effort has been reduced
  12. Pros 01 The implementation effort has been reduced 02 Hasura

    takes on the role of the Federation Layer 03 Configurations can be managed through the GUI
  13. • Hasura federates the REST and GraphQL endpoints • Federation

    setting is easily managed through the GUI • Authorization for the federated target can also be managed with Hasura Hasura takes on the role of the Federation Layer
  14. Pros 01 The implementation effort has been reduced 02 Hasura

    takes on the role of the Federation Layer 03 Configurations can be managed through the GUI
  15. • Most settings can be managed through the GUI •

    The settings are exported as YAML files • Database migrations can also be managed through the GUI Configurations can be done through the GUI
  16. Cons 01 Managing configuration files can be difficult 02 Knowledge

    of the tables is required to write queries 03 Tuning the database is difficult
  17. Cons 01 Managing configuration files can be difficult 02 Knowledge

    of the tables is required to write queries 03 Tuning the database is difficult
  18. • Reviewing the YAML configuration files alone is difficult •

    In large-scale systems, managing configs through the GUI can actually be more difficult Managing configuration files can be difficult
  19. • Making rules related to configuration • Creating a custom

    YAML file validator based on the rules and running it in CI • Additionally, creating a custom tool for modifying YAML files Solutions
  20. Cons 01 Managing configuration files can be difficult 02 Knowledge

    of the tables is required to write queries 03 Tuning the database is difficult
  21. Knowledge of the tables is required to write queries With

    Hasura, the step of defining the GraphQL schema is omitted Usually Using Hasura Table definition GraphQL schema definition Implementation Table definition Implementation
  22. Knowledge of the tables is required to write queries Understanding

    both the GraphQL schema and 
 the table structure is necessary Writing Queries becomes dependent on individual skills
  23. • Participating in backend development to get the knowledge of

    the table structure ◦ The team's policy of developing in full-stack is the underlying principle • Export only the required schema ◦ Reducing the cost of schema selection Solutions
  24. Cons 01 Managing configuration files can be difficult 02 Knowledge

    of the tables is required to write queries 03 Tuning the database is difficult
  25. • Hasura builds responses using SQL queries, often resulting in

    complex SQL queries • Understanding the complex SQL queries is nearly impossible • It is not possible to modify the SQL query unless fixing the GraphQL Query Tuning the database is difficult
  26. • We can only monitor slow queries and add indexes

    • If this doesn't solve the performance issue, the only option is to implement that Query in the Remote Schema Solutions
  27. • Adopting Hasura has reduced development efforts and allowed us

    to focus on core logic implementation ◦ It's highly recommended for Proof of Concept or creating prototypes • While there are some cons, we have been able to handle them so far, so overall, we believe it was a good choice to adopt it Conclusion