Skip to content
/ dgraph-dev Public template

A Ready-To-Use Dgraph Local Development Environment

License

Notifications You must be signed in to change notification settings

pshaddel/dgraph-dev

Repository files navigation

dgraph-dev

A ready to use local development environment for Dgraph project

Summary of Important features

  • Schema Hot Reload
  • Lambda Script Hot Reload
  • Multi-Schema Support
  • All Logs are shown together
  • Ready-To-Use Pipeline that contains[install, lint, test, schema validation]

Schema Hot Reload

Lambda Script Hot Reload

Multi-Schema Support

For using this feature put schema.graphql in gitignore and start creating files with .graphql in src folder. Then if you run npm run start:dev with each change in one of these files it starts merging them into one file: schema.graphql. This file should exists in working directory.

Prerequisites

  • Nodejs: You can install the latest version here
  • npm:
  • docker: Install docker engine from here.

Quick Start

First install the packages:

npm install

and then all you need to do is to run this command in project folder:

npm run start:dev

Explaining Command: npm run start:dev

It is nodejs script that does these things:

  • In case this is the first time you are running it, it creates a empty bundle.js file so Lambda container does not fail.
  • It runs docker compose up and one alpha, one zero, one lambda is going to start running detached.
  • Deploy Schema(schema.graphql)
  • Bundle Typescript files in src folder
  • Watch changes of schema.graphql to Redeploy Schema with each change.
  • Watch changes in *.graphql files in src folder in merge these files and overwrites schema.graphql
  • Watch changes in src folder and run webpack to create Javascript Bundle.
  • Show you logs of all Docker Containers.

Typescript Setup for Lambda Script

  • Dgraph Lambda Version: Dgraph@v22
  • Javascript Bundle file is created in dist/bundle.js and mounted to the docker container I have used for this project and this version needs external lambda container.
  • Prettier as Formatter: prettier
  • ESLint as Linter : eslint
  • Bundling with Webpack 5: webpack 5.

Services and Default Ports

  • Ratel:9000 use localhost:9000 for accessing ratel and executing dql commands.
  • Alpha:8080,9080,8000 these ports are mapped to alpha container
  • Zero:5080,6080 these ports are mapped to zero container
  • Lambda:8686 these ports are mapped to lambda container

You can send graphql requests to this address: http://localhost:8080/graphql

On Ratel set Dgraph server URL to: http://localhost:8080

Examples with Tests

  • How to use Authentication
  • How to use Lambda Scripts

Contribution

Feel free to open issues and pull requests.

About

A Ready-To-Use Dgraph Local Development Environment

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published