Skip to content

Commit

Permalink
refactor(api-gql): use service for greetings (#789)
Browse files Browse the repository at this point in the history
* refactor(api-gql): use service for greetings

* fix applyPatch

* change to uuid on frontend

* fix mapper and resolver uuid
  • Loading branch information
Satont authored Dec 19, 2024
1 parent 24ac0ab commit a04ca86
Show file tree
Hide file tree
Showing 13 changed files with 541 additions and 148 deletions.
9 changes: 9 additions & 0 deletions apps/api-gql/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/twirapp/twir/apps/api-gql/internal/services/commands_responses"
"github.com/twirapp/twir/apps/api-gql/internal/services/commands_with_groups_and_responses"
"github.com/twirapp/twir/apps/api-gql/internal/services/dashboard-widget-events"
"github.com/twirapp/twir/apps/api-gql/internal/services/greetings"
"github.com/twirapp/twir/apps/api-gql/internal/services/keywords"
"github.com/twirapp/twir/apps/api-gql/internal/services/roles"
"github.com/twirapp/twir/apps/api-gql/internal/services/timers"
Expand Down Expand Up @@ -84,6 +85,9 @@ import (

rolesrepository "github.com/twirapp/twir/libs/repositories/roles"
rolesrepositorypgx "github.com/twirapp/twir/libs/repositories/roles/pgx"

greetingsrepository "github.com/twirapp/twir/libs/repositories/greetings"
greetingsrepositorypgx "github.com/twirapp/twir/libs/repositories/greetings/pgx"
)

func main() {
Expand Down Expand Up @@ -116,6 +120,7 @@ func main() {
commands_responses.New,
commands.New,
roles.New,
greetings.New,
),
// repositories
fx.Provide(
Expand Down Expand Up @@ -175,6 +180,10 @@ func main() {
rolesrepositorypgx.NewFx,
fx.As(new(rolesrepository.Repository)),
),
fx.Annotate(
greetingsrepositorypgx.NewFx,
fx.As(new(greetingsrepository.Repository)),
),
),
// grpc clients
fx.Provide(
Expand Down
16 changes: 16 additions & 0 deletions apps/api-gql/internal/delivery/gql/mappers/greetings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package mappers

import (
"github.com/twirapp/twir/apps/api-gql/internal/delivery/gql/gqlmodel"
"github.com/twirapp/twir/apps/api-gql/internal/entity"
)

func GreetingEntityTo(e entity.Greeting) gqlmodel.Greeting {
return gqlmodel.Greeting{
ID: e.ID,
UserID: e.UserID,
Enabled: e.Enabled,
IsReply: e.IsReply,
Text: e.Text,
}
}

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

177 changes: 48 additions & 129 deletions apps/api-gql/internal/delivery/gql/resolvers/greetings.resolver.go

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

4 changes: 4 additions & 0 deletions apps/api-gql/internal/delivery/gql/resolvers/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/twirapp/twir/apps/api-gql/internal/services/commands_responses"
"github.com/twirapp/twir/apps/api-gql/internal/services/commands_with_groups_and_responses"
dashboard_widget_events "github.com/twirapp/twir/apps/api-gql/internal/services/dashboard-widget-events"
"github.com/twirapp/twir/apps/api-gql/internal/services/greetings"
"github.com/twirapp/twir/apps/api-gql/internal/services/keywords"
"github.com/twirapp/twir/apps/api-gql/internal/services/roles"
"github.com/twirapp/twir/apps/api-gql/internal/services/timers"
Expand Down Expand Up @@ -71,6 +72,7 @@ type Resolver struct {
commandsWithGroupsAndResponsesService *commands_with_groups_and_responses.Service
commandsResponsesService *commands_responses.Service
rolesService *roles.Service
greetingsService *greetings.Service
}

type Opts struct {
Expand Down Expand Up @@ -104,6 +106,7 @@ type Opts struct {
CommandsWithGroupsAndResponsesService *commands_with_groups_and_responses.Service
CommandsResponsesService *commands_responses.Service
RolesService *roles.Service
GreetingsService *greetings.Service
}

func New(opts Opts) (*Resolver, error) {
Expand Down Expand Up @@ -141,6 +144,7 @@ func New(opts Opts) (*Resolver, error) {
commandsWithGroupsAndResponsesService: opts.CommandsWithGroupsAndResponsesService,
commandsResponsesService: opts.CommandsResponsesService,
rolesService: opts.RolesService,
greetingsService: opts.GreetingsService,
}, nil
}

Expand Down
17 changes: 17 additions & 0 deletions apps/api-gql/internal/entity/greeting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package entity

import (
"github.com/google/uuid"
)

type Greeting struct {
ID uuid.UUID
ChannelID string
UserID string
Enabled bool
Text string
IsReply bool
Processed bool
}

var GreetingNil = Greeting{}
Loading

0 comments on commit a04ca86

Please sign in to comment.