forked from kataras/iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
27 lines (20 loc) · 731 Bytes
/
server.go
File metadata and controls
27 lines (20 loc) · 731 Bytes
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
package main
import (
"os"
"github.com/iris-contrib/outerbanks-api/graph"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/playground"
"github.com/kataras/iris/v12"
)
func main() {
app := iris.New()
graphServer := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}))
playgroundHandler := playground.Handler("GraphQL playground", "/query")
app.Get("/", iris.FromStd(playgroundHandler)) // We use iris.FromStd to convert a standard http.Handler to an iris.Handler.
app.Any("/query", iris.FromStd(graphServer.ServeHTTP)) // GET, POST, PUT...
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
app.Listen(":" + port)
}