Hasura GraphQL
Introduction
The Hasura GraphQL Server Template is a starter kit for the development of GraphQL API using Hasura. This template offers a pre-configured setup with sample data models for books, authors, genres, tags, and users. It provide smooth start and can be easily customized to suit specific needs.
Features
- Instant GraphQL API using Hasura: Automatically generate GraphQL APIs over PostgreSQL database.
- Hasura GraphQL Console: Interactive web interface for API exploration and database management.
- Dockerized Setup: Quick and easy deployment using Docker and Docker Compose.
- Sample Data Models: Predefined schemas for books, authors, genres, tags, and users to kickstart the project.
- Automatic Migration using Hasura cli: Simplify database management with schema and metadata migrations.
Technologies Used
- Hasura GraphQL Engine: An open-source engine that provides instant GraphQL APIs over PostgreSQL.
- PostgreSQL: A powerful, open-source relational database system.
- Docker & Docker Compose: Tools for containerization to ease setup and deployment.
- GraphQL: A query language for APIs and a runtime for fulfilling those queries.
Installation Steps
To utilize the Apollo GraphQL Server Template with Universal-Box, follow these steps:
- Initialize the project:
- Select the Apollo GraphQL Server Template:
Select the following from the menu:
- Configure Environment Variables:
- Copy the
.env.example
file to.env
. - Update the
.env
file with your specific configuration if necessary.
- Copy the
- Start Docker Containers:
- Apply Migrations and Metadata:
- Ensure you have the Hasura CLI installed (installation guide).
- Apply migrations and metadata:
- Import Sample Data:
- Use the Hasura console to import sample data:
- Navigate to
http://localhost:8080/console/data/sql
. - Paste the contents of
hasura-exports/sample-data.sql
and execute.
- Navigate to
- Use the Hasura console to import sample data:
- Access the Hasura Console:
- Open your browser and go to
http://localhost:8080
to access the Hasura console.
- Open your browser and go to
Sample Queries and Mutations
Explore some of the available GraphQL operations:
Fetch All Books
Add a New Book with Author
Delete a Book by ID
Fetch Author by ID
Explore More
Visit the GraphQL API Explorer at http://localhost:8080/console/api-explorer
to try out additional queries and mutations.
Note: For more examples, refer to the docs
Visit codebase here