/
main.go
41 lines (30 loc) · 854 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
"log"
"net/http"
"github.com/spf13/viper"
"github.com/aquiseb/lychee/core"
"github.com/aquiseb/lychee/micro-user/db"
resolvers "github.com/aquiseb/lychee/micro-user/resolvers"
"github.com/aquiseb/lychee/micro-user/schema"
)
// https://github.com/graph-gophers/graphql-go/issues/106#issuecomment-350231819
// RootResolver is extended with each "microservice" resolver
func main() {
port := viper.GetString("port")
c, _ := core.GetMongoClient()
core.Seed(c) // seed demo data
schem := schema.GetSchema()
database := &db.Services{c}
r := &resolvers.Query{
DB: database,
}
http.Handle("/graphql", core.Graphql(schem, r))
http.Handle("/", core.Playground())
fmt.Println("Starting server on http://localhost:" + port)
log.Fatal(http.ListenAndServe(":"+port, nil))
}
func init() {
core.InitViper()
}