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 resolver | |
// This file will not be regenerated automatically. | |
// | |
// It serves as dependency injection for your app, add any dependencies you require here. | |
import ( | |
"golang-clean-architecture-ent-gqlgen/ent" | |
"golang-clean-architecture-ent-gqlgen/graph/generated" | |
"golang-clean-architecture-ent-gqlgen/pkg/adapter/controller" |
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 datastore | |
import ( | |
"golang-clean-architecture-ent-gqlgen/config" | |
"golang-clean-architecture-ent-gqlgen/ent" | |
"entgo.io/ent/dialect" | |
"github.com/go-sql-driver/mysql" | |
) |
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
func (r *queryResolver) User(ctx context.Context, id *int) (*ent.User, error) { | |
u, err := r.controller.User.Get(ctx, id) | |
if err != nil { | |
return nil, err | |
} | |
return u, nil | |
} |
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
// Resolver is a context struct | |
type Resolver struct { | |
client *ent.Client | |
controller controller.Controller | |
} | |
// NewSchema creates NewExecutableSchema | |
func NewSchema(client *ent.Client, controller controller.Controller) graphql.ExecutableSchema { | |
return generated.NewExecutableSchema(generated.Config{ | |
Resolvers: &Resolver{ |
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 registry | |
import ( | |
"golang-clean-architecture-ent-gqlgen/pkg/adapter/controller" | |
"golang-clean-architecture-ent-gqlgen/pkg/adapter/repository" | |
"golang-clean-architecture-ent-gqlgen/pkg/usecase/usecase" | |
) | |
func (r *registry) NewUserController() controller.User { | |
repo := repository.NewUserRepository(r.client) |
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 registry | |
import ( | |
"golang-clean-architecture-ent-gqlgen/ent" | |
"golang-clean-architecture-ent-gqlgen/pkg/adapter/controller" | |
) | |
type registry struct { | |
client *ent.Client | |
} |
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
# Where should the resolver implementations go? | |
resolver: | |
layout: follow-schema | |
dir: pkg/adapter/resolver | |
package: resolver |
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 repository | |
import ( | |
"context" | |
"golang-clean-architecture-ent-gqlgen/ent" | |
"golang-clean-architecture-ent-gqlgen/ent/user" | |
"golang-clean-architecture-ent-gqlgen/pkg/entity/model" | |
usecaseRepository "golang-clean-architecture-ent-gqlgen/pkg/usecase/repository" | |
) |
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 controller | |
import ( | |
"context" | |
"golang-clean-architecture-ent-gqlgen/pkg/entity/model" | |
"golang-clean-architecture-ent-gqlgen/pkg/usecase/usecase" | |
) | |
type user struct { | |
userUsecase usecase.User |
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 controller | |
// Controller holds the controllers for the entire across application | |
type Controller struct { | |
User interface{ User } | |
} |