Backend

Backend

Installation

Docker
Without Docker

Run the following command to install everything through docker.

The installation takes a bit longer on the first pass or on rebuild ...

$ docker-compose up
# rebuild the containers for a cleanup
$ docker-compose up --build

Open another terminal and create unique indices with:

$ docker-compose exec neo4j migrate

For the local installation you need a recent version of node (>= v10.12.0) and Neo4J along with Apoc plugin installed on your system.

Download Neo4j Community Edition and unpack the files.

Download Neo4j Apoc and drop the file into the plugins folder of the just extracted Neo4j-Server Note that grand-stack-starter does not currently bundle a distribution of Neo4j. You can download Neo4j Desktop and run locally for development, spin up a hosted Neo4j Sandbox instance, run Neo4j in one of the many cloud options, spin up Neo4j in a Docker container or on Debian-based systems install Neo4j from the Debian Repository. Just be sure to update the Neo4j connection string and credentials accordingly in .env. Start Neo4J and confirm the database is running at http://localhost:7474.

Now install node dependencies with yarn:

$ cd backend
$ yarn install

Copy Environment Variables:

# in backend/
$ cp .env.template .env

Configure the new files according to your needs and your local setup.

Create unique indices with:

$ ./neo4j/migrate.sh

Start the backend for development with:

$ yarn run dev

or start the backend in production environment with:

yarn run start

Your backend is up and running at http://localhost:4000/ This will start the GraphQL service (by default on localhost:4000) where you can issue GraphQL requests or access GraphQL Playground in the browser.

GraphQL Playground

You can access Neo4J through http://localhost:7474/ for an interactive cypher shell and a visualization of the graph.

Seed Database

If you want your backend to return anything else than an empty response, you need to seed your database:

Docker
Without Docker

In another terminal run:

$ docker-compose exec backend yarn run db:seed

To reset the database run:

$ docker-compose exec backend yarn run db:reset
# you could also wipe out your neo4j database and delete all volumes with:
$ docker-compose down -v

Run:

$ yarn run db:seed

To reset the database run:

$ yarn run db:reset

Testing

Beware: We have no multiple database setup at the moment. We clean the database after each test, running the tests will wipe out all your data!

Docker
Without Docker

Run the jest tests:

$ docker-compose exec backend yarn run test:jest

Run the cucumber features:

$ docker-compose exec backend yarn run test:cucumber

Run the jest tests:

$ yarn run test:jest

Run the cucumber features:

$ yarn run test:cucumber