Skip to content

Commit

Permalink
chore: Restructure code into domain package
Browse files Browse the repository at this point in the history
  • Loading branch information
hlubek committed Oct 22, 2024
1 parent b26f59a commit 8537b95
Show file tree
Hide file tree
Showing 75 changed files with 605 additions and 505 deletions.
4 changes: 2 additions & 2 deletions backend/api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"

"myvendor.mytld/myproject/backend/api/graph/model"
"myvendor.mytld/myproject/backend/domain"
"myvendor.mytld/myproject/backend/domain/types"
)

var ErrAuthTokenInvalid = TypedError{"authTokenInvalid", "auth token invalid"}
Expand Down Expand Up @@ -43,7 +43,7 @@ func ResultFromErr(err error) (*model.Result, error) {
}

func FieldsErrorFromErr(err error) *model.FieldsError {
var fieldErr domain.FieldResolvableError
var fieldErr types.FieldResolvableError
if errors.As(err, &fieldErr) {
return &model.FieldsError{
Errors: []*model.FieldError{
Expand Down
35 changes: 18 additions & 17 deletions backend/api/graph/admin.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions backend/api/graph/authentication.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 20 additions & 19 deletions backend/api/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions backend/api/graph/helper/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"

"myvendor.mytld/myproject/backend/api/graph/model"
"myvendor.mytld/myproject/backend/domain"
model2 "myvendor.mytld/myproject/backend/domain/model"
"myvendor.mytld/myproject/backend/domain/query"
)

func MapToAccount(record domain.Account) *model.Account {
func MapToAccount(record model2.Account) *model.Account {
return &model.Account{
ID: record.ID,
EmailAddress: record.EmailAddress,
Expand All @@ -19,28 +20,28 @@ func MapToAccount(record domain.Account) *model.Account {
}
}

func MapToAccounts(records []domain.Account) []*model.Account {
func MapToAccounts(records []model2.Account) []*model.Account {
result := make([]*model.Account, len(records))
for i, record := range records {
result[i] = MapToAccount(record)
}
return result
}

func MapFromAccountFilter(filter *model.AccountFilter) domain.AccountsQuery {
func MapFromAccountFilter(filter *model.AccountFilter) query.AccountsQuery {
if filter == nil {
return domain.AccountsQuery{}
return query.AccountsQuery{}
}
return domain.AccountsQuery{
return query.AccountsQuery{
IDs: filter.Ids,
SearchTerm: ToVal(filter.Q),
OrganisationID: filter.OrganisationID,
}
}

func AccountQueryOptsFromSelection(ctx context.Context, accountSelectPath ...string) domain.AccountQueryOpts {
func AccountQueryOptsFromSelection(ctx context.Context, accountSelectPath ...string) *query.AccountQueryOpts {
selectedFields := SelectedFields(ctx)
return domain.AccountQueryOpts{
return &query.AccountQueryOpts{
IncludeOrganisation: selectedFields.PathSelected(append(accountSelectPath, "organisation")...),
OrganisationQueryOpts: OrganisationQueryOptsFromSelection(ctx, append(accountSelectPath, "organisation")...),
}
Expand Down
Loading

0 comments on commit 8537b95

Please sign in to comment.