Created
December 10, 2021 04:47
-
-
Save manakuro/38c4477a8c3b06bd436bbb6ba58fb0e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"golang-clean-architecture-ent-gqlgen/config" | |
"golang-clean-architecture-ent-gqlgen/ent" | |
"golang-clean-architecture-ent-gqlgen/pkg/adapter/controller" | |
"golang-clean-architecture-ent-gqlgen/pkg/infrastructure/datastore" | |
"golang-clean-architecture-ent-gqlgen/pkg/infrastructure/graphql" | |
"golang-clean-architecture-ent-gqlgen/pkg/infrastructure/router" | |
"golang-clean-architecture-ent-gqlgen/pkg/registry" | |
"log" | |
) | |
func main() { | |
config.ReadConfig(config.ReadConfigOption{}) | |
client := newDBClient() | |
ctrl := newController(client) | |
srv := graphql.NewServer(client, ctrl) | |
e := router.New(srv) | |
e.Logger.Fatal(e.Start(":" + config.C.Server.Address)) | |
} | |
func newDBClient() *ent.Client { | |
client, err := datastore.NewClient() | |
if err != nil { | |
log.Fatalf("failed opening mysql client: %v", err) | |
} | |
return client | |
} | |
func newController(client *ent.Client) controller.Controller { | |
r := registry.New(client) | |
return r.NewController() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment