<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Praveen Durairaju</title>
    <description>The latest articles on Forem by Praveen Durairaju (@praveenweb).</description>
    <link>https://forem.com/praveenweb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F56872%2F7dbc7a2c-8183-485e-9804-7371f2fd97e5.jpg</url>
      <title>Forem: Praveen Durairaju</title>
      <link>https://forem.com/praveenweb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/praveenweb"/>
    <language>en</language>
    <item>
      <title>How to Build a GraphQL API for MongoDB Using Hasura in Six Steps</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Tue, 25 Jun 2024 19:41:00 +0000</pubDate>
      <link>https://forem.com/praveenweb/how-to-build-a-graphql-api-for-mongodb-using-hasura-in-six-steps-5bhh</link>
      <guid>https://forem.com/praveenweb/how-to-build-a-graphql-api-for-mongodb-using-hasura-in-six-steps-5bhh</guid>
      <description>&lt;p&gt;In 2012, GraphQL was introduced as a developer-friendly API spec that allows clients to request exactly the data they need, making it efficient and fast. By reducing the need for multiple requests and limiting the over-fetching of data, GraphQL simplifies data retrieval, improving the developer experience. This leads to better applications by ensuring more efficient data loading and less bandwidth usage, particularly important for mobile or low-bandwidth environments.&lt;/p&gt;

&lt;p&gt;Using GraphQL instead of REST on MongoDB is desirable for many use cases, especially when data from multiple MongoDB instances needs to be accessed simultaneously or when engineers need to join NoSQL data from MongoDB with data from another source.&lt;/p&gt;

&lt;p&gt;However, engineers often encounter difficulties implementing GraphQL APIs and layering them onto their MongoDB data sources. This learning curve and the maintenance overhead often inhibit adoption. Hasura was designed to address this common challenge with adopting GraphQL.&lt;/p&gt;

&lt;p&gt;Hasura is a low-code GraphQL API solution. With Hasura, even engineers unfamiliar with GraphQL can build feature-rich GraphQL APIs — complete with pagination, filtering, sorting, etc. — on MongoDB and dozens of other data sources in minutes. &lt;/p&gt;

&lt;p&gt;Hasura also supports data federation, enabling developers to create a unified GraphQL API across different databases and services. In this guide, I’ll show you how to quickly connect Hasura to MongoDB and generate a secure, high-performance GraphQL API.&lt;/p&gt;

&lt;p&gt;I will take you through the following steps to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a project on Hasura Cloud&lt;/li&gt;
&lt;li&gt;Create a database on MongoDB Atlas&lt;/li&gt;
&lt;li&gt;Connect Hasura to MongoDB&lt;/li&gt;
&lt;li&gt;Generate a high-performance GraphQL API instantly&lt;/li&gt;
&lt;li&gt;Try out GraphQL queries with relationships&lt;/li&gt;
&lt;li&gt;Analyze query execution&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition, I will delve into the mechanics behind the generated API's exceptional performance, detailing the techniques and optimizations that contribute to its efficiency.&lt;/p&gt;

&lt;p&gt;By the conclusion of this guide, you will possess the skills necessary to build your own high-performance, production-ready GraphQL API using Hasura, tailored for your existing or new MongoDB Atlas instance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Create a project on Hasura Cloud
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa4y7wr3lco5qd6snwbpw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa4y7wr3lco5qd6snwbpw.png" alt="Hasura Cloud Console" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To begin, you will need a project on Hasura Cloud and a MongoDB database on Atlas. Head over to &lt;a href="https://cloud.hasura.io/signup?utm_source=mongodb&amp;amp;utm_medium=blog&amp;amp;utm_campaign=mongodb_developer_portal"&gt;cloud.hasura.io&lt;/a&gt; to create an account or log in. Once you are on the Cloud Dashboard, navigate to &lt;a href="https://cloud.hasura.io/projects"&gt;Projects&lt;/a&gt; and click on &lt;code&gt;New Project&lt;/code&gt; to create a new project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxpbpo5e6g9ycz035lwd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxpbpo5e6g9ycz035lwd.png" alt="Create a new project on Hasura Cloud" width="800" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can create a free project by selecting the region of your choice. In this example, we are using AWS infrastructure, US West region.&lt;/p&gt;

&lt;p&gt;Remember the region selected. We want to co-locate the GraphQL API deployed using Hasura Cloud in the same region as the database on MongoDB Atlas. This will be done in one of the subsequent steps. Click on the &lt;code&gt;Create Free Project&lt;/code&gt; button, as highlighted. As always, you can upgrade the project later as required.&lt;/p&gt;

&lt;p&gt;Once the project is created, you’ll be taken to the project details page, which displays the GraphQL endpoint among other details. Take note of the &lt;code&gt;Hasura Cloud IP&lt;/code&gt; on this page, as it’s required during the MongoDB Atlas setup to allow the connection from Hasura to MongoDB.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fetlnscanhe6epfjk08ks.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fetlnscanhe6epfjk08ks.png" alt="Launch Hasura Console" width="800" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;code&gt;Launch Console&lt;/code&gt; to open the project's Hasura Console. You will land on the API Explorer page to try out the GraphQL APIs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4dgm0jgnj32be7azn6t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4dgm0jgnj32be7azn6t.png" alt="Create free project" width="800" height="1158"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the &lt;code&gt;DATA&lt;/code&gt; tab at the top to navigate to the Data Management section of the console. Here you can connect to the various databases that Hasura supports. Choose MongoDB from the list and click on &lt;code&gt;Connect Existing Database&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjeqaus1qsh0l7xpmhgsg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjeqaus1qsh0l7xpmhgsg.png" alt="Connect Existing Database" width="800" height="820"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, Hasura requires the connection details of MongoDB. &lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create a database on MongoDB Atlas
&lt;/h2&gt;

&lt;p&gt;Hasura can connect to a new or an existing MongoDB Atlas database and generate the GraphQL API for you. Now, go ahead and create a new database and use some autogenerated sample data.&lt;/p&gt;

&lt;p&gt;Go to &lt;a href="https://cloud.mongodb.com/"&gt;MongoDB Atlas&lt;/a&gt;, create a project if you don’t already have one, and navigate to the Database page under the Deployments section. You should see a page like the one below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fggbbawzuby4gbr5ab4bn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fggbbawzuby4gbr5ab4bn.png" alt="MongoDB deployment page" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the &lt;code&gt;Build a Database&lt;/code&gt; button. On the next page, select the deployment specifics. Start with the Free M0 cluster, free forever and ideal for getting started. You can always upgrade later when required.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxayynozxasvcr1g0u6i3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxayynozxasvcr1g0u6i3.png" alt="Deploy Mongo database" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give the cluster a name; for this example, use &lt;code&gt;Hasura&lt;/code&gt;. You will need to select the region. For this tutorial, pick AWS as the provider and choose the &lt;code&gt;us-west-2&lt;/code&gt;  region to keep the data close to the Hasura instance (recall that our Hasura cluster was deployed on US West, as well).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwe3act4qbgftjg9wjazw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwe3act4qbgftjg9wjazw.png" alt="Provider AWS" width="790" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember to choose the region closest to your users. Keeping your database and API region the same is recommended to avoid performance and latency issues.&lt;/p&gt;

&lt;p&gt;Next, add your IP address for local connectivity and create a new database user with &lt;code&gt;atlasAdmin&lt;/code&gt; permission that you’ll need to access the MongoDB cluster from Hasura Cloud.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frdik4c10oa81nvj6515u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frdik4c10oa81nvj6515u.png" alt="Add IP Address" width="800" height="638"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note the password, as we will need it later. Now, click on &lt;code&gt;Create Database User&lt;/code&gt;. &lt;code&gt;Choose a connection method&lt;/code&gt; and skip the next steps. Optionally, in case you are stuck in any of the steps above, you can refer to the instructions for &lt;a href="https://www.mongodb.com/docs/atlas/getting-started/#create-a-database-user-for-your-cluster"&gt;creating a new MongoDB database deployment&lt;/a&gt; in the docs, particularly until Step 4.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Load sample dataset
&lt;/h2&gt;

&lt;p&gt;Once the database deployment is complete, you might want to load some sample data for the cluster. You can do this by heading to the &lt;code&gt;Database&lt;/code&gt; tab and under the newly created Cluster, click on the &lt;code&gt;...&lt;/code&gt; that opens an option to &lt;code&gt;Load Sample Dataset&lt;/code&gt;. This may take a few seconds.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fio5dxs9z6oqotr17ahfa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fio5dxs9z6oqotr17ahfa.png" alt="Load sample dataset" width="800" height="526"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this stage, we have created a Hasura Cloud project and a MongoDB Atlas database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Connect Hasura to MongoDB
&lt;/h2&gt;

&lt;p&gt;To connect Hasura to MongoDB, first add the Hasura Cloud IP address to your MongoDB cluster. To do that, navigate to the Network Access page (under Security) from the Atlas dashboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmd92lfnwqhw2vogi8x3z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmd92lfnwqhw2vogi8x3z.png" alt="Network Access MongoDB" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;code&gt;ADD IP ADDRESS&lt;/code&gt; and enter the &lt;code&gt;Hasura Cloud IP&lt;/code&gt; that you obtained from the Hasura Cloud dashboard in the first step.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqdrcbhvkhtzcjl4d2mch.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqdrcbhvkhtzcjl4d2mch.png" alt="Add IP Address" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once completed, Hasura Cloud should be able to communicate with the MongoDB Atlas instance. The next step is to get the database connection string.&lt;/p&gt;

&lt;p&gt;On the Atlas dashboard, head to the &lt;code&gt;Database page&lt;/code&gt; and click on &lt;code&gt;Connect&lt;/code&gt; next to the Hasura cluster created some steps back. Choose the &lt;code&gt;Drivers&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq92c0ud53jzzbvdm661f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq92c0ud53jzzbvdm661f.png" alt="Connect to your Application MongoDB" width="800" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will get a popup with the connection string details. Copy the connection string for the database, which will be similar to this format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mongodb+srv://praveen:&amp;lt;password&amp;gt;@hasura.1oyflxi.mongodb.net/?retryWrites&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;&amp;amp;w&lt;span class="o"&gt;=&lt;/span&gt;majority
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that you need to replace &lt;code&gt;&amp;lt;password&amp;gt;&lt;/code&gt; with the actual password of the database user that you created earlier.&lt;/p&gt;

&lt;p&gt;You can access the Database Users from the Database Access tab under the Security section of the left navigation menu. Remember that the database user needs to have &lt;code&gt;atlasAdmin&lt;/code&gt; permission for the connection to work.&lt;/p&gt;

&lt;p&gt;Now, move back to the Hasura Cloud dashboard for the next step.&lt;/p&gt;

&lt;p&gt;As you are on the Connect Existing Database for MongoDB page, enter the values for the name of the database as &lt;code&gt;mongodb&lt;/code&gt;, the connection string copied from the previous step. This instance comes with a sample database called &lt;code&gt;sample_mflix&lt;/code&gt;. Enter that under the &lt;code&gt;db&lt;/code&gt; config.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmedaclccy38ag7y1f4t0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmedaclccy38ag7y1f4t0.jpg" alt="Connect MongoDB in Hasura" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, click on &lt;code&gt;Connect Database&lt;/code&gt; and you are all set with the connection of Hasura and MongoDB, all hosted on their respective Cloud instances.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Generate a high-performance GraphQL API
&lt;/h2&gt;

&lt;p&gt;You can generate an API instantly for the sample database that was loaded to MongoDB by going to the mongodb -&amp;gt; Manage page on Hasura Console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqdwfx4dkb8fcnhnewd2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqdwfx4dkb8fcnhnewd2.png" alt="Track collections MongoDB" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Review the collections from the sample database shown on this page. For example, you can see collections such as users, theaters, movies, comments, sessions, and embedded_movies. Now you can Track them to make sure Hasura generates the GraphQL (and REST) API for the collections.&lt;/p&gt;

&lt;p&gt;Start by tracking the movies collection. Click on the Track button next to the movies collection.&lt;/p&gt;

&lt;p&gt;In this step, you’ll need to indicate to Hasura the structure of the JSON object so that Hasura can inspect it and generate a GraphQL schema for it.&lt;/p&gt;

&lt;p&gt;Insert the following JSON as input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"$oid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"573a1390f29313caabcd42e8"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"plot"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"A group of bandits stage a brazen train hold-up, only to find a determined posse hot on their heels."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"genres"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Short"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Western"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"runtime"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"11"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"cast"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"A.C. Abadie"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Gilbert M. 'Broncho Billy' Anderson"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"George Barnes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Justus D. Barnes"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"poster"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://m.media-amazon.com/images/M/MV5BMTU3NjE5NzYtYTYyNS00MDVmLWIwYjgtMmYwYWIxZDYyNzU2XkEyXkFqcGdeQXVyNzQzNzQxNzI@._V1_SY1000_SX677_AL_.jpg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The Great Train Robbery"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"fullplot"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Among the earliest existing films in American cinema - notable as the first film that presented a narrative story to tell - it depicts a group of cowboy outlaws who hold up a train and rob the passengers. They are then pursued by a Sheriff's posse. Several scenes have color included - all hand tinted."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"languages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"English"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"released"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"$date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$numberLong"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"-2085523200000"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"directors"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Edwin S. Porter"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"rated"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"TV-G"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"awards"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"wins"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"nominations"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1 win."&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"lastupdated"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2015-08-13 00:27:59.177000000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"year"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1903"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"imdb"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"rating"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$numberDouble"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"7.4"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"votes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"9847"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"439"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"countries"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"USA"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"movie"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"tomatoes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"viewer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"rating"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"$numberDouble"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"3.7"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"numReviews"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2559"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"meter"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"75"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"fresh"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"6"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"critic"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"rating"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"$numberDouble"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"7.6"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"numReviews"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"6"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"meter"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"100"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"rotten"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lastUpdated"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"$numberLong"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1439061370000"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"num_mflix_comments"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"$numberInt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, if you want to copy these objects from your Mongo collections directly, head to the Collections tab under the Database section.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3a7er483niikzhryl4rl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3a7er483niikzhryl4rl.png" alt="Sample mflix database mongo" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the &lt;code&gt;Validate&lt;/code&gt; button to validate the JSON document. In the next step, you will see the models derived from this document. Finally, click on the &lt;code&gt;Track Collection&lt;/code&gt; button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkigacpcn6mbajm0gt6y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkigacpcn6mbajm0gt6y.png" alt="Track Collection" width="800" height="860"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Try out GraphQL queries
&lt;/h2&gt;

&lt;p&gt;Once you track the collection, you should navigate to the API Explorer page on the Hasura Console to start trying out some GraphQL queries. Execute the following GraphQL query inside the GraphQL interface.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="k"&gt;query&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;movies&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;order_by&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;released&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;desc&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;_id&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;released&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;imdb&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="n"&gt;numberDouble&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are trying to fetch 10 movies, sorted by released, descending. You will get a JSON response on the right as you execute the query by clicking the &lt;code&gt;play&lt;/code&gt; button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwv2h7x8ybv988np492e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwv2h7x8ybv988np492e.png" alt="GraphiQL query" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And voilà! A GraphQL API for the movies collection is now tested and ready for consumption. Play around with different queries as you see them on the Explorer tab on the left sidebar. You can repeat this for tracking more collections like comments, users, theaters, etc., and get APIs generated for all of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  How is the GraphQL API highly performant?
&lt;/h2&gt;

&lt;p&gt;Hasura's instant generation of the GraphQL API for collections significantly minimizes the need for boilerplate code, which would otherwise be required in the form of GraphQL resolvers on any server.&lt;/p&gt;

&lt;p&gt;Ensuring that both the database and the API reside in the same region mitigates latency concerns. However, let's delve deeper into the mechanics of query execution behind the scenes. It essentially revolves around these key factors:&lt;/p&gt;

&lt;h3&gt;
  
  
  1: Database pushdown with query optimization
&lt;/h3&gt;

&lt;p&gt;Hasura operates as a compiler that receives a GraphQL query, enriches it with predicates as part of the query, and then delegates the query with projection, relationships, and authorization rules to the database to handle the workload. This approach circumvents server-side data processing and capitalizes on the database's capabilities to achieve high efficiency and performance.&lt;/p&gt;

&lt;p&gt;Given GraphQL's inherent capability for clients to specify their desired data, it becomes imperative to retrieve only the exact fields requested by the client. Hasura achieves this by compiling the query with projection. In the absence of Hasura, a typical query might be suboptimal, resulting in fetching unnecessary data (more data than required).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhdgoep2vjnlpdmuer9qc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhdgoep2vjnlpdmuer9qc.png" alt="Database pushdown with query optimization" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2: Usage of aggregation pipelines
&lt;/h3&gt;

&lt;p&gt;Let’s analyze the query that is generated by Hasura. For the example, GraphQL query that we used above, click on the Analyze button on the GraphiQL section of the API Explorer page.&lt;/p&gt;

&lt;p&gt;You’ll see that the query execution plan looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"aggregate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"movies"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"pipeline"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$sort"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"released"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-1&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$limit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"$replaceWith"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"released"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"$dateToString"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"$released"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"$_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"imdb"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"$cond"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"if"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"$imdb"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"then"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="nl"&gt;"rating"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"$cond"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                  &lt;/span&gt;&lt;span class="nl"&gt;"if"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"$imdb.rating"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                  &lt;/span&gt;&lt;span class="nl"&gt;"then"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                    &lt;/span&gt;&lt;span class="nl"&gt;"numberDouble"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"$imdb.rating.numberDouble"&lt;/span&gt;&lt;span class="w"&gt;
                  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
                  &lt;/span&gt;&lt;span class="nl"&gt;"else"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"else"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"$title"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"cursor"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see the usage of aggregation pipelines for high performance.&lt;br&gt;
Iterating on the API with updates to collections&lt;br&gt;
Updating the structure of a document in a collection is a straightforward process with Hasura. Simply adjust the Hasura metadata to include or exclude the modified fields. The schema's flexibility allows you to update the logical model to incorporate API changes seamlessly. No database migrations are necessary; — just add or remove fields from the metadata to reflect in the API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The integration of MongoDB with Hasura's GraphQL Engine introduces a heightened level of efficiency and scalability for developers. Harnessing Hasura's ability to create a unified GraphQL API from varied data sources, developers can swiftly expose MongoDB data through a secure, high-performance, and extensively customizable GraphQL API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources to learn more about the integration.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://hasura.io/docs/latest/databases/mongodb/mongodb-atlas/"&gt;Hasura docs for MongoDB Atlas integration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hasura.io/docs/latest/databases/mongodb/docker/"&gt;Running Hasura and MongoDB locally&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=to9_hFLcw8Y"&gt;It should’ve been MongoDB all along!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hasura.io/discord"&gt;Hasura Discord server&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>graphql</category>
      <category>mongodb</category>
      <category>hasura</category>
    </item>
    <item>
      <title>How to Build a Supergraph using Snowflake, Neon PostgreSQL, and Hasura in Five Steps</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Thu, 20 Jun 2024 20:17:00 +0000</pubDate>
      <link>https://forem.com/praveenweb/how-to-build-a-supergraph-using-snowflake-neon-postgresql-and-hasura-in-five-steps-2h02</link>
      <guid>https://forem.com/praveenweb/how-to-build-a-supergraph-using-snowflake-neon-postgresql-and-hasura-in-five-steps-2h02</guid>
      <description>&lt;p&gt;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. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkv89aae6oemdh5oquz2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkv89aae6oemdh5oquz2.png" alt="Supergraph with Hasura" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Setting up Hasura Cloud
&lt;/h2&gt;

&lt;p&gt;Start with Hasura Cloud to quickly create GraphQL APIs. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sign up for a free &lt;a href="https://cloud.hasura.io/signup?pg=product&amp;amp;plcmt=body&amp;amp;cta=get-started-for-free&amp;amp;tech=default"&gt;Hasura Cloud account&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Create a new project and connect it to your version control system (e.g., GitHub).&lt;/li&gt;
&lt;li&gt;Define your data model using Hasura's metadata.&lt;/li&gt;
&lt;li&gt;Run some exciting queries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flw5azl6yk0fpgmfy7bjn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flw5azl6yk0fpgmfy7bjn.png" alt="Run GraphQL queries" width="800" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Integrating Snowflake DB
&lt;/h2&gt;

&lt;p&gt;Snowflake is a cloud-based data warehousing platform that &lt;a href="https://hasura.io/graphql/database/snowflake"&gt;seamlessly integrates with Hasura Cloud&lt;/a&gt;. To integrate Snowflake:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Obtain your Snowflake credentials (account, username, password).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flsyz0pashcv7pi26u1rw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flsyz0pashcv7pi26u1rw.png" alt="Connect to Snowflake" width="800" height="855"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In Hasura Cloud, navigate to the "Data" tab and add a new data source.&lt;/li&gt;
&lt;li&gt;Select "Snowflake" and input your credentials.&lt;/li&gt;
&lt;li&gt;“Import all tables” to add all the tables as models to the supergraph&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk07j450t945qzpdcepys.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk07j450t945qzpdcepys.png" alt="Import snowflake tables to Hasura" width="800" height="856"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Incorporate PostgreSQL on Neon
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://hasura.io/docs/latest/databases/postgres/neon/"&gt;Neon&lt;/a&gt; is a managed platform for PostgreSQL databases. To incorporate PostgreSQL on Neon into your supergraph backend:&lt;/p&gt;

&lt;p&gt;Sign up for Neon and create a new PostgreSQL database instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpveb53fkcoibiq6dp2aj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpveb53fkcoibiq6dp2aj.png" alt="Neon PostgreSQL" width="800" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Obtain the connection details for your Neon PostgreSQL database.&lt;/li&gt;
&lt;li&gt;In Hasura Cloud, add another data source, but this time, select "Neon Database" and authorize the Neon database connection details.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr1pqr2tg7xremwnvav0f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr1pqr2tg7xremwnvav0f.png" alt="Connect to Neon" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add the models and relationships you want to track in the data tab.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Executing individual queries
&lt;/h2&gt;

&lt;p&gt;Now that you have Snowflake and PostgreSQL on Neon integrated into your Hasura Cloud project, you can execute queries individually.&lt;/p&gt;

&lt;h3&gt;
  
  
  Querying Snowflake
&lt;/h3&gt;

&lt;p&gt;To query data from Snowflake, you can use Hasura's GraphQL API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="k"&gt;query&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MyQuery&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;SNOWFLAKETABLE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;COLUMN1&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;COLUMN2&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace snowflakeTable, column1, and column2 with your Snowflake table and columns.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvj7cz2nwz7mqmx6aqr3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvj7cz2nwz7mqmx6aqr3.png" alt="Snowflake GraphQL query" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Querying PostgreSQL on Neon
&lt;/h3&gt;

&lt;p&gt;Similarly, to query data from your Neon PostgreSQL database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="k"&gt;query&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MyQuery&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;neontable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;column1&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;column2&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;column3&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace neonTable, column1, and column2 with your Neon table and columns.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8e6mcd50z96hlmz15q7i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8e6mcd50z96hlmz15q7i.png" alt="Postgres GraphQL Query" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Nested queries for complex data retrieval
&lt;/h2&gt;

&lt;p&gt;GraphQL has the ability to handle complex data retrieval through nested queries. Here’s an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="k"&gt;query&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;posts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this query:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We retrieve user details by their ID from either Snowflake or PostgreSQL.&lt;/li&gt;
&lt;li&gt;Then, we fetch the user's posts with their titles and content.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>snowflake</category>
      <category>postgres</category>
      <category>hasura</category>
    </item>
    <item>
      <title>The Learning Path to GraphQL for Fullstack Developers</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Thu, 28 Oct 2021 15:25:24 +0000</pubDate>
      <link>https://forem.com/praveenweb/the-learning-path-to-graphql-for-fullstack-developers-10bp</link>
      <guid>https://forem.com/praveenweb/the-learning-path-to-graphql-for-fullstack-developers-10bp</guid>
      <description>&lt;p&gt;&lt;a href="https://hasura.io/graphql/"&gt;GraphQL&lt;/a&gt; has been around for 6 years now and has really empowered frontend and fullstack developers with the ability to build backends easily. With tools like Hasura, developers focus only on writing custom logic code specific to the app, taking away the repetitive CRUD APIs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hasura.io"&gt;Hasura&lt;/a&gt; gives you instant GraphQL and REST APIs on all your data. It sits in between your application and the data sources to give you the goodness of GraphQL, Authorization and a slew of security and monitoring features. The core Hasura GraphQL Engine is &lt;a href="https://github.com/hasura/graphql-engine"&gt;open source&lt;/a&gt; and we have a &lt;a href="https://cloud.hasura.io/signup"&gt;Cloud&lt;/a&gt; offering for managing infra and advanced production ready features.&lt;/p&gt;

&lt;p&gt;We at Hasura, along with the community have created a series of &lt;a href="https://github.com/hasura/learn-graphql"&gt;open source tutorials&lt;/a&gt; starting from GraphQL Basics, Hasura Basics to full fledged frontend tutorials in various frameworks. You name it, we have it :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkt06ianpblcgyqa62yz5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkt06ianpblcgyqa62yz5.png" alt="Image description" width="800" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Begin your journey with GraphQL Basics
&lt;/h2&gt;

&lt;p&gt;If you are completely new to GraphQL, we recommend taking our &lt;a href="https://hasura.io/learn/graphql/intro-graphql/introduction/"&gt;Introduction to GraphQL&lt;/a&gt; course. This will get you from Zero to GraphQL in less than an hour.&lt;/p&gt;

&lt;p&gt;The key to learning GraphQL is to understand that it is just a query language and popular implementations on the client and server leverage existing JSON standards for requests and responses over HTTP.&lt;/p&gt;

&lt;p&gt;Once you are familiar with this concept, it will become easier to grok the benefits of GraphQL. The Intro to GraphQL tutorial covers some fundamental concepts like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://hasura.io/learn/graphql/intro-graphql/what-is-graphql/"&gt;What is GraphQL?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hasura.io/learn/graphql/intro-graphql/graphql-vs-rest/"&gt;GraphQL vs REST&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hasura.io/learn/graphql/intro-graphql/core-concepts/"&gt;Core Concepts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hasura.io/learn/graphql/intro-graphql/introspection/"&gt;Introspection&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The three most common things you will encounter with GraphQL are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Queries&lt;/li&gt;
&lt;li&gt;Mutations&lt;/li&gt;
&lt;li&gt;Subscriptions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This along with the type system makes GraphQL the powerful self-serve API that everyone can use intuitively.&lt;/p&gt;

&lt;p&gt;You will also understand the different approaches one can take while writing a &lt;a href="https://hasura.io/learn/graphql/intro-graphql/graphql-server/"&gt;GraphQL Server&lt;/a&gt;. Finally you will learn how &lt;a href="https://hasura.io/learn/graphql/intro-graphql/graphql-client/"&gt;GraphQL Clients&lt;/a&gt; make data fetching, consuming realtime subscriptions really easy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup the backend with Hasura
&lt;/h2&gt;

&lt;p&gt;Once you have understood what GraphQL is and the core concepts around it, you can progress to the easiest step in the journey. i.e Setting up a GraphQL API with Hasura.&lt;/p&gt;

&lt;p&gt;We have put together a concise tutorial for &lt;a href="https://hasura.io/learn/graphql/hasura/introduction/"&gt;Hasura Basics&lt;/a&gt; to create a production ready GraphQL API from scratch without writing much code. You will be able to use the power of database, set up Authorization rules for security and write custom business logic code specific to a realtime use case.&lt;/p&gt;

&lt;p&gt;Once you go over this Hands-on tutorial, which should take about ~30 mins to an hour, you will be able to start integrating the GraphQL API with any frontend app.&lt;/p&gt;

&lt;h3&gt;
  
  
  Optional: Database Ninja
&lt;/h3&gt;

&lt;p&gt;Hasura connects to a database (either PostgreSQL, MySQL or MS SQL etc) to give you a GraphQL API. Now if you are a frontend developer who is new to the database ecosystem, then you are covered with our &lt;a href="https://hasura.io/learn/#database-tutorials"&gt;database series&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The database tutorials will teach you core concepts around data modeling with examples of SQL statements and key fundamentals to know just enough to deploy an app in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrate GraphQL backend with frontend
&lt;/h2&gt;

&lt;p&gt;Once you are familiar with GraphQL and setting up a backend with Hasura, you can start trying out the real power of GraphQL in the frontend app. In this frontend series, you will learn how modern GraphQL client side tooling can be integrated with a GraphQL backend like Hasura.&lt;/p&gt;

&lt;p&gt;There are tutorials available in &lt;a href="https://hasura.io/learn/#front-end-tutorials"&gt;most popular frontend frameworks&lt;/a&gt; and mobile first languages.&lt;/p&gt;

&lt;p&gt;The highlights of this series are the examples around consuming realtime subscriptions and patterns around handling data in cache.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folbk2sbvc2yu5o6zum72.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folbk2sbvc2yu5o6zum72.png" alt="Image description" width="800" height="623"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Join our GraphQL Learning Circles
&lt;/h2&gt;

&lt;p&gt;Starting from November 2021, We’re going to host GraphQL Learning Circles to go over the various tutorials that we and the GraphQL community have created and contributed to on a weekly basis. If you’d like to host a GraphQL Learning Circle reach out to us on &lt;a href="https://hasura.io/discord"&gt;discord&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Do subscribe us on &lt;a href="https://www.youtube.com/c/HasuraHQ/"&gt;YouTube&lt;/a&gt; to get notified about the schedule for these live tutorials.&lt;/p&gt;

&lt;p&gt;We would love to hear what you would like to see on the Hasura Learn portal. We are constantly updating the tutorials to keep in pace with industry standard language and framework versions and best practices.&lt;/p&gt;

&lt;p&gt;Do check it out and spread the love :)&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Migrate from Graphcool to Hasura</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Sat, 09 May 2020 12:29:12 +0000</pubDate>
      <link>https://forem.com/open-graphql/migrate-from-graph-cool-to-hasura-2mfi</link>
      <guid>https://forem.com/open-graphql/migrate-from-graph-cool-to-hasura-2mfi</guid>
      <description>&lt;p&gt;Graph.cool will be &lt;a href="https://www.graph.cool/sunset-notice"&gt;sunsetted&lt;/a&gt; July 1, 2020. If you have an existing project, it is time to migrate off from their platform to have enough leeway for testing and going production.&lt;/p&gt;

&lt;p&gt;I have been helping a few folks migrate from Graph.cool to Hasura and decided to put together a rough migration path.&lt;br&gt;
&lt;a href="https://hasura.io"&gt;Hasura&lt;/a&gt; is an open source engine that connects to your databases &amp;amp; microservices and auto-generates a production-ready GraphQL backend.&lt;/p&gt;
&lt;h2&gt;
  
  
  Pre-requisites:
&lt;/h2&gt;

&lt;p&gt;We will be using &lt;code&gt;docker&lt;/code&gt; to run some containers (MySQL, Postgres and Hasura). If you don't have docker on your machine yet, it is time to set up. &lt;a href="https://docs.docker.com/get-docker/"&gt;Read their official docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This guide is not comprehensive and some steps require manual intervention depending on your Graph.cool project. Feel free to ask any queries in the comments. You can also &lt;a href="https://twitter.com/praveenweb"&gt;DM me on Twitter&lt;/a&gt;. I will be happy to help you out :)&lt;/p&gt;

&lt;p&gt;But here's roughly what you need to follow to get going.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1: Export data from Graph.cool
&lt;/h2&gt;

&lt;p&gt;Export your Graph.cool data using their &lt;a href="https://export.graph.cool/"&gt;export tool&lt;/a&gt;. This will give a MySQL binary dump of your current Graphcool data.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5ynkgksb8cm4tabe7zik.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5ynkgksb8cm4tabe7zik.png" alt="Graph.cool Export" width="672" height="443"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2: Set up an intermediary MySQL server
&lt;/h2&gt;

&lt;p&gt;We need to set up a MySQL server as an intermediary step in order to migrate data from Graph.cool to Postgres.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2.1: Start MySQL with Docker
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--name&lt;/span&gt; graphcool-mysql &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;MYSQL_ROOT_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;my-secret-pw &lt;span class="nt"&gt;-p&lt;/span&gt; 3306:3306 &lt;span class="nt"&gt;-d&lt;/span&gt; mysql:latest &lt;span class="nt"&gt;--default-authentication-plugin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mysql_native_password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Replace the password (my-secret-pw) as required.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2.2: Connect to MySQL via mysql CLI
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql --user=root --password=my-secret-pw --host=&amp;lt;host&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Replace the host and password as required.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2.3: Create a database in MySQL
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;create database public&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 2.4: Import data
&lt;/h3&gt;

&lt;p&gt;Import Graph.cool's MySQL export into your local MySQL instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql &lt;span class="nt"&gt;--user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;root &lt;span class="nt"&gt;--password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;my-secret-pw &lt;span class="nt"&gt;--host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;host&amp;gt; public &lt;span class="nt"&gt;--binary-mode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &amp;lt; &amp;lt;pathtomysqlexport&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace host and pathtomysqlexport as required. Your data should now be present in the MySQL database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Migrate data to Hasura
&lt;/h2&gt;

&lt;p&gt;Since MySQL is now set up with all the data from Graph.cool, we need to create a Hasura and Postgres instance, and to import the data to the same.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3.1: Set up Hasura
&lt;/h3&gt;

&lt;p&gt;Refer to the &lt;a href="https://hasura.io/docs/1.0/graphql/manual/getting-started/docker-simple.html#docker-simple"&gt;Getting started guide&lt;/a&gt; to set up Hasura using &lt;code&gt;docker-compose&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3.2: Import data into Postgres
&lt;/h3&gt;

&lt;p&gt;We will use &lt;code&gt;pgloader&lt;/code&gt; to migrate from MySQL to Postgres. Refer to their &lt;a href="https://github.com/dimitri/pgloader"&gt;installation guide&lt;/a&gt; for setting this up.&lt;/p&gt;

&lt;p&gt;Once you have installed, execute the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pgloader mysql://root:my-secret-pw@&amp;lt;host&amp;gt;/public postgresql://postgres:postgrespassword@&amp;lt;host&amp;gt;:5432/postgres
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;&amp;lt;host&amp;gt;&lt;/code&gt; and mysql password (my-secret-pw) as required.&lt;/p&gt;

&lt;p&gt;Your data should now be present in the Postgres database.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3.3: Connect Hasura to Postgres
&lt;/h3&gt;

&lt;p&gt;Once the dataset is migrated to Postgres, Hasura should be able to track tables and relationships. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: If you have enums in your Graph.cool project, check out &lt;a href="https://hasura.io/docs/1.0/graphql/manual/schema/enums.html"&gt;Enums in Hasura&lt;/a&gt;, since they're handled differently in Hasura and you would need to change the data structure a bit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Migrate structure &amp;amp; functionality
&lt;/h2&gt;

&lt;p&gt;After migrating the data to Hasura, there is some manual work involved in migrating the structure and functionality of your Graph.cool project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4.1: Restructure connection tables
&lt;/h3&gt;

&lt;p&gt;You can rename tables/columns to match your client-side queries as required. Do note that, for every one-to-one relationship, Graph.cool would have created a connection table to link them. This would require a bit of manual work to restructure. Currently, there is no automation available for this step. Carefully review the connection tables and make the necessary changes.&lt;/p&gt;

&lt;p&gt;Read up more about &lt;a href="https://hasura.io/docs/1.0/graphql/manual/schema/relationships/index.html"&gt;Relationships in Hasura&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4.2: Migrate functions
&lt;/h3&gt;

&lt;p&gt;In case you have functions in Graph.cool, Hasura has an equivalent feature called &lt;a href="https://hasura.io/docs/1.0/graphql/manual/event-triggers/index.html"&gt;Event Triggers&lt;/a&gt;. Migrating this involves taking your code and deploying it on a different platform. It could be a serverless function or all the functions can be combined into a monolith Node.js server. The choice is up to you.&lt;/p&gt;

&lt;p&gt;Do note that for event triggers, the &lt;a href="https://hasura.io/docs/1.0/graphql/manual/event-triggers/payload.html"&gt;payload&lt;/a&gt; that Hasura sends might be different, and you might have to change the way the request body parameters are handled in your function code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4.3: Migrate auth
&lt;/h3&gt;

&lt;p&gt;There are two ways of authenticating users in Graph.cool:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using Auth0&lt;/li&gt;
&lt;li&gt;Using email-password auth.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you were using Auth0 with Graph.cool, the migration should be fairly straightforward. You can configure Hasura with Auth0 easily by following the &lt;a href="https://hasura.io/docs/1.0/graphql/manual/guides/integrations/auth0-jwt.html"&gt;Auth0 guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In case you are using email-password auth, Graph.cool generates mutations for &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;creating a user
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="err"&gt;createUser(authProvider:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;login
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="err"&gt;signinUser(email:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will need to implement these custom mutations using &lt;a href="https://hasura.io/docs/1.0/graphql/manual/actions/index.html"&gt;Hasura Actions&lt;/a&gt;. &lt;br&gt;
Refer to this example for a &lt;a href="https://github.com/hasura/hasura-actions-examples/tree/master/auth"&gt;custom signup mutation&lt;/a&gt;. You can modify this to include login functionality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4.4: Migrate permissions
&lt;/h3&gt;

&lt;p&gt;The CRUD permissions in Graph.cool can be manually migrated to Hasura's permission system. You can define roles in Hasura and configure permissions declaratively for all the CRUD operations. &lt;br&gt;
Refer to &lt;a href="https://hasura.io/docs/1.0/graphql/manual/auth/authorization/index.html"&gt;authorization&lt;/a&gt; for configuring Hasura permissions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Community Tooling for File Storage
&lt;/h2&gt;

&lt;p&gt;Nhost has a community maintained solution &lt;a href="https://github.com/nhost/hasura-backend-plus"&gt;hasura-backend-plus&lt;/a&gt; for handling Files on Cloud providers like S3 in case you are looking for a way to migrate Files from Graph.cool. They also have an Auth solution that can be integrated with Hasura :)&lt;/p&gt;

&lt;h2&gt;
  
  
  Subscriptions
&lt;/h2&gt;

&lt;p&gt;Hasura gives you realtime APIs out of the box. All your Postgres tables can be subscribed from the client using GraphQL Subscriptions.&lt;/p&gt;

&lt;p&gt;I hope this guide gives an indication of the steps involved. In case you are stuck with any of the steps, do ping me :)&lt;/p&gt;

&lt;p&gt;Hasura has an active and a helpful discord community. Do &lt;a href="https://hasura.io/discord"&gt;join the discord server&lt;/a&gt; as well and post your queries.&lt;/p&gt;

</description>
      <category>graphcool</category>
      <category>hasura</category>
      <category>graphql</category>
      <category>migration</category>
    </item>
    <item>
      <title>Approaches to add dynamic content to statically generated sites (JAMStack)</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Wed, 16 Oct 2019 12:14:38 +0000</pubDate>
      <link>https://forem.com/hasurahq/approaches-to-add-dynamic-content-to-statically-generated-sites-jamstack-3g6</link>
      <guid>https://forem.com/hasurahq/approaches-to-add-dynamic-content-to-statically-generated-sites-jamstack-3g6</guid>
      <description>&lt;h1&gt;
  
  
  TL;DR
&lt;/h1&gt;

&lt;p&gt;The different approaches to add dynamic content to statically generated sites with JAMStack.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JAMStack Constraints&lt;/li&gt;
&lt;li&gt;
Types of Content

&lt;ul&gt;
&lt;li&gt;User specific: Public / Auth protected&lt;/li&gt;
&lt;li&gt;Frequency of updates: Infrequent / Frequent&lt;/li&gt;
&lt;li&gt;Interactivity: Non-interactive / Interactive&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Source data during build phase&lt;/li&gt;
&lt;li&gt;Static pages hydrated on client&lt;/li&gt;
&lt;li&gt;Separate Static and Dynamic pages&lt;/li&gt;
&lt;li&gt;Caveats&lt;/li&gt;
&lt;li&gt;Summary&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;&lt;a&gt;JAMStack Constraints&lt;/a&gt;&lt;/h1&gt;

&lt;p&gt;JAMStack is an emerging architecture for web apps which aims to decouple frontend and backend dev teams. Read more about it here. The architecture allows for a performance and operational benefit by imposing a few key constraints on how you build your UI.&lt;/p&gt;

&lt;p&gt;These are the key constraints:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-built markup/UI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Markup is pre-built to ensure good performance and SEO. UI should be pre-built and deployed as HTML files instead of getting rendered on the client (like what vanilla SPAs do).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No server side code that deals with UI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No server side code implies that the UI developer deploys their code as an HTML/CSS bundle, focussing on rendering the frontend. They needn't do server-side templating / server-side rendering.&lt;/p&gt;

&lt;p&gt;As you can imagine, these two constraints give the UI team great ownership in being able to deploy and own their code (no server-side complexity). There is no server side templating like how it's typically done in Django/Rails application and they can assume content will be injected into HTML from a data source.&lt;/p&gt;

&lt;p&gt;JAMStack is great for static sites or static site generators, but the key question is, what about "dynamic" sites or apps?&lt;/p&gt;

&lt;h1&gt;&lt;a&gt;Types of Content&lt;/a&gt;&lt;/h1&gt;

&lt;p&gt;Before we try out these approaches in-depth, let's walkthrough the different types of content to see which approach works for what. The content for a webpage comes from a data source, typically a database. This data could change frequently based on user interactions. There could be multiple data sources to get content from. For example, a blog can have content coming from a database and user information coming from an auth provider. Broadly content types can be classified to be one or more of the following:&lt;/p&gt;

&lt;h3&gt;&lt;a&gt;User specific (public or private)&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;In case of static web pages, the content served would be the same for all users. But what if, depending on the user who is viewing the page the content served needs to be different? Users of the site can also generate personal content and how do you build all those static pages pre-deployment time? &lt;/p&gt;

&lt;p&gt;The answer is simple. You can't build the markup ahead for user specific content. This gives us the classification based on whether the content is publicly accessible or protected. Content on a webpage can be public, accessible to all or protected behind auth and will be different for different users.&lt;/p&gt;

&lt;h3&gt;&lt;a&gt;Frequency of updates (frequent / infrequent)&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Another classification of content would be to base it off on whether the content changes and if so, how often. If content changes frequently, then it needs a dynamic runtime to take over from the pre-built markup that was generated.&lt;br&gt;
Let's say there's page content that you want to change and you want to reflect the changes immediately to your users. With pre-built markup, this doesn't happen realtime and there is a delay with re-building and deploying. Content on a webpage can change frequently, realtime or doesn't change that often.&lt;/p&gt;

&lt;h3&gt;&lt;a&gt;Interactivity (interactive / non-interactive)&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Users interacting with the page in the form of search, comments, forms, e-commerce checkout, payments etc are dynamic and a pure static web page doesn't scale for these kind of interactions. And hence the final classification based on interactions. Content on a webpage can be either interactive or non interactive.&lt;/p&gt;

&lt;h3&gt;
  
  
  Choosing the right approach for your dynamic content
&lt;/h3&gt;

&lt;p&gt;Let's see how we can apply different approaches to handle different types of content and decide which ones are more suitable for a given use case. Go over the below flow to see which approach is applicable for your use case.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OxPSmBC1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/ujeu7kotthf7sqogpz35.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OxPSmBC1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/ujeu7kotthf7sqogpz35.png" alt="JAMStack Dynamic Content" width="800" height="788"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We'll look at different approaches to handle dynamic content and how it can be implemented to make a JAMStack (pre-built markup) site dynamic.&lt;/p&gt;

&lt;h1&gt;&lt;a&gt;Approach #1: Source data during build phase&lt;/a&gt;&lt;/h1&gt;

&lt;p&gt;The simplest way to make JAMStack Dynamic is to source dynamic content at build time. The content can come from any data source. Data sources can be markdown (suited for blogs/docs), JSON/YAML and APIs, including third party ones. The API(s) would be responsible for fetching content from a database or a datastore and thus makes it a powerful way to build sites with dynamic content.&lt;/p&gt;

&lt;p&gt;The data sources are compiled to HTML, typically using a static site generator. During the build phase, these generators traverse through every path of the app and compile flat HTML files out of it. It uses specified data sources to compile the HTML.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jm8b_leF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/ut6l4w2kxvuhdw5ao65w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jm8b_leF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/ut6l4w2kxvuhdw5ao65w.png" alt="Source data during build phase" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With git automation, git push should trigger an automated build which is then deployed to cloud providers. Add a CDN for caching and an app with decent traffic should run easily.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is this architecture best suited for?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's say you have some data which is coming from the database (accessed using APIs) but is not updated frequently. With this architecture, you can cache content which is infrequently updated, and only trigger builds for the content that changes. Do note that the data still comes from a data source like a database/markdown during the build phase and hence any changes will reflect eventually.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trying it out with Gatsby and Hasura&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hasura.io"&gt;Hasura&lt;/a&gt; fits into Dynamic JAMStack with its unified GraphQL API sourced into Gatsby. Here's an &lt;a href="https://github.com/praveenweb/dynamic-jamstack-gatsby-hasura/tree/master/dynamic-source-build"&gt;example&lt;/a&gt; of using Gatsby with Hasura with dynamic content. Hasura is being used as a Headless CMS in this example and the amount of backend code written is significantly reduced.&lt;/p&gt;

&lt;h1&gt;&lt;a&gt;Approach #2: Static pages hydrated on client&lt;/a&gt;&lt;/h1&gt;

&lt;p&gt;As you would imagine, just having pre-built content may not suffice for many apps. In this approach, we will look at how to fetch data at both build and run time for any page. This is achieved using a process called hydration, that allows static markup to be sent to the client which further becomes a dynamic app with the ability to manipulate the DOM. The benefit is obvious; users see a fully rendered page and then it becomes interactive like an SPA.&lt;/p&gt;

&lt;p&gt;Now let's look at various possibilities of dynamic content on the client. You have a site that requires client side functionalities such as search, comments, handling forms and e-commerce actions. Do note that some of them could be coupled with Authentication/Authorization as well.&lt;/p&gt;

&lt;p&gt;To handle these client side interactions, what we need is a pre-rendered static site + a dynamic runtime, maintaining the performance benefits and major parts of SEO.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PsvB1awL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/2eoujt084xme23n8bx1f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PsvB1awL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/2eoujt084xme23n8bx1f.png" alt="Static site hydration" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the markup rendered on the client, we would like the client to take over to make it interactive. This should be possible with hydration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hydration
&lt;/h3&gt;

&lt;p&gt;Hydration is a concept where the client expects the generated markup on both client and server to be identical. It is a process during which the framework (like react/vue) takes over the static HTML sent by the server and turns it DOM that can be manipulated and react to client-side data changes. In short, this makes sure that the client is ready for dynamic content without reloading.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;All pages should work by default without JavaScript being enabled on the browser and client side rendering is just a progressive enhancement.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Interactions -&amp;gt; Serverless Functions
&lt;/h3&gt;

&lt;p&gt;On the client side, the user would typically do auth (login/logout), interactive actions (search, comments) etc.  The user interactions can be forwarded to serverless functions which can internally perform business logic to handle state of the app.&lt;/p&gt;

&lt;p&gt;User interactivity can be lazy loaded on the client. Consider the example of this blog. The Disqus comments are loaded on the client where as the article was pre-rendered during build phase.&lt;/p&gt;

&lt;h3&gt;
  
  
  Realtime
&lt;/h3&gt;

&lt;p&gt;Feed based UIs could require data to come in realtime. How do we update content on the UI realtime? Websockets FTW! A websocket connection can be setup to listen for notifications. Anytime new data comes in, the client is notified about the data update.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_yBj_OhR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/x0isykm6ayuqvmzjfs45.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_yBj_OhR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/x0isykm6ayuqvmzjfs45.png" alt="Realtime Notifications" width="650" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have access to a Realtime GraphQL API, it should be as simple as setting up websockets on the app to connect and fetch live data. Obviously this API needs to support Auth, in case it's required. Here's a &lt;a href="https://www.youtube.com/watch?v=HTEGGndT3zY"&gt;reference&lt;/a&gt; video tutorial for how it's done with Hasura.&lt;/p&gt;

&lt;h3&gt;
  
  
  Asynchronous calls
&lt;/h3&gt;

&lt;p&gt;On the client, you can make asynchronous calls to external APIs for fetching/mutating data for UI views which are not user blocking. The APIs can be serverless functions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trying it out with Gatsby and Hasura&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here's an &lt;a href="https://github.com/praveenweb/dynamic-jamstack-gatsby-hasura/tree/master/dynamic-auth-client"&gt;example&lt;/a&gt; of using Gatsby with Hasura. Markup is hydrated on the client and some data is fetched only during runtime, assuming its dynamic.&lt;/p&gt;

&lt;h1&gt;&lt;a&gt;Approach #3: Separate Static and Dynamic Pages&lt;/a&gt;&lt;/h1&gt;

&lt;p&gt;By now, you would have realised that static data is important for improved page load time and time to interactive. But what about pages which cannot be pre-built at all? Imagine a user profile page or a search results page. The content of these pages cannot be determined during build phase.&lt;/p&gt;

&lt;p&gt;Some pages of the app are completely static, while some are completely dynamic. We can separate out the static and dynamic pages neatly, so that static pages get their performance boost, while dynamic pages are completely loaded on the client, behaving like an SPA.&lt;/p&gt;

&lt;p&gt;Let's consider the example of an e-commerce product page to understand this better. There are some routes which are primarily static and doesn't have dynamic interactions on the client. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Bcl-u8Pe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/42uthg933yjavaaf74t2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Bcl-u8Pe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/42uthg933yjavaaf74t2.png" alt="E-Commerce Dynamic JAMStack" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In an e-commerce site, pages can be pre-built for homepage, listing page, product page etc and can be rendered on the server. But user profile, search results, cart or payment pages cannot be pre-built. They are completely loaded on the client. Usually these pages are also behind Auth.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Completely Static Pages&lt;/em&gt; -&amp;gt; Sourced during build phase. Ideal for performance and SEO. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Completely Dynamic Pages&lt;/em&gt; -&amp;gt; Loaded on client side on demand. Interactive for users. Distributed the load to client. Protected routes are used to block access to users.&lt;/p&gt;

&lt;p&gt;In the above example, product details would be pre-rendered markup where as ADD TO CART would be dynamic interaction on the client and the Cart page itself would be protected by auth, being completely dynamic.&lt;/p&gt;

&lt;h2&gt;&lt;a&gt;Caveats&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;The approaches mentioned above come with a few caveats. Although they are not blockers, it's good to know them to know where this works and where it doesn't.&lt;/p&gt;

&lt;h3&gt;
  
  
  Completely Dynamic Apps
&lt;/h3&gt;

&lt;p&gt;What about apps which are completely protected behind auth? Hasura Console is a good example of that; In fact all admin dashboards are protected behind Auth. Content can be different for users who have logged in. Obviously these pages cannot be built during compile time.&lt;/p&gt;

&lt;p&gt;There is a way to handle this. This approach requires you to build your app as an SPA (Single Page Application) where everything is loaded on the client or SSR (Server Side Rendering) where the server compiles HTML on every request. I didn't mention this approach earlier because this doesn't have any pre-built markup and is not the scope of this post 😃&lt;/p&gt;

&lt;h3&gt;
  
  
  Updating Content
&lt;/h3&gt;

&lt;p&gt;If data in the database changes, the app will not show the current data till it's rebuilt. So the option is to either trigger a rebuild whenever there is a data change or take advantage of hydration to update data dynamically on the client once the page is loaded.&lt;/p&gt;

&lt;h3&gt;
  
  
  What about large sites?
&lt;/h3&gt;

&lt;p&gt;Build time increases with fairly large sites. Assume a content site with over thousands of posts. Rebuilding all the pages would be very slow. Deployments need to be instant. So how does one perform quick deployments? &lt;/p&gt;

&lt;p&gt;Incremental builds is the way forward. Here’s a good read from Netlify. The idea is to cache the older content which doesn't require changing and rebuild only the pages which have been added recently so that deployments are instant. This solution may not exist for all frameworks today.&lt;/p&gt;

&lt;h2&gt;&lt;a&gt;Summary&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;JAMStack is a neat architecture to highlight the benefits of static sites that we were building a few years ago (and continue to). The idea behind Dynamic JAMStack is to get pre-built markup to the client as much as possible and do progressive enhancement on the client via Hydration to open up a lot of possibilities.&lt;/p&gt;

&lt;p&gt;Coupled with modern frontend frameworks and headless CMS, these static sites can become truly dynamic bringing in a whole lot of benefits and flexibility to build powerful apps. This way we build sites for performance.&lt;/p&gt;

&lt;p&gt;Of course these approaches may not be suitable for all types of apps. There are still use cases which requires an app to be completely SPA or completely SSR for obvious reasons and they continue to work well in their current architecture.&lt;/p&gt;

&lt;p&gt;Here are some good reads:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.gatsbyjs.org/blog/2018-10-15-beyond-static-intro/"&gt;Beyond Static: Building Dynamic Apps with Gatsby&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.hawksworx.com/blog/isomorphic-rendering-on-the-jam-stack/"&gt;Isomorphic rendering on the JAMStack&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.indiehackers.com/article/jamstack-for-indie-hackers-b07f7a943d"&gt;JAMStack for Indie Hackers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>jamstack</category>
      <category>gatsby</category>
      <category>graphql</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Build and Deploy Realtime Svelte 3 Apps Using GraphQL</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Thu, 23 May 2019 13:56:38 +0000</pubDate>
      <link>https://forem.com/praveenweb/build-and-deploy-realtime-svelte-3-apps-using-graphql-1fkj</link>
      <guid>https://forem.com/praveenweb/build-and-deploy-realtime-svelte-3-apps-using-graphql-1fkj</guid>
      <description>&lt;h2&gt;
  
  
  What is Svelte?
&lt;/h2&gt;

&lt;p&gt;Svelte is a component framework that compiles components at build step (unlike React/Vue) into highly efficient imperative code that updates the DOM. &lt;/p&gt;

&lt;p&gt;Svelte gives a single &lt;code&gt;bundle.js&lt;/code&gt; that can be referenced in the app's HTML which doesn't contain any framework specific dependencies (magically disappearing framework was their tagline before). The bundles are usually smaller than other frameworks with greater emphasis on accessbility.&lt;/p&gt;

&lt;p&gt;This also means that there is no virtual DOM and no extra work like virtual DOM diffing and it looks like there are performance benefits to it. State management is made easy since its just javascript variables and updating them would re-render the component by updating the DOM directly (truly reactive)&lt;/p&gt;

&lt;p&gt;You will also see in the sample app that there's less boilerplate code than other frameworks to achieve the same functionality. Svelte released their stable version 3 last month and here's an interesting &lt;a href="https://svelte.dev/blog/svelte-3-rethinking-reactivity"&gt;blog&lt;/a&gt; written by Rich Harris if you would like to learn some details.&lt;/p&gt;

&lt;p&gt;Alright! Now let's see how a simple realtime app can be made using Svelte and GraphQL. To get started, we will deploy Hasura.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy Hasura
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://hasura.io"&gt;Hasura&lt;/a&gt; is an &lt;a href="https://github.com/hasura/graphql-engine"&gt;open-source&lt;/a&gt; engine that gives you realtime GraphQL APIs on new or existing Postgres databases, with built-in support for stitching custom GraphQL APIs and triggering webhooks on database changes.&lt;/p&gt;

&lt;p&gt;Follow the instructions in the &lt;a href="https://github.com/hasura/graphql-engine/blob/master/community/sample-apps/svelte-apollo/README.md"&gt;readme&lt;/a&gt; to deploy Hasura and create the tables author and article required for the app. Note the Heroku URL for GraphQL Endpoint. You will be configuring this in the app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clone and Run App
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/svelte-apollo"&gt;demo app&lt;/a&gt; walks you through to build a simple realtime app, listing all authors and articles. &lt;/p&gt;

&lt;p&gt;In this example, we will look at building a simple app to &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetch articles and authors using GraphQL Queries, &lt;/li&gt;
&lt;li&gt;Adding an author using GraphQL Mutations and &lt;/li&gt;
&lt;li&gt;Demonstrate realtime capabilities using GraphQL Subscriptions by updating authors list in realtime.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To integrate GraphQL into Svelte, we will make use of &lt;a href="https://github.com/timhall/svelte-apollo"&gt;svelte-apollo&lt;/a&gt; module to perform queries.&lt;/p&gt;

&lt;p&gt;You can clone and run the app for the demo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git clone git@github.com:hasura/graphql-engine.git
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;graphql-engine/community/sample-apps/svelte-apollo
&lt;span class="nv"&gt;$ &lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installation, you will have to configure the GraphQL endpoint that you got above after deploying Hasura on Heroku.&lt;/p&gt;

&lt;p&gt;Open &lt;code&gt;src/apollo.js&lt;/code&gt; and configure the endpoint.&lt;/p&gt;

&lt;p&gt;Now run the app using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This app was forked off from the standard &lt;a href="https://github.com/sveltejs/template"&gt;template&lt;/a&gt; and svelte-apollo dependency was added to integrate GraphQL&lt;br&gt;
Here's an example of a Svelte component making a GraphQL query to fetch list of articles:&lt;/p&gt;



&lt;p&gt;Here, we are importing the &lt;code&gt;query&lt;/code&gt; method from &lt;code&gt;svelte-apollo&lt;/code&gt; and passing in the client and the GraphQL query to fetch the list of articles. There's also the &lt;code&gt;restore&lt;/code&gt; API to restore a previously executed query into Apollo Cache. The previous query came through preload method called during app initialisation.&lt;/p&gt;

&lt;p&gt;And subscriptions are pretty easy as well:&lt;/p&gt;



&lt;p&gt;If you looked at it carefully, this would be slightly similar to the React hooks style of implementation in the sense of less boilerplate code. &lt;/p&gt;
&lt;h2&gt;
  
  
  Bundle using Rollup
&lt;/h2&gt;

&lt;p&gt;Svelte comes with default Rollup bundling and configuring Rollup is also fairly easy. When you run the command &lt;code&gt;npm run build&lt;/code&gt; , rollup generates a bundle.js, which is referenced in &lt;code&gt;index.html&lt;/code&gt; and bundle.js doesn't contain any framework specific dependencies like React or Vue, since Svelte bundles at compile time.&lt;/p&gt;
&lt;h2&gt;
  
  
  Deployment
&lt;/h2&gt;

&lt;p&gt;Deploying a Svelte app is as simple as deploying a simple static HTML app with javascript and css files.&lt;br&gt;
Let's use &lt;code&gt;now-cli&lt;/code&gt; to deploy the app. Install the now cli, if you don't have already.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And from within your project folder, execute the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will deploy our svelte 3 app on Now using the configuration available in &lt;code&gt;now.json&lt;/code&gt;. Obviously it can be deployed on popular providers like Netlify, Heroku etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Svelte comes with least learning curve despite deviating from JSX style familiar to React developers and i would personally compare the syntax to Vue, as in you focus on writing HTML separately.&lt;/p&gt;

&lt;p&gt;If you are familiar with React/Vue and other virtual DOM based frameworks, you can try out Svelte for less boilerplate code and potential performance benefits. Of course GraphQL integration is pretty easy and you get all the benefits with lesser effort.&lt;/p&gt;

&lt;p&gt;There's also an SSR framework for Svelte named &lt;a href="https://sapper.svelte.dev/"&gt;Sapper&lt;/a&gt;, if you are concerned about SEO.&lt;/p&gt;

&lt;p&gt;Take the demo for a spin and let us know what you think.&lt;/p&gt;

</description>
      <category>svelte</category>
      <category>graphql</category>
      <category>javascript</category>
      <category>hasura</category>
    </item>
    <item>
      <title>Building a Progressive Todo Web App with Vuetify, Vuex and GraphQL</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Tue, 26 Mar 2019 10:38:07 +0000</pubDate>
      <link>https://forem.com/hasurahq/building-a-progressive-todo-web-app-with-vuetify-vuex-and-graphql-4mlc</link>
      <guid>https://forem.com/hasurahq/building-a-progressive-todo-web-app-with-vuetify-vuex-and-graphql-4mlc</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Build a progressive todo app with Vuetify, Vuex, VueApollo and integrate GraphQL APIs using Hasura GraphQL Engine.&lt;/p&gt;

&lt;p&gt;Instant setup. App Source Code 👉 &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/vuetify-vuex-todo-graphql" rel="noopener noreferrer"&gt;vuetify-vuex-todo-graphql&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fivvmkt9qapl0osfvtm9h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fivvmkt9qapl0osfvtm9h.png" alt="vuetify+vuex+graphql" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;p&gt;This progressive web app uses the following frameworks/servers&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vue.js with Vuetify for Material Design UI, Vuex for state management, VueApollo for making GraphQL queries&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/hasura/graphql-engine" rel="noopener noreferrer"&gt;Hasura GraphQL Engine&lt;/a&gt; to get instant GraphQL APIs over Postgres&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Vuetify Framework
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://vuetifyjs.com/" rel="noopener noreferrer"&gt;Vuetify&lt;/a&gt; is a semantic component framework for Vue. It is built according to Google's Material Design Spec and has intuitive properties without complex classes and markup.&lt;/p&gt;

&lt;p&gt;In this app, we make use of Vuetify components like VGrid, VCard, VList, VTextField, VBtn among a bunch of available reusable components.&lt;/p&gt;

&lt;p&gt;The progressive todo web app is a fork of &lt;a href="https://github.com/davidgaroro/vuetify-todo-pwa" rel="noopener noreferrer"&gt;davidgaroro/vuetify-todo-pwa&lt;/a&gt; which uses&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vuetify for the TodoMVC UI with material design&lt;/li&gt;
&lt;li&gt;Vuex for state management&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's how the todo app looks like with Vuetify's material design components:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F985yshqb4341l2to97yb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F985yshqb4341l2to97yb.png" alt="Todo App" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We added &lt;strong&gt;vue-apollo&lt;/strong&gt; to this app and configured &lt;strong&gt;ApolloClient&lt;/strong&gt; to make GraphQL queries for storing and managing the todos in the database. We will use Hasura to get instant GraphQL APIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hasura + vue-apollo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://hasura.io/" rel="noopener noreferrer"&gt;Hasura&lt;/a&gt; is an &lt;a href="https://github.com/hasura/graphql-engine" rel="noopener noreferrer"&gt;open-source&lt;/a&gt; engine that gives you realtime GraphQL APIs on new or existing Postgres databases, with built-in support for stitching custom GraphQL APIs and triggering webhooks on database changes.&lt;/p&gt;

&lt;p&gt;We will integrate Hasura GraphQL APIs with this todo app. Refer the &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/vuetify-vuex-todo-graphql" rel="noopener noreferrer"&gt;github&lt;/a&gt; link to deploy Hasura and create the todos table.&lt;/p&gt;

&lt;p&gt;Once we have Hasura deployed, we can configure the frontend to make GraphQL queries. We add all modules required to configure ApolloClient.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt; &lt;span class="nx"&gt;vue&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;apollo&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt; &lt;span class="nx"&gt;apollo&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="nx"&gt;apollo&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="nx"&gt;apollo&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="nx"&gt;apollo&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;inmemory&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;tag&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: You can also use &lt;strong&gt;apollo-boost&lt;/strong&gt;, if you don't need fine grained control over configuration&lt;/p&gt;

&lt;p&gt;We define &lt;strong&gt;ApolloClient&lt;/strong&gt; in &lt;code&gt;src/apollo.js&lt;/code&gt; file in the todo app,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Vue&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;VueApollo&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue-apollo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ApolloClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;apollo-client&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;HttpLink&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;apollo-link-http&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;InMemoryCache&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;apollo-cache-inmemory&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;httpLink&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;HttpLink&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="c1"&gt;// You should use an absolute URL here&lt;/span&gt;
  &lt;span class="na"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://myapp.herokuapp.com/v1alpha1/graphql&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Create the apollo client&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apolloClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ApolloClient&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;link&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;httpLink&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;InMemoryCache&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="na"&gt;connectToDevTools&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apolloProvider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;VueApollo&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;defaultClient&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;apolloClient&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Install the vue plugin&lt;/span&gt;
&lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;VueApollo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;apolloProvider&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to just configure Hasura GraphQL Engine endpoint in the &lt;code&gt;httpLink&lt;/code&gt; and import this apolloProvider in &lt;code&gt;main.js&lt;/code&gt; and add it to the Vue instance like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Vue&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App.vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./router&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./store&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;apolloProvider&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./apollo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./registerServiceWorker&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./vuetify&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;productionTip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;apolloProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;render&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;$mount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once this is configured, the apolloClient can be imported and used across the app.&lt;/p&gt;

&lt;p&gt;We define the GraphQL queries/mutations and trigger them in &lt;strong&gt;Vuex store&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example, to fetch all the todos, we define a simple query to fetch todos sorted by latest id.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;todoQuery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="s2"&gt;`{
    todos(order_by: [{id: desc}]) {
      id
      text
      is_completed
    }
}`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and in our actions, we make this query using apolloClient and invoke the mutation handler using &lt;strong&gt;commit&lt;/strong&gt; which will update the state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;actions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;fetchTodos &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;apolloClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;todoQuery&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="nf"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fetchTodos&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that we are making use of &lt;strong&gt;async, await&lt;/strong&gt; which makes the syntax cleaner.&lt;/p&gt;

&lt;p&gt;Let's define a GraphQL mutation to insert a new todo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;todoMutation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="s2"&gt;`
  mutation insert_todos($text: String!) {
    insert_todos(objects: [{text: $text}]) {
      affected_rows
      returning {
        id
        text
        is_completed
      }
    }
}`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This mutation accepts a &lt;code&gt;$text&lt;/code&gt; variable and inserts it into the todos table.&lt;/p&gt;

&lt;p&gt;Similarly we define GraphQL mutations for adding/updating/deleting todos and we define actions to make the mutation and update the state in the Vuex store.&lt;/p&gt;

&lt;h2&gt;
  
  
  Progressive Web App
&lt;/h2&gt;

&lt;p&gt;This todo app is a PWA and comes with boilerplate setup for&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;App manifest&lt;/li&gt;
&lt;li&gt;Service worker&lt;/li&gt;
&lt;li&gt;Workbox options - &lt;a href="https://developers.google.com/web/tools/workbox/guides/common-recipes#google_fonts" rel="noopener noreferrer"&gt;Cache Google Fonts&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;which can be configured to get a Lighthouse score of 100.&lt;/p&gt;

&lt;h2&gt;
  
  
  Todo App Source Code
&lt;/h2&gt;

&lt;p&gt;I have put together the app with complete GraphQL integration so that you can get started quickly and extend it further!&lt;/p&gt;

&lt;p&gt;Check it out on &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/vuetify-vuex-todo-graphql" rel="noopener noreferrer"&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note that this app doesn't have any user authentication yet and its currently a demo to integrate GraphQL queries/mutations with Vuetify + Vuex with Hasura.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>vuetify</category>
      <category>graphql</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Build Responsive Cross Platform Vue Apps with Quasar Framework and GraphQL</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Wed, 20 Mar 2019 11:48:00 +0000</pubDate>
      <link>https://forem.com/hasurahq/build-responsive-cross-platform-vue-apps-with-quasar-framework-and-graphql-59a1</link>
      <guid>https://forem.com/hasurahq/build-responsive-cross-platform-vue-apps-with-quasar-framework-and-graphql-59a1</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;br&gt;
Build responsive SPAs, SSR Apps, PWAs, Hybrid Mobile / Electron Apps using a single codebase with &lt;a href="https://quasar-framework.org/" rel="noopener noreferrer"&gt;Quasar Framework&lt;/a&gt; powered by Vue.js and GraphQL APIs over postgres using Hasura GraphQL Engine. &lt;/p&gt;

&lt;p&gt;Instant setup. Tutorial/boilerplate 👉 &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/quasar-framework-vue-graphql" rel="noopener noreferrer"&gt;quasar-framework-vue-graphql&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5u2yyjpepe3amacqqvlr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5u2yyjpepe3amacqqvlr.png" alt="quasar-with-hasura"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Quasar Framework
&lt;/h2&gt;

&lt;p&gt;Quasar Framework is a high performance full frontend stack allowing developers to maintain a single codebase to build different types of apps (SPA, SSR, Hybdrid etc).&lt;br&gt;
It is powered by Vue.js but comes with its own set of built-in &lt;a href="https://quasar-framework.org/components/" rel="noopener noreferrer"&gt;web components&lt;/a&gt; that can be imported to quickly construct an interface for the app.&lt;/p&gt;
&lt;h2&gt;
  
  
  Hasura with Quasar
&lt;/h2&gt;

&lt;p&gt;Hasura is an &lt;a href="https://github.com/hasura/graphql-engine" rel="noopener noreferrer"&gt;open-source&lt;/a&gt; engine that gives you realtime GraphQL APIs on new or existing Postgres databases, with built-in support for stitching custom GraphQL APIs and triggering webhooks on database changes.&lt;/p&gt;

&lt;p&gt;Hasura GraphQL fits in neatly in this workflow of building cross platform apps. All the clients(mobile app/electron app) use the same set of APIs controlled by the same set of permissions and auth and can leverage the power of Postgres. Quasar gives endless possibilities with one codebase and a common GraphQL API from Hasura adds to the easier development workflow.&lt;/p&gt;

&lt;p&gt;Now let's see some implementation details for a simple author/article blog app:&lt;/p&gt;
&lt;h2&gt;
  
  
  Plugins
&lt;/h2&gt;

&lt;p&gt;Quasar allows users to define app plugins which can be used to run code before the root Vue instance is instantiated.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;quasar new plugin apollo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we define the apollo plugin inside &lt;code&gt;src/plugins/apollo.js&lt;/code&gt; and create the &lt;strong&gt;ApolloClient&lt;/strong&gt; with Hasura GraphQL API Endpoint.&lt;/p&gt;

&lt;p&gt;In this sample app, we are making use of this plugin to inject Apollo props to Vue prototype. So inside &lt;strong&gt;.vue&lt;/strong&gt; files, we can make use of &lt;strong&gt;this.$apollo&lt;/strong&gt; to execute any graphql specific actions.&lt;br&gt;
We can configure quasar to add the new plugin by modifying &lt;strong&gt;quasar.conf&lt;/strong&gt; and adding &lt;strong&gt;apollo&lt;/strong&gt; in the plugins list as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = function (ctx) {
  return {
    // app plugins (/src/plugins)
    plugins: [
      'apollo'
    ],
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the layouts, we have defined a layout drawer listing out the authors and a simple GraphQL query to fetch author has been used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;openURL&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;quasar&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;graphql-tag&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;authorQuery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="s2"&gt;`
  query {
    author {
      id
      name
    }
  }`&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MyLayout&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;data &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;leftDrawerOpen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;is&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;desktop&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;methods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;openURL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;fetchArticles &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/author/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;apollo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Simple query that will update the 'author' vue property&lt;/span&gt;
    &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;authorQuery&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is still the same kind of code you would have written with Vue.js apps to make a GraphQL query with &lt;strong&gt;vue-apollo&lt;/strong&gt;. But the difference is the &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; where quasar gives native-like components to build hybrid apps. &lt;/p&gt;

&lt;p&gt;The author list is rendered on a &lt;code&gt;&amp;lt;q-layout-drawer&amp;gt;&lt;/code&gt; and it is automatically responsive as with every quasar layout component. Quasar comes with all sorts of layout, button, form components and more that you can get you started quickly to create a native feel app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build Targets
&lt;/h2&gt;

&lt;p&gt;Quasar requires you to specify the mode &lt;code&gt;spa|ssr|pwa|cordova|electron&lt;/code&gt; of the app and the target &lt;code&gt;cordova|electron&lt;/code&gt; (in case its a hybrid app). You can also specify themes like material, ios etc which will apply the styles for each component appropriately.&lt;/p&gt;

&lt;p&gt;Read more about build targets &lt;a href="https://quasar-framework.org/guide/app-build-commands.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have put together a boilerplate and tutorial so that you can get started quickly!&lt;br&gt;
Check it out on &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/quasar-framework-vue-graphql" rel="noopener noreferrer"&gt;github&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>graphql</category>
      <category>hasura</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Build and Deploy Serverless React Apps with Next.js 8 and Zeit Now</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Thu, 21 Feb 2019 11:39:17 +0000</pubDate>
      <link>https://forem.com/hasurahq/build-and-deploy-serverless-react-apps-with-nextjs-8-and-zeit-now-22op</link>
      <guid>https://forem.com/hasurahq/build-and-deploy-serverless-react-apps-with-nextjs-8-and-zeit-now-22op</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;: Configure Next.js 8 serverless mode to generate lambdas for each page. Use Hasura GraphQL API as data layer. Deploy to Zeit Now. Instant setup. Tutorial/boilerplate 👉 &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/nextjs-8-serverless" rel="noopener noreferrer"&gt;nextjs-8-serverless&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.hasura.io%2Fcontent%2Fimages%2F2019%2F02%2Fnextjs-serverless-now-hasura-graphql.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.hasura.io%2Fcontent%2Fimages%2F2019%2F02%2Fnextjs-serverless-now-hasura-graphql.png" alt="Next.js Serverless Now Hasura GraphQL"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nextjs.org/blog/next-8#serverless-nextjs" rel="noopener noreferrer"&gt;Next.js 8&lt;/a&gt; landed last week with support for serverless deployment. With this release, Next.js splits an application into serverless lambdas helping improve both reliability and scalability. The "pay for what you use" model is one of the key benefits to going serverless. There are obvious other benefits like distributed points of failure and scale as you go. Out of the box support for serverless is exciting!&lt;/p&gt;

&lt;p&gt;To quickly test this out, i had created a Next.js 8 app integrating Hasura GraphQL Engine. The app had a couple of pages; index and about. The index page renders a list of authors fetched from Hasura GraphQL. The about page renders some static text. Here are the instructions for you to get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy Hasura
&lt;/h2&gt;

&lt;p&gt;Follow the instructions in the &lt;a href="https://github.com/hasura/graphql-engine/blob/master/community/sample-apps/nextjs-8-serverless/README.md" rel="noopener noreferrer"&gt;readme&lt;/a&gt; to deploy Hasura and create the table author required for the app. Note the Heroku URL for GraphQL Endpoint. You will be configuring this in the app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clone and Run app
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/nextjs-8-serverless" rel="noopener noreferrer"&gt;demo app&lt;/a&gt; walks you through to build a simple app, listing all authors. You can clone and run the app for the demo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git clone git@github.com:hasura/graphql-engine.git
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;graphql-engine/community/sample-apps/nextjs-8-serverless
&lt;span class="nv"&gt;$ &lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installation, you will have to configure the GraphQL endpoint that you got above.&lt;/p&gt;

&lt;p&gt;Open &lt;strong&gt;lib/init-apollo.js&lt;/strong&gt; and configure Hasura GraphQL Endpoint in &lt;strong&gt;uri&lt;/strong&gt;&lt;br&gt;
Now run the app by using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and visit &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; to view the app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enabling Serverless Mode&lt;/strong&gt;&lt;br&gt;
To enable serverless mode, we add the serverless build target in next.config.js.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;serverless&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it! Now build the serverless app by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The build that is generated by Next.js has a &lt;strong&gt;very low footprint&lt;/strong&gt;, with the base zip size of the serverless function being &lt;strong&gt;50KB&lt;/strong&gt;. The function that is output doesn't require any other dependencies, since everything required is already bundled in. Of course, depending on the page's internal dependencies, the final size would be more than 50KB.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;.next&lt;/strong&gt; folder, you will see a &lt;strong&gt;serverless&lt;/strong&gt; folder generated after the build. Inside that there is a &lt;strong&gt;pages&lt;/strong&gt; folder, which will have outputs of lambda per page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pages/index.js =&amp;gt; .next/serverless/pages/index.js
pages/about.js =&amp;gt; .next/serverless/pages/about.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These pages can now be independently deployed onto other cloud providers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy to Now Platform
&lt;/h2&gt;

&lt;p&gt;The Now Platform gives a seamless way to deploy it to the cloud with &lt;a href="https://zeit.co/now" rel="noopener noreferrer"&gt;now&lt;/a&gt; (&lt;a href="https://zeit.co/download" rel="noopener noreferrer"&gt;download&lt;/a&gt;): Run the following commands to deploy&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install -g now
$ now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Older versions of now-cli doesn't support serverless mode.&lt;/p&gt;

&lt;p&gt;Once the deployment is successful, you will be able to navigate to pages &lt;strong&gt;/&lt;/strong&gt; and &lt;strong&gt;/about&lt;/strong&gt;, with each one internally being a lambda function which Now manages.&lt;br&gt;
The Now Platform takes care of the routing which is available across a few regions. The lambdas are all deployed onto AWS. You can read more about available routing and regions &lt;a href="https://zeit.co/docs/v2/platform/regions-and-providers/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The outputs of the build process can be static files or serverless lambdas. Static files will be served directly from Zeit's &lt;a href="https://zeit.co/docs/v2/domains-and-aliases/cdn/" rel="noopener noreferrer"&gt;edge caches&lt;/a&gt;, while lambdas contain code that gets executed dynamically and on-demand.&lt;/p&gt;

&lt;p&gt;As you can see in the image below, about and index pages are lambdas. The static assets are being cached by Zeit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.hasura.io%2Fcontent%2Fimages%2F2019%2F02%2Fnextjs-now-serverless.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.hasura.io%2Fcontent%2Fimages%2F2019%2F02%2Fnextjs-now-serverless.png" alt="Now Deployment"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Migrating from older versions
&lt;/h2&gt;

&lt;p&gt;Next.js 8 maintains backward compatibility and hence for most applications, all you need to do is run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm i next@latest react@latest react-dom@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And set up the config in next.config.js to have the serverless build target and you should be good to go.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;This is an interesting shift towards deploying web apps as serverless lambdas. Since each page of the app is a lambda, you pay only for the number of invocations and you can choose to scale high traffic pages selectively. Static assets can be cached as well, providing an affordable and scalable option from day 1.&lt;br&gt;
Check out the sample app on &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/nextjs-8-serverless" rel="noopener noreferrer"&gt;github&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>serverless</category>
      <category>react</category>
      <category>nextjs</category>
      <category>zeit</category>
    </item>
    <item>
      <title>Create Nuxt.js Universal Apps using GraphQL and Postgres</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Wed, 30 Jan 2019 14:43:45 +0000</pubDate>
      <link>https://forem.com/hasurahq/create-nuxtjs-universal-apps-using-graphql-and-postgres-154h</link>
      <guid>https://forem.com/hasurahq/create-nuxtjs-universal-apps-using-graphql-and-postgres-154h</guid>
      <description>&lt;h1&gt;
  
  
  TL;DR:
&lt;/h1&gt;

&lt;p&gt;Server side render websites using &lt;a href="https://nuxtjs.org/"&gt;Nuxt.js&lt;/a&gt; and &lt;a href="https://graphql.org/"&gt;GraphQL&lt;/a&gt; APIs over postgres using Hasura GraphQL Engine. Instant setup. Tutorial/boilerplate 👉 &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/nuxtjs-postgres-graphql"&gt;nuxtjs-postgres-graphql&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--78kVjZfb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/b9kdnvl00v541vm2oolh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--78kVjZfb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/b9kdnvl00v541vm2oolh.png" alt="Nuxt.js Hasura GraphQL Postgres" width="800" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Building universal apps is generally touted to be hard and Nuxt.js is here to solve this for Vue.js apps by being performant and modular. Hasura GraphQL Engine makes it easy to get GraphQL APIs on top of Postgres database. In this post, we will look at how these two can be integrated.&lt;/p&gt;

&lt;h1&gt;
  
  
  Nuxt.js
&lt;/h1&gt;

&lt;p&gt;Nuxt.js gives full support for SSR apps and takes care of the common pitfalls. Being a universal app makes it more exciting; the page is server rendered and then SPA takes over. This is how it works:&lt;/p&gt;

&lt;h4&gt;
  
  
  Pages:
&lt;/h4&gt;

&lt;p&gt;Nuxt is opinionated on the project directory structure. It will transform every .vue file inside the pages directory as a route for the application. The community has embraced the opinionated directory structure with different projects (looking at you Gatsby, Next.js) and its quite easy to get familiar with. In the boilerplate example, you can see how the &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/nuxtjs-postgres-graphql/pages"&gt;pages&lt;/a&gt; are structured. For more information on the directory structure that Nuxt enforces, read more &lt;a href="https://nuxtjs.org/guide/directory-structure"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Server side data fetching:
&lt;/h4&gt;

&lt;p&gt;Nuxt community has built this &lt;a href="https://github.com/nuxt-community/apollo-module"&gt;apollo-module&lt;/a&gt; that sets up apollo client for a GraphQL endpoint. So in the index.vue page, we add the apollo snippet inside script as follows:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Here, author is a graphql query which fetches the list of authors from the database and updates the author property in vue. This GraphQL query is executed on the server and the data is available in template which allows the page to be rendered server side. The same query is then executed on the client side as well, making it universal/isomorphic. apollo-module in Nuxt accepts a clientConfig which can be used to configure endpoint, authentication and other parameters as well.&lt;/p&gt;

&lt;h4&gt;
  
  
  Nuxt.js + Hasura + apollo-module = Universal apps with GraphQL!
&lt;/h4&gt;

&lt;p&gt;I have put together a boilerplate and tutorial so that you can get started quickly!&lt;/p&gt;

&lt;p&gt;Check it out on &lt;a href="https://github.com/hasura/graphql-engine/tree/master/community/sample-apps/nuxtjs-postgres-graphql"&gt;github&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>vue</category>
      <category>nuxt</category>
      <category>javascript</category>
    </item>
    <item>
      <title>awesome-angular-graphql: A curated collection of resources for Angular and GraphQL</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Mon, 26 Nov 2018 09:37:34 +0000</pubDate>
      <link>https://forem.com/hasurahq/awesome-angular-graphql-a-curated-collection-of-resources-for-angular-and-graphql-m7n</link>
      <guid>https://forem.com/hasurahq/awesome-angular-graphql-a-curated-collection-of-resources-for-angular-and-graphql-m7n</guid>
      <description>&lt;p&gt;This is a compilation of resources, clients and tools that make working with &lt;code&gt;GraphQL and Angular&lt;/code&gt; awesome.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/hasura/awesome-angular-graphql"&gt;https://github.com/hasura/awesome-angular-graphql&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to suggest more articles/videos/tools.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>graphql</category>
      <category>awesomelist</category>
    </item>
    <item>
      <title>Setting up a production ready realtime GraphQL backend in just a few minutes</title>
      <dc:creator>Praveen Durairaju</dc:creator>
      <pubDate>Tue, 20 Nov 2018 15:43:28 +0000</pubDate>
      <link>https://forem.com/hasurahq/setting-up-a-production-ready-realtime-graphql-backend-in-just-a-few-minutes-13bf</link>
      <guid>https://forem.com/hasurahq/setting-up-a-production-ready-realtime-graphql-backend-in-just-a-few-minutes-13bf</guid>
      <description>&lt;p&gt;Since Facebook &lt;a href="https://code.fb.com/core-data/graphql-a-data-query-language/" rel="noopener noreferrer"&gt;announced GraphQL&lt;/a&gt; three years ago, GraphQL popularity has grown by leaps and bounds. In the &lt;a href="https://2018.stateofjs.com/data-layer/overview/" rel="noopener noreferrer"&gt;2018 state of javascript survey&lt;/a&gt;, 83% of JS developers had either used GraphQL or wanted to learn it, and it is well on its way to becoming a megatrend. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4q4zxkwbt7fm9sojgfsp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4q4zxkwbt7fm9sojgfsp.png" alt="npm trends for GraphQL" width="800" height="357"&gt;&lt;/a&gt;&lt;/p&gt;
npm trends for GraphQL



&lt;p&gt;Adopting GraphQL can result in a significant increase in feature velocity, and any organization looking at new product development or re-architecting their existing products should seriously evaluate GraphQL and the benefits that it brings. &lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started with GraphQL quickly
&lt;/h2&gt;

&lt;p&gt;At Hasura, we have just released the &lt;a href="https://hasura.io/diy-graphql-baas" rel="noopener noreferrer"&gt;DIY Realtime GraphQL BaaS&lt;/a&gt;. It uses the &lt;a href="https://github.com/hasura/graphql-engine" rel="noopener noreferrer"&gt;Hasura GraphQL Engine&lt;/a&gt;, Auth0 and DigitalOcean, to help you setup a production ready GraphQL backend in a few minutes - sort of like Firebase, but for realtime GraphQL, over Postgres, on your own infrastructure. It offers you the ease of use of a BaaS (set up in a few minutes), while allowing you to retain flexibility and control going forward. &lt;/p&gt;

&lt;p&gt;Here’s how you can set it up: &lt;/p&gt;

&lt;p&gt;1) Deploy the Hasura GraphQL engine on DigitalOcean using the &lt;a href="https://cloud.digitalocean.com/droplets/new?image=hasura-18-04" rel="noopener noreferrer"&gt;one-click deploy&lt;/a&gt;. It comes with a Postgres database and Caddy webserver for easy and automatic HTTPS using Let’s Encrypt.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fhasura.io%2Frstatic%2Fdist%2Faff7bcdcffab8cf6be860b30f687ab2e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fhasura.io%2Frstatic%2Fdist%2Faff7bcdcffab8cf6be860b30f687ab2e.png" alt="Deploy Hasura GraphQL on DigitalOcean" width="800" height="400"&gt;&lt;/a&gt; &lt;/p&gt;
Deploy Hasura GraphQL on DigitalOcean



&lt;p&gt;2) &lt;a href="https://docs.hasura.io/1.0/graphql/manual/getting-started/first-graphql-query.html" rel="noopener noreferrer"&gt;Create your schema&lt;/a&gt; using the Hasura console. The Hasura GraphQL Engine will give you instant GraphQL APIs, for queries, mutations and subscriptions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fhasura.io%2Frstatic%2Fdist%2Fa3334540075c7ca1266194670ddb56a3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fhasura.io%2Frstatic%2Fdist%2Fa3334540075c7ca1266194670ddb56a3.png" alt="Create schema Hasura" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;
Create schema

 

&lt;p&gt;3) Configure Auth0 rules and callback URLs, and &lt;a href="https://docs.hasura.io/1.0/graphql/manual/guides/integrations/auth0-jwt.html" rel="noopener noreferrer"&gt;integrate&lt;/a&gt; it with Hasura.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fhasura.io%2Frstatic%2Fdist%2Fd01922a476e7cbee087e6884bb406ff2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fhasura.io%2Frstatic%2Fdist%2Fd01922a476e7cbee087e6884bb406ff2.png" alt="Auth0 setup" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;
Configure access control rules

  

&lt;p&gt;And that’s it! You have a full-fledged backend with GraphQL APIs and Authentication/authorization on managed infrastructure. On the 5$ machine, you should be able to handle thousands of users. Of course, if you want to handle more users, you can just upgrade the underlying infra. &lt;/p&gt;

&lt;p&gt;We have used DigitalOcean and Auth0 for this example for their ease of use, you can use any other &lt;a href="https://docs.hasura.io/1.0/graphql/manual/deployment/index.html" rel="noopener noreferrer"&gt;infrastructure provider&lt;/a&gt; or &lt;a href="https://docs.hasura.io/1.0/graphql/manual/auth/index.html" rel="noopener noreferrer"&gt;authentication provider&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Next steps
&lt;/h2&gt;

&lt;p&gt;Once you have the BaaS setup, there are tons of other cool things you can do as you build complex applications, and take them to production: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write custom backend code or business logic and use &lt;a href="https://blog.hasura.io/the-ultimate-guide-to-schema-stitching-in-graphql-f30178ac0072" rel="noopener noreferrer"&gt;schema stitching&lt;/a&gt; to merge with Hasura.&lt;/li&gt;
&lt;li&gt;Manage postgres &lt;a href="https://docs.hasura.io/1.0/graphql/manual/migrations/existing-project.html" rel="noopener noreferrer"&gt;migrations&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;
&lt;a href="http://hasura.io/event-triggers" rel="noopener noreferrer"&gt;Trigger webhooks&lt;/a&gt; on Database events to integrate with serverless functions.&lt;/li&gt;
&lt;li&gt;Set up logging and monitoring with &lt;a href="https://blog.hasura.io/uptime-monitoring-for-hasura-graphql-engine-with-datadog-on-gke-4faff5832e7f" rel="noopener noreferrer"&gt;DataDog&lt;/a&gt; and &lt;a href="https://blog.hasura.io/graphql-observability-with-hasura-graphql-engine-and-honeycomb-ee0a1a836c41" rel="noopener noreferrer"&gt;Honeycomb&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you get stuck somewhere or you have some questions, feel free to talk to us on our &lt;a href="https://discord.gg/3FNQnWj" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Full disclosure: I am an engineer working at &lt;a href="http://hasura.io" rel="noopener noreferrer"&gt;Hasura&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>graphql</category>
      <category>hasura</category>
      <category>baas</category>
      <category>realtime</category>
    </item>
  </channel>
</rss>
