How to Install Hasura on macOS

Hasura is an open-source engine that provides instant GraphQL APIs to your existing databases, making it a popular choice for developers. Here is a step-by-step guide on installing Hasura on macOS.

Prerequisites:

Before installing Hasura, you must have the following prerequisites installed on your macOS:

Install Hasura

Now that you have met all the prerequisites, let's proceed with installing Hasura.

  1. Start the Docker daemon.

    Ensure that the Docker daemon is running on your macOS by clicking the Docker icon in the menu bar and selecting "Open Docker Desktop."

  2. Create a new directory for Hasura.

    Create a new directory with a name of your choice for your Hasura project. For example:

    mkdir my-hasura-project
    cd my-hasura-project
    
  3. Create a Docker Compose file.

    Create a new file named docker-compose.yaml in the directory you created in the previous step:

    version: '3.6'
    
    services:
      postgres:
        image: postgres
        restart: always
        environment:
          POSTGRES_PASSWORD: postgres
    
      graphql-engine:
        image: hasura/graphql-engine:v2.0.12
        ports:
          - 8080:8080
        depends_on:
          - postgres
        environment:
          HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
          HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
    

    This docker-compose.yaml file defines two services: postgres and graphql-engine. The postgres service provides a PostgreSQL database that Hasura will use, and the graphql-engine service provides the Hasura GraphQL engine.

    Note that the HASURA_GRAPHQL_DATABASE_URL environment variable in the graphql-engine service is set to connect to the postgres service's database.

  4. Start the Hasura stack.

    Run the following command in the terminal to start the Hasura stack:

    docker-compose up -d
    

    This command will start the PostgreSQL database and the Hasura GraphQL engine inside Docker.

  5. Open Hasura console.

    After Hasura starts, you can access the Hasura console to create and manage your GraphQL API.

    Open a web browser and go to http://localhost:8080/console - this should open the Hasura console.

    You will be prompted to log in with a Hasura administrator account. You can create an account by clicking on the "Create an account" button on the login page.

    Once you log in, you can start creating your GraphQL API by adding tables and permissions to the Hasura engine.

  6. Stop the Hasura stack.

    To stop the Hasura stack, run the following command:

    docker-compose down
    

    This command will stop the PostgreSQL database and the Hasura GraphQL engine.

Congratulations! You have successfully installed and set up a Hasura server on your macOS.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!