refactor: push commands in to cmd and ev to root as library
This commit is contained in:
30
cmd/ev/svc.gql.go
Normal file
30
cmd/ev/svc.gql.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/sour-is/ev/app/gql"
|
||||
"github.com/sour-is/ev/internal/lg"
|
||||
"github.com/sour-is/ev/pkg/gql/resolver"
|
||||
"github.com/sour-is/ev/pkg/mux"
|
||||
"github.com/sour-is/ev/pkg/service"
|
||||
"github.com/sour-is/ev/pkg/slice"
|
||||
)
|
||||
|
||||
var _ = apps.Register(90, func(ctx context.Context, svc *service.Harness) error {
|
||||
ctx, span := lg.Span(ctx)
|
||||
defer span.End()
|
||||
|
||||
span.AddEvent("Enable GraphQL")
|
||||
gql, err := resolver.New(ctx, &gql.Resolver{}, slice.FilterType[resolver.IsResolver](svc.Services...)...)
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
return err
|
||||
}
|
||||
svc.Add(gql, mux.RegisterHTTP(func(mux *http.ServeMux) {
|
||||
mux.Handle("/", http.RedirectHandler("/playground", http.StatusTemporaryRedirect))
|
||||
}))
|
||||
|
||||
return nil
|
||||
})
|
||||
Reference in New Issue
Block a user