An experiment with GraphQL and maps.
Currently its only function is to demonstrate how GraphQL may ease frontend development.
docker-compose up --build
Open http://localhost:1234 in two different browsers and wait for the backend to initialize itself. Then click away on the map and the created markers.
Clicking, dragging or deleting new points on the map within either browser window causes both views to get updated.
Some assumed benefits:
- The UI stays synchronized with the state of the backend.
- The React component responsible for showing the points has little extra fluff.
- Server-side state caching in the frontend is handled by the GraphQL client library.
- Only state changes relevant for each subscription is sent from the server to each client.
- No polling code is needed in the frontend due to GraphQL subscriptions.
To play with the GraphQL API or to modify the backend, it is easiest to use the Hasura admin UI ("console").
To play around, in 2 minutes:
- Set
HASURA_GRAPHQL_ENABLE_CONSOLE
to"true"
indocker-compose.yml
. - Open http://localhost:8080 to access the console.
The default admin secret is also in
docker-compose.yml
. The initial view opens up with a beefed-up GraphiQL.
To contribute, in 10 minutes:
- Leave
HASURA_GRAPHQL_ENABLE_CONSOLE
as"false"
indocker-compose.yml
. - Install Hasura CLI.
- Create
.env
with at leastHASURA_GRAPHQL_ADMIN_SECRET
. This will be utilized indocker-compose.yml
. - Groan... to have
hasura/config.yml
inhasura/
and to still use.env
with Hasura CLI:ln -s "$(pwd)/.env" hasura/.env
cd hasura/
- Run
hasura console
to start the console. - Run
hasura migrate ...
to read or write DB migration files. - Run
hasura metadata ...
to read or write Hasura configuration.
To iterate on the frontend faster, run docker-compose up -d hasura
in project root and yarn start
in frontend
directory.
To update generate updated graphql schema for relay:
yarn schema:update
(needs to be updated every time our api's schema changes)
To keep relay running for watching graphql query changes:
yarn relay --watch