-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
38 lines (31 loc) · 1.06 KB
/
server.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
package main
import (
"log"
"net/http"
_ "net/http/pprof"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/playground"
"github.com/a-agmon/gql-parquet-api/graph"
"github.com/a-agmon/gql-parquet-api/pkg/aws"
"github.com/a-agmon/gql-parquet-api/pkg/data"
)
const defaultPort = "8999"
func main() {
log.Printf("starting profiling endpoint on port 6060")
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
log.Print("starting server...")
awsCred, err := aws.GetAWSCredEnv()
if err != nil {
log.Fatalf("error getting aws credentials from env: %v", err)
}
dataDriver := data.NewDuckDBDriver(awsCred)
dataStore := data.NewStore(dataDriver)
resolver := graph.NewResolver(dataStore)
srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: resolver}))
http.Handle("/", playground.Handler("GraphQL playground", "/query"))
http.Handle("/query", srv)
log.Printf("connect to http://localhost:%s/ for GraphQL playground", defaultPort)
log.Fatal(http.ListenAndServe(":"+defaultPort, nil))
}