GithubHelp home page GithubHelp logo

intro-graphql-hasura's Introduction

Intro GraphQL & Hasura

This workshop provides a hands-on introduction to the fundamental concepts of GraphQL and the Hasura GraphQL Engine.

Setup

Requirements: Docker installed and available

Local setup in terminal

Check installation via the command line: docker --version should return something like Docker version 19.03.8, build af0cb9b

Check availability via the command line: docker ps should return something like 'CONTAINER ID IMAGE COMMAND CREATED ...'. If you see messages like 'Error response from daemon' or 'Cannot connect to the Docker daemon', try restarting your docker service.

Installation instructions can be found here: https://docs.docker.com/get-docker/

Recommended: PostgreSQL / psql installed and available

Check installation via the command line: psql --version should return something like psql (PostgreSQL) 12.2

Installation instructions can be found here: https://www.postgresql.org/download/

Getting started

You will work with local Docker containers for this tutorial; see the services "postgres" and "graphql-engine" in docker-compose.yaml

To begin, use docker-compose up -d

View your new Hasura GraphQL Engine Console at http://localhost:8080 (admin secret from docker-compose.yaml: adminsecret)

Note To end a session, use docker-compose down

In case there is difficulty with Docker locally, use a free Heroku deployment instead:

Deploy to Heroku

Loading initial data

For local Docker setup

Use the following command to set up initial tables and data into your postgres container:

psql postgres://postgres:mypassword@localhost:6432/postgres < chinook.sql

If you do not have psql available, you can copy the chinook.sql file to the postgres container and execute the psql command via inside it:

docker cp chinook.sql <postgres-container-ID>:/
docker exec -ti <postgres-container-ID> /bin/bash
psql -U postgres < chinook.sql

Note You can find <postgres-container-ID> with docker ps

For a Heroku deployment

From the Heroku app dashboard (dashboard.heroku.com/apps/<my-app-name>), navigate to the Settings tab -> Reveal config vars -> DATABASE_URL. Use the following command:

psql <DATABASE_URL> < chinook.sql

or, lacking psql, use the following (might need to run heroku login first):

heroku pg:psql -a <my-app-name> < chinook.sql

Track tables and foreign-key relations

Track tables in console

Return to the Hasura GraphQL Engine console and select the Data tab. In the central view, there should be a section "Untracked tables or views" with several tables listed and a "Track All" option available. Select "Track All", and then "Track All" again for untracked foreign-key relations.

Now you're all set! You should see your tables listed in the left-hand panel.

Go to the Graphiql tab and start trying out queries, mutations, and subscriptions.

Remote schema endpoint

An additional Hasura GraphQL Engine instance has already been set up as a Heroku app for practice with remote schemas:

https://op-workshop-remote-schema-6923.herokuapp.com/v1/graphql

x-hasura-admin-secret: super-secret-password

It contains the following tables:

  • playlist
  • playlist_aggregate
  • playlist_by_pk
  • playlist_track
  • playlist_track_aggregate
  • playlist_track_by_pk

intro-graphql-hasura's People

Contributors

allpwrfulroot avatar coco98 avatar tirumaraiselvan avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.