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
type User interface { | |
Get(ctx context.Context, id *model.ID) (*model.User, error) | |
} | |
... | |
func (u *user) Get(ctx context.Context, id *model.ID) (*model.User, error) { | |
return u.userUsecase.Get(ctx, id) | |
} |
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 *ulid.ID) (*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
models: | |
ID: | |
model: | |
- golang-clean-architecture-ent-gqlgen/pkg/entity/model.ID |
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 model | |
import ( | |
"golang-clean-architecture-ent-gqlgen/ent/schema/ulid" | |
) | |
// ID implements a ULID | |
type ID = ulid.ID |
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 (Todo) Fields() []ent.Field { | |
return []ent.Field{ | |
field.String("id"). | |
GoType(ulid.ID("")). | |
DefaultFunc(func() ulid.ID { | |
return ulid.MustNew("") | |
}), | |
field.String("user_id"). | |
GoType(ulid.ID("")). | |
Optional(), |
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 (User) Fields() []ent.Field { | |
return []ent.Field{ | |
field.String("id"). | |
GoType(ulid.ID("")). | |
DefaultFunc(func() ulid.ID { | |
return ulid.MustNew("") | |
}), | |
field.String("name"). | |
NotEmpty(). | |
MaxLen(255), |
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 ulid | |
import ( | |
"crypto/rand" | |
"database/sql/driver" | |
"fmt" | |
"io" | |
"strconv" | |
"time" |
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" |
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 router | |
import ( | |
"net/http" | |
"github.com/99designs/gqlgen/graphql/handler" | |
"github.com/99designs/gqlgen/graphql/playground" | |
"github.com/labstack/echo/v4" | |
"github.com/labstack/echo/v4/middleware" | |
) |
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 graphql | |
import ( | |
"golang-clean-architecture-ent-gqlgen/ent" | |
"golang-clean-architecture-ent-gqlgen/pkg/adapter/controller" | |
"golang-clean-architecture-ent-gqlgen/pkg/adapter/resolver" | |
"entgo.io/contrib/entgql" | |
"github.com/99designs/gqlgen/graphql/handler" |