diff --git a/pkg/graphql/handler.go b/pkg/graphql/handler.go index 4d714a5..9ffa9dd 100644 --- a/pkg/graphql/handler.go +++ b/pkg/graphql/handler.go @@ -5,8 +5,15 @@ import ( "github.com/99designs/gqlgen/graphql/handler" thunderGraphql "github.com/gothunder/thunder/internal/graphql" + "github.com/gothunder/thunder/pkg/router" ) func CreateHandler(graphQLSchema graphql.ExecutableSchema) *handler.Server { return thunderGraphql.CreateHandler(graphQLSchema) } + +func newGraphqlHandler(graphQLSchema graphql.ExecutableSchema) router.HandlerOutput { + return router.HandlerOutput{ + Handler: thunderGraphql.NewGraphqlHandler(graphQLSchema), + } +} diff --git a/pkg/graphql/module.go b/pkg/graphql/module.go index 888ff31..8934932 100644 --- a/pkg/graphql/module.go +++ b/pkg/graphql/module.go @@ -1,12 +1,11 @@ package graphql import ( - "github.com/gothunder/thunder/internal/graphql" "go.uber.org/fx" ) var Module = fx.Options( fx.Provide( - graphql.NewGraphqlHandler, + newGraphqlHandler, ), ) diff --git a/pkg/router/chi/module.go b/pkg/router/chi/module.go index 692b105..f7bd416 100644 --- a/pkg/router/chi/module.go +++ b/pkg/router/chi/module.go @@ -18,7 +18,7 @@ var Module = fx.Options( ), ) -func startListener(lc fx.Lifecycle, s fx.Shutdowner, logger *zerolog.Logger, params router.Params, r *chi.Mux) { +func StartListener(lc fx.Lifecycle, s fx.Shutdowner, logger *zerolog.Logger, params router.Params, r *chi.Mux) { server, listener, err := thunderChi.CreateServer(params.Handlers, logger, r) if err != nil { logger.Error().Err(err).Msg("failed to create server") @@ -62,7 +62,3 @@ func startListener(lc fx.Lifecycle, s fx.Shutdowner, logger *zerolog.Logger, par }, ) } - -var StartServer = fx.Invoke( - startListener, -)