Logo

dev-resources.site

for different kinds of informations.

How to Build a Supergraph using Snowflake, Neon PostgreSQL, and Hasura in Five Steps

Published at
6/20/2024
Categories
graphql
snowflake
postgres
hasura
Author
praveenweb
Categories
4 categories in total
graphql
open
snowflake
open
postgres
open
hasura
open
Author
10 person written this
praveenweb
open
How to Build a Supergraph using Snowflake, Neon PostgreSQL, and Hasura in Five Steps

By combining Hasura Cloud, Snowflake DB, and PostgreSQL on Neon, you can create a powerful supergraph backend to handle complex data tasks such as joining data across multiple data sources and filtering data on model relations. It's a supergraph framework with modular, unified layers that is continuously evolving and deployed by many companies worldwide.

Supergraph with Hasura

This tutorial will guide you through the creation of an application backend that leverages the powerful features of Snowflake and PostgreSQL databases. I will show how to integrate tables from both Snowflake and PostgreSQL into your supergraphs, allowing you to perform sophisticated, nested queries that connect models from diverse databases. This approach not only increases your backend's capabilities but also streamlines the data handling process for more complex data relationship management across different sources.

1. Setting up Hasura Cloud

Start with Hasura Cloud to quickly create GraphQL APIs.

  • Sign up for a free Hasura Cloud account.
  • Create a new project and connect it to your version control system (e.g., GitHub).
  • Define your data model using Hasura's metadata.
  • Run some exciting queries

Run GraphQL queries

2. Integrating Snowflake DB

Snowflake is a cloud-based data warehousing platform that seamlessly integrates with Hasura Cloud. To integrate Snowflake:

  • Obtain your Snowflake credentials (account, username, password).

Connect to Snowflake

  • In Hasura Cloud, navigate to the "Data" tab and add a new data source.
  • Select "Snowflake" and input your credentials.
  • “Import all tables” to add all the tables as models to the supergraph

Import snowflake tables to Hasura

3. Incorporate PostgreSQL on Neon

Neon is a managed platform for PostgreSQL databases. To incorporate PostgreSQL on Neon into your supergraph backend:

Sign up for Neon and create a new PostgreSQL database instance.

Neon PostgreSQL

  • Obtain the connection details for your Neon PostgreSQL database.
  • In Hasura Cloud, add another data source, but this time, select "Neon Database" and authorize the Neon database connection details.

Connect to Neon

  • Add the models and relationships you want to track in the data tab.

4. Executing individual queries

Now that you have Snowflake and PostgreSQL on Neon integrated into your Hasura Cloud project, you can execute queries individually.

Querying Snowflake

To query data from Snowflake, you can use Hasura's GraphQL API:

query MyQuery {
  SNOWFLAKETABLE {
    COLUMN1
    COLUMN2
  }
}
Enter fullscreen mode Exit fullscreen mode

Replace snowflakeTable, column1, and column2 with your Snowflake table and columns.

Snowflake GraphQL query

Querying PostgreSQL on Neon

Similarly, to query data from your Neon PostgreSQL database:

query MyQuery {
  neontable {
    column1
    column2
    column3
  }
}
Enter fullscreen mode Exit fullscreen mode

Replace neonTable, column1, and column2 with your Neon table and columns.

Postgres GraphQL Query

5. Nested queries for complex data retrieval

GraphQL has the ability to handle complex data retrieval through nested queries. Here’s an example:

query {
  getUser(userId: 123) {
    username
    email
    posts {
      title
      content
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

In this query:

  • We retrieve user details by their ID from either Snowflake or PostgreSQL.
  • Then, we fetch the user's posts with their titles and content.

By defining appropriate relationships and foreign keys in Hasura's metadata for both Snowflake and PostgreSQL, you can perform nested queries like the one above, aggregating data from multiple sources into a single response.

Conclusion

Continue to explore and experiment with Hasura Cloud, Snowflake DB, and PostgreSQL on Neon. Discover how to efficiently integrate multiple data sources and execute both individual and nested queries. This will increase performance and scalability across a wide range of applications.

hasura Article's
30 articles in total
Favicon
Convert insert mutation to upsert
Favicon
refinedev - hasura (nested/multiple query_root)
Favicon
From Idea to Launch: My 30-Day MVP Journey
Favicon
How to Build a GraphQL API for MongoDB Using Hasura in Six Steps
Favicon
How to Build a Supergraph using Snowflake, Neon PostgreSQL, and Hasura in Five Steps
Favicon
Streamlining CI/CD Pipelines with Hasura GraphQL Engine
Favicon
Supabase over Hasura for 2024?
Favicon
Hasura and Keycloak integration with NestJS server
Favicon
Modern API Development (Part 1)
Favicon
Build a graphQL API with Hasura low-code platform
Favicon
Startup Starter Kit
Favicon
Hasura x MEWS
Favicon
Hasura vs Apollo: Comparing GraphQL Platforms
Favicon
Hasura and Nhost vs Supabase
Favicon
How to monitor URQL performance and link with database queries ?
Favicon
Build a Powerful GraphQL API with Postgres in Under 10 Minutes
Favicon
Guide to Side effects in Hasura
Favicon
Hasura: Building Scalable and Real-Time Applications - An Extensive Guide
Favicon
Hasura Cloud: Building Scalable and Secure GraphQL APIs Made Easy
Favicon
How to avoid messing up squash migration in Hasura
Favicon
Appwrite vs. Hasura vs. Apollo
Favicon
Auth0, Hasura, Social Media Login
Favicon
Deno & Hasura for app development
Favicon
SSR: clerk with hasura
Favicon
Hasura Custom Authentication Using JWT
Favicon
Unable to HASURA_GRAPHQL_JWT_SECRET in docker-compose file
Favicon
Hasura Storage in Go: 5x performance increase and 40% less RAM
Favicon
Using Authorizer with Hasura
Favicon
Hasura + Supertokens
Favicon
Creating a todo web app in < 112 lines of code with Hasura and Python

Featured ones: