Intégration d'un point d'entrée GraphQL et d'un connecteur pour

PostgreSQL

- Possibilité de migrer le schéma de la base de données via drapeau
- Génération du code GraphQL avec https://gqlgen.com/
This commit is contained in:
2020-07-13 09:20:14 +02:00
parent 1120474ad9
commit 591112a800
28 changed files with 984 additions and 15 deletions

View File

@ -2,7 +2,11 @@ package route
import (
"forge.cadoles.com/Cadoles/daddy/internal/config"
"forge.cadoles.com/Cadoles/daddy/internal/graph"
"forge.cadoles.com/Cadoles/daddy/internal/graph/generated"
oidc "forge.cadoles.com/wpetit/goweb-oidc"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/playground"
"github.com/go-chi/chi"
"gitlab.com/wpetit/goweb/static"
@ -18,6 +22,17 @@ func Mount(r *chi.Mux, config *config.Config) error {
r.Route("/api", func(r chi.Router) {
r.Use(oidc.Middleware)
gql := handler.NewDefaultServer(
generated.NewExecutableSchema(generated.Config{
Resolvers: &graph.Resolver{},
}),
)
if config.Debug {
r.Get("/v1/graphql", playground.Handler("GraphQL playground", "/api/v1/graphql"))
}
r.Post("/v1/graphql", gql.ServeHTTP)
})
notFoundHandler := r.NotFoundHandler()