A GraphQL Comparison
GraphQL, a powerful and flexible query language for APIs, has changed how developers interact with data. Tools built around GraphQL offer tremendous advantages in development speed, efficiency, and overall data management. Two notable players in this space are Graphweaver and Hasura, each offering a unique approach to building GraphQL-powered applications.
This article will delve into the strengths, weaknesses, and differences between Graphweaver and Hasura. We'll explore their nuances, features, and ideal use cases, helping you choose the right tool for your next GraphQL project.
Understanding the Fundamentals
Before we dive into the feature comparison, let's understand the core concepts behind these technologies.
Graphweaver: Data Everywhere, Instant GraphQL.
Graphweaver defines itself as an instant GraphQL API over your distributed datasets. The emphasis here is on two distinct concepts:
- Data Everywhere: Graphweaver has a plugin architecture that connects to any data source. Out-of-the-box Graphweaver can connect to Postgres, MySql, SQLite, Rest and more. This approach encourages you to query it from the source instead of introducing an error-prone synchronisation worker.
- Instant GraphQL: Graphweaver is built from the ground up with GraphQL as its core interface. The entire framework revolves around creating and managing a comprehensive GraphQL API. GraphQL queries and mutations are generated automatically for you without having to write them by hand.
Hasura: The Lightning-Fast GraphQL Engine
Hasura bills itself as a super-fast GraphQL engine. Its primary focus is providing a way to expose PostgreSQL databases through a GraphQL API. Hasura does this by tracking changes to your database schema and using metadata to generate the API and queries.
Feature Highlight
Let’s take a look at the standout key feature for each platform.
Graphweaver: Cross Data Filtering
One of Graphweaver's standout features is its ability to seamlessly filter data across multiple sources. With Graphweaver, you can construct complex GraphQL queries that target data from any of your connected sources, whether databases, REST APIs, or SaaS platforms. Allowing you to refine results from different sources within a single query, streamlining your development process.
Hasura Cloud
Hasura Cloud is a fully managed cloud platform for deploying and operating Hasura GraphQL instances. It allows you to spin up Hasura without hosting a docker container. Their cloud aims to remove the operational overhead of managing Hasura yourself, allowing developers to focus on building their GraphQL applications.
Next, let’s compare the features of both options.
Key Features
Let's look at Graphweaver and Hasura's most notable features side-by-side:
Data Sources
Graphweaver: Graphweaver shines in its ability to connect to and unify multiple data sources. It natively supports:
- Databases: PostgreSQL, MySQL, SQLite
- REST APIs
- SaaS connectors for platforms like Contentful, Xero, etc.
It also is extensible, allowing developers to add more connections as needed.
Hasura: Hasura's primary strength lies in connecting to a PostgreSQL database. It does provide some support for other database systems, but PostgreSQL remains its focus and main use case. Many of the other database systems are only available via the Enterprise platform. For example, MySql is only available on the Enterprise platform.
API Generation
Graphweaver: When you connect your data sources, Graphweaver automatically generates a comprehensive GraphQL API, including CRUD operations (Create, Read, Update, Delete), filtering, sorting, and pagination.
Hasura: Hasura also automatically creates a GraphQL API. Its metadata-driven approach tracks changes in your PostgreSQL database and reflects those changes in the API in near real-time.
Customisation
Graphweaver: Graphweaver adopts a code-first approach using TypeScript, allowing you to extend the auto-generated API with your custom resolvers, custom logic, and even custom data source connections.
The code-first approach means you have control over your GraphQL API and can extend it as you please and host it in your own infrastructure.
Hasura: Hasura favours a configuration-driven model. Customisation is through Actions (webhooks for custom logic), events/triggers, and the ability to write custom SQL functions. Instead of adding code to Hasura, you use Hasura as the hub and build up your system around it, receiving event triggers when something in Hasura changes.
Performance
Graphweaver: Graphweaver delivers fast performance for locally connected databases, but fetching data from multiple sources might introduce some overhead. One way to combat this is using a caching layer for reads and writes.
Hasura: Hasura is known for its fast performance, especially when connected directly to a PostgreSQL database.
Real-time Updates
Graphweaver: Graphweaver allows real-time functionality via integrations and GraphQL polling. Subscriptions are also on the roadmap and coming soon.
Hasura: Hasura has Real-time subscriptions for data changes in PostgreSQL, but changes in data sources outside of PostgreSQL are not able to be subscribed to.
Admin Interface
Graphweaver: Graphweaver provides a customisable, React-based admin panel for managing content from all your connected data sources. As a developer you can override individual fields or inject custom pages, giving you the ability to add complex UI for editing a field, custom dashboards and wizards.
Hasura: Hasura includes a powerful built-in admin interface for managing PostgreSQL data, permissions, and other API-related settings. Customisation is more limited.
Open Source
Graphweaver: Fully open-source.
Hasura: Hasura has an open-source core, but some advanced enterprise features are closed-source and require a paid plan.
When to Choose Graphweaver
Graphweaver could be your ideal choice in these scenarios:
- Diverse Data Needs: You have a project that pulls data from many sources – databases of different types, REST APIs, and potentially external SaaS platforms. Graphweaver's flexibility in connecting these disparate sources is its strength.
- Developer Comfort: You or your team are comfortable with TypeScript and prefer a code-first approach to customise and control the GraphQL API. The open-source nature of Graphweaver ensures no limits and no vendor lock-in.
- AdminUI: While not a full-fledged CMS in the traditional sense, Graphweaver provides the admin front-end to manage structured data from all your sources.
When to Choose Hasura
Consider Hasura if the following factors are essential to your project:
- PostgreSQL: Your application uses only a PostgreSQL database, and your primary focus is exposing that data with GraphQL access.
- Ease of Setup: You prefer a more configuration-driven approach, valuing the rapid setup that Hasura's metadata system provides.
- Real-time a Must: If built-in real-time subscriptions for your PostgreSQL data are non-negotiable.
Other Reasons to Consider
Let's consider a few more factors that might influence your decision:
- Front-end Frameworks: Graphweaver, due to its GraphQL-only focus, plays nicely with any JavaScript front-end framework like React, Angular, Vue.js, or Svelte. Hasura works seamlessly, but its tight coupling with PostgreSQL might subtly guide front-end choices.
- Scaling and Complexity: For highly complex projects with many data sources or custom logic, Graphweaver's code-first approach might give you the necessary control over scaling. On the other hand, Hasura's configuration-driven approach might excel in more straightforward setups.
- Community and Support: Both Graphweaver and Hasura have active communities. However, Hasura enjoys a large user base due to its longer presence in the GraphQL ecosystem. Making it easier to discover resources and help when needed.
Example Use Cases
Let's look at some use-case examples:
Ideal for Graphweaver
Unified E-commerce Dashboard: Build a back-office dashboard that pulls product data from a MySQL database, order and shipment information from a REST API, and customer data from a SaaS CRM like Salesforce – all unified under a single GraphQL API.
Custom Content Platform: Create a platform where content is enriched with data from various sources. For example, a recipe platform might connect nutritional data from an external API while managing blog content within Contentful all via the Graphweaver AdminUI.
Ideal for Hasura
High-Traffic Real-time Application: Build a real-time social media or live sports score application where PostgreSQL stores the constantly updated data, and Hasura delivers it to the front end with minimal latency.
Rapidly Prototyping a PostgreSQL-backed App: If you have an existing PostgreSQL database and need a GraphQL API, Hasura's metadata-driven setup will get you up and running the fastest.
No One-Size-Fits-All Winner
Remember, there's no single "best" GraphQL engine. Graphweaver and Hasura both bring valuable capabilities to the table. Analysing your project's specific requirements, priorities, and team preferences is crucial for making the most informed choice.
Useful Links to Get Started
Graphweaver Links
Quick Start Guide: https://graphweaver.com/docs/quick-start
Examples:
- Postgres and Mysql: https://github.com/exogee-technology/graphweaver/tree/main/src/examples/databases
- REST and Mysql: https://github.com/exogee-technology/graphweaver/tree/main/src/examples/rest
- Xero: https://github.com/exogee-technology/graphweaver/tree/main/src/examples/xero
Hasura Links
Hasura Quickstart guide: https://hasura.io/docs/latest/getting-started/overview/