dsa-events

command module
v0.0.0-...-62b7090 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2018 License: MIT Imports: 15 Imported by: 0

README

A Boilerplate DGraph API

GoDoc GitHub version Build Status

Dgraph is a powerful graph database written in Go. The query language for DGraph is based off of GraphQL, called GraphQL+-.

This API is a nice way to interface with Dgraph data, and has the 3 following endpoints:

  • /query
  • /mutate
  • /alter

To understand what mutations and alterations are, you can take a look over here to understand the fundamentals of graph database interactions.


Getting Started

Install Dgraph

Your first step is to install dgraph. You can download and install from DGraph's main site over here.

One important note is that this API uses docker as middleware, so please follow the 'From Docker Image' instructions in the link I posted previously. If you don't have docker installed on your machine, you can find the installation instructions from them over here.

Start DGraph

Run the following command to get your dgraph instance running locally via the included docker compose file:

docker-compose up -d

This will start Dgraph Server, Zero (Dgraph Instance Manager) and Ratel (Dgraph Console UI).

DEPRECATED (Dgraph prior to dgraphzero implementation)

Run DGraph instance with ports mapped:

docker run --rm -it -p 8080:8080 -p 9080:9080 -v ~/dgraph:/dgraph --name dgraph dgraph/dgraph dgraph --bindall=true --memory_mb 2048


Install Go dependencies

While you're at the root of the project, run:

go get ./...

This will install the required dependencies of the whole project

Build project

Run:

make build

Run project

Run:

make run


GraphQL+- Samples

GraphQL+- Sample Query
POST - http://localhost:5000/query
Purpose:

This query will get an Event with all the available parameters. It will get an Event with 'uid' of 0x3.

Body:
{
	Event(func: uid(0x3)) {
		uid
	    name
	    description
	    location
	    time
	    working_group {
	      name
	      description
	    }
	    chapter {
	      name
	      location
	      contact {
	        name
	        email
	        facebook
	        twitter
	      }
	    }
	}
}
GraphQL+- Sample Mutation
POST - http://localhost:5000/mutate
Purpose:

This is a sample mutation that will create a new Event with the parameters given.

Body:
{
	"name":"Name of event",
	"description":"Event's description.",
	"location": {
		"type": "Point", 
		"coordinates": [17.8803304,-245.6662756]
	},
	"time":"2018-05-01T15:30:00Z",
	"working_group": {
		"name": "Chapter working group",
		"description": "Chapter working group "
	},
	"chapter": {
		"name": "Hosting chapter",
		"location": {
			"type": "Point", 
			"coordinates": [41.8803304,-87.6662756]
		},
		"contact": {
			"name":"John Doe",
			"email":"doe@hotmail.com",
			"facebook":"John Doe",
			"twitter":"@johndoe"
		}
	}
}

Built using:

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL