Build a CRUD Application with Hasura and Vue-Apollo

Build a CRUD Application with Hasura and Vue-Apollo

In this tutorial, we would be building a simple Vue application with Hasura and Vue-Apollo that allows you to add, delete, and get all books you have read.

In this tutorial, we would be building a simple Vue application with Hasura and Vue-Apollo that allows you to add, delete, and get all books you have read.

Prerequisites

  • Familiarity with HTML, CSS and JavaScript
  • Basic Knowledge of Vuejs
  • Basic Knowledge of Graphql
  • GraphQL Playground app. Download here
  • VS Code or any other code editor

App Requirements

  • Hasura: It’s an open-source graphql service that gives you instant realtime graphql APIs with PostGre database.
  • Heroku: We would be using heroku for hosting the API.
  • Vue-Apollo: This integrates ApolloClient in our Vue app with declarative components. We would use vue-apollo to consume our graphQL API

GraphQL is a query language for your APIs and runtime for consuming those queries with your existing data. Simply, it gives you the luxury of asking for a specific kind of data from your server and getting expected results.

GraphQL has two parts:

  • The Server: GraphQL server simply exposes your API via a single endpoint. APIs here are written as a series of type definitions and resolvers. Graphql gives you a variety of server libraries to expose your APIs.
  • The Client: GraphQL client accepts queries on the frontend, connects to the server endpoint, and ask for the data you want to receive. They are also a variety of client libraries and JavaScript has a handful including popular libraries such as AWS Amplify and ApolloClient.

Let’s get started with coding already

Building the API and setting up DB with Hasura

Let’s get our API and database ready. Follow these steps:

  • Go to hasura.io and sign up. Then click the Start for free button.
  • Create my first project and then choose heroku (sign up if you don’t have an account) for Database Setup.
  • Give it some seconds, and it’ll generate a postgre uri, copy it and store somewhere. Next page would have your console details, you can screenshot them too. You should also get your graphql API url. Something like this: this
  • Now we are here in the hasura graphql console, let’s create our database tables and relationships.

Setting up database Navigate to the Data tab. We would just be working with a single table called books. Click the add table on the left sidebar of the console. Follow these steps:

  • Give the table a name, i’m calling mine, “books” but you can decide to call yours anything else.
  • Create a column, name it “id”, set column_type to integer(auto-increment) and select the Unique checkbox.
  • Create another column, name it “title” and set column_type to text. Create 2 other columns, name them description and written_by and set their column_type to text.
  • Create a column, name it is_completed, set the column_type to date and default to now().
  • On the Primary Key field, select the id. Then click on Add table, this should successfully create your books table.

At the end, you should have something like this:

At the moment, our table has no rows. Let’s create some. Click on the Insert Row tab and add some content to the empty fields (text, description and written_by). You should have something like this when you browse rows:

graphql tutorials vue crud application hasura vue-apollo

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Building GraphQL APIs with Vue.js and Apollo Client

Learn how to build GraphQL APIs with Vue.js and Apollo Client. Integrate APIs through GraphQL with Vue using Vue-apollo. Install the vue-apollo-client and their dependencies 📦 in your Vue application. GraphQL is the most easygoing way to querying APIs. Apollo client is a community-driven effort to build an easy-to-understand, flexible, and powerful GraphQL client.

Discover GraphQL by Building a Headless Blog with Apollo and Slash GraphQL

This tutorial will show you how to build a blog using React for the frontend, Apollo for ... instance on Heroku (eg: https://your-app.herokuapp.com) without the trailing slash ... React for the frontend, and Apollo for requesting the Strapi API with GraphQL. ... Check the article find and findone routes and save.

Building a Stocks Price Notifier App using React, Apollo GraphQL and Hasura

We’re going to build a Stocks Price Notifier application by using React, Apollo GraphQL, and Hasura GraphQL engine. We’re going to start the project from a create-react-app boilerplate code and would build everything ground up. We’ll learn how to set up the database tables, and events on the Hasura console. We’ll also learn how to wire up Hasura’s events to get stock price updates using web-push notifications.

Learn Vue Apollo With GraphQL in 15 Minutes

Learn Vue Apollo With GraphQL in 15 Minutes - Vue.js and Apollo go together really well with GraphQL. In this video I discuss how to get client side Vue working using the Vue Apollo plugin!

Vue MEVN Stack Tutorial - Build Full Stack Vue.js CRUD App

This is a step by step MEVN stack tutorial, in this tutorial, we are going to learn how to create MEVN stack app. (MongoDB, Express.js, Vue.js, Node.js). I will show you how to create a Full-stack single page application with Vue from scratch. We will create a simple yet best Student Record Management system.