You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
781 B
30 lines
781 B
package graph
|
|
|
|
import (
|
|
"git.aiterp.net/stufflog/server/graph/graphcore"
|
|
"git.aiterp.net/stufflog/server/graph/resolvers"
|
|
"git.aiterp.net/stufflog/server/services"
|
|
"github.com/99designs/gqlgen/graphql"
|
|
"github.com/99designs/gqlgen/graphql/handler"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
//go:generate go run github.com/99designs/gqlgen --verbose --config gqlgen.yml
|
|
|
|
// New creates a new GraphQL schema.
|
|
func New(s services.Bundle) graphql.ExecutableSchema {
|
|
return graphcore.NewExecutableSchema(graphcore.Config{
|
|
Resolvers: &resolvers.Resolver{S: s},
|
|
})
|
|
}
|
|
|
|
func Gin(s services.Bundle) gin.HandlerFunc {
|
|
schema := New(s)
|
|
gqlHandler := handler.NewDefaultServer(schema)
|
|
|
|
return func(c *gin.Context) {
|
|
s.Auth.CheckGinSession(c)
|
|
|
|
gqlHandler.ServeHTTP(c.Writer, c.Request)
|
|
}
|
|
}
|