api: instroduce /add_schema
diff --git a/controller/controller b/controller/controller
deleted file mode 100755
index f2995db..0000000
--- a/controller/controller
+++ /dev/null
Binary files differ
diff --git a/controller/main.go b/controller/main.go
index 2bba060..9c3cd4b 100644
--- a/controller/main.go
+++ b/controller/main.go
@@ -58,7 +58,7 @@
 	}
 }
 
-func (a *ApiHandler) graphqlHandler(w http.ResponseWriter, r *http.Request) {
+func (a *ApiHandler) graphql(w http.ResponseWriter, r *http.Request) {
 	glog.Infof("New GraphQL query received: %s", r.Method)
 	q, err := extractQuery(r)
 	if err != nil {
@@ -75,6 +75,23 @@
 	w.Header().Set("Content-Type", "application/json")
 }
 
+func (a *ApiHandler) addSchema(w http.ResponseWriter, r *http.Request) {
+	if r.Method != "POST" {
+		http.Error(w, "Only POST requests are accepted in /add_schema", http.StatusBadRequest)
+		return
+	}
+	body, err := ioutil.ReadAll(r.Body)
+	if err != nil {
+		http.Error(w, "Could not read request", http.StatusInternalServerError)
+		return
+	}
+	err = a.gql.AddSchema(string(body))
+	if err != nil {
+		http.Error(w, err.Error(), http.StatusPreconditionFailed)
+		return
+	}
+}
+
 func main() {
 	flag.Parse()
 
@@ -116,6 +133,7 @@
 		panic(err)
 	}
 	api := ApiHandler{gqlClient}
-	http.HandleFunc("/graphql", api.graphqlHandler)
+	http.HandleFunc("/graphql", api.graphql)
+	http.HandleFunc("/add_schema", api.addSchema)
 	log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
 }
diff --git a/controller/schema/dgraph_schema_store.go b/controller/schema/dgraph_schema_store.go
index 1680af0..f958af6 100644
--- a/controller/schema/dgraph_schema_store.go
+++ b/controller/schema/dgraph_schema_store.go
@@ -175,6 +175,9 @@
 		if shouldIgnoreDefinition(t) {
 			continue
 		}
+		if _, ok := parsed.Types[t.Name+"Event"]; ok {
+			continue
+		}
 		_, err := fmt.Fprintf(&extended, eventTmpl, t.Name, t.Name, t.Name, t.Name)
 		if err != nil {
 			return "", err