stufflog graphql server
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

  1. package graph
  2. import (
  3. "git.aiterp.net/stufflog/server/graph/graphcore"
  4. "git.aiterp.net/stufflog/server/graph/resolvers"
  5. "git.aiterp.net/stufflog/server/services"
  6. "github.com/99designs/gqlgen/graphql"
  7. "github.com/99designs/gqlgen/graphql/handler"
  8. "github.com/gin-gonic/gin"
  9. )
  10. //go:generate go run github.com/99designs/gqlgen --verbose --config gqlgen.yml
  11. // New creates a new GraphQL schema.
  12. func New(s services.Bundle) graphql.ExecutableSchema {
  13. return graphcore.NewExecutableSchema(graphcore.Config{
  14. Resolvers: &resolvers.Resolver{S: s},
  15. })
  16. }
  17. func Gin(s services.Bundle) gin.HandlerFunc {
  18. schema := New(s)
  19. gqlHandler := handler.NewDefaultServer(schema)
  20. return func(c *gin.Context) {
  21. s.Auth.CheckGinSession(c)
  22. gqlHandler.ServeHTTP(c.Writer, c.Request)
  23. }
  24. }