authorizer/server/handlers/graphql.go
Lakhan Samani f88363e6dc
feat: login wall (#42)
* feat: add login-wall app

* fix: rename vars

* fix: rename vars

* update docker file

* add validations for app state

* add host check for app

* fix: docker file
2021-08-04 12:18:57 +05:30

24 lines
733 B
Go

package handlers
import (
"github.com/99designs/gqlgen/graphql/handler"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/graph"
"github.com/authorizerdev/authorizer/server/graph/generated"
"github.com/gin-gonic/gin"
)
// Defining the Graphql handler
func GraphqlHandler() gin.HandlerFunc {
// NewExecutableSchema and Config are in the generated.go file
// Resolver is in the resolver.go file
h := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}}))
return func(c *gin.Context) {
if constants.AUTHORIZER_URL == "" {
constants.AUTHORIZER_URL = "https://" + c.Request.Host
}
h.ServeHTTP(c.Writer, c.Request)
}
}