Skip to content

Commit 43e5f11

Browse files
committed
chore(api-gql): change gql schema directory
1 parent ebaec0c commit 43e5f11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+651
-73
lines changed

.graphqlrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
schema: './apps/api-gql/schema/*.graphqls'
1+
schema: './apps/api-gql/internal/delivery/gql/schema/*.graphqls'

apps/api-gql/cmd/main.go

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_users"
3939
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_with_roles_users"
4040
"github.com/twirapp/twir/apps/api-gql/internal/services/song_requests"
41+
"github.com/twirapp/twir/apps/api-gql/internal/services/streamelements"
4142
"github.com/twirapp/twir/apps/api-gql/internal/services/timers"
4243
"github.com/twirapp/twir/apps/api-gql/internal/services/twir-users"
4344
"github.com/twirapp/twir/apps/api-gql/internal/services/twitch"
@@ -211,6 +212,7 @@ func main() {
211212
tts.New,
212213
song_requests.New,
213214
community_redemptions.New,
215+
streamelements.New,
214216
),
215217
// grpc clients
216218
fx.Provide(

apps/api-gql/gqlgen.yml apps/api-gql/internal/delivery/gql/gqlgen.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Where are all the schema files located? globs are supported eg src/**/*.graphqls
22
schema:
3-
- apps/api-gql/schema/*.graphqls
3+
- apps/api-gql/internal/delivery/gql/schema/*.graphqls
44

55
# Where should the generated server code go?
66
exec:

apps/api-gql/internal/delivery/gql/mappers/commands.go

+76
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package mappers
22

33
import (
4+
"github.com/google/uuid"
5+
"github.com/samber/lo"
46
model "github.com/satont/twir/libs/gomodels"
57
"github.com/twirapp/twir/apps/api-gql/internal/delivery/gql/gqlmodel"
68
"github.com/twirapp/twir/apps/api-gql/internal/entity"
9+
"github.com/twirapp/twir/apps/api-gql/internal/services/commands"
10+
"github.com/twirapp/twir/libs/integrations/streamelements"
711
)
812

913
var commandsExpiresAtMap = map[model.ChannelCommandExpiresType]gqlmodel.CommandExpiresType{
@@ -110,3 +114,75 @@ func CommandResponseTo(e entity.CommandResponse) gqlmodel.CommandResponse {
110114

111115
return m
112116
}
117+
118+
func CommandGqlInputToService(
119+
channelID, actorID string,
120+
input gqlmodel.CommandsCreateOpts,
121+
) commands.CreateInput {
122+
responses := make([]commands.CreateInputResponse, len(input.Responses))
123+
for idx, res := range input.Responses {
124+
responses[idx] = commands.CreateInputResponse{
125+
Text: &res.Text,
126+
Order: idx,
127+
TwitchCategoryIDs: res.TwitchCategoriesIds,
128+
}
129+
}
130+
131+
var groupId *uuid.UUID
132+
if input.GroupID.IsSet() && input.GroupID.Value() != nil {
133+
parsedGroupId, err := uuid.Parse(*input.GroupID.Value())
134+
if err == nil {
135+
groupId = &parsedGroupId
136+
}
137+
}
138+
139+
var expiresType *string
140+
if input.ExpiresType.IsSet() && input.ExpiresType.Value() != nil {
141+
expiresType = lo.ToPtr(input.ExpiresType.Value().String())
142+
}
143+
144+
return commands.CreateInput{
145+
ChannelID: channelID,
146+
ActorID: actorID,
147+
Name: input.Name,
148+
Cooldown: input.Cooldown,
149+
CooldownType: input.CooldownType,
150+
Enabled: input.Enabled,
151+
Aliases: input.Aliases,
152+
Description: input.Description,
153+
Visible: input.Visible,
154+
IsReply: input.IsReply,
155+
KeepResponsesOrder: input.KeepResponsesOrder,
156+
DeniedUsersIDS: input.DeniedUsersIds,
157+
AllowedUsersIDS: input.AllowedUsersIds,
158+
RolesIDS: input.RolesIds,
159+
OnlineOnly: input.OnlineOnly,
160+
CooldownRolesIDs: input.CooldownRolesIds,
161+
EnabledCategories: input.EnabledCategories,
162+
RequiredWatchTime: input.RequiredWatchTime,
163+
RequiredMessages: input.RequiredMessages,
164+
RequiredUsedChannelPoints: input.RequiredUsedChannelPoints,
165+
GroupID: groupId,
166+
ExpiresAt: input.ExpiresAt.Value(),
167+
ExpiresType: expiresType,
168+
Responses: responses,
169+
}
170+
}
171+
172+
func StreamElementsCommandToGql(m streamelements.Command) gqlmodel.StreamElementsCommand {
173+
return gqlmodel.StreamElementsCommand{
174+
ID: m.ID,
175+
Name: m.Name,
176+
Enabled: m.Enabled,
177+
Cooldown: m.Cooldown.Global,
178+
Aliases: m.Aliases,
179+
Response: m.Response,
180+
AccessLevel: m.AccessLevel,
181+
EnabledOnline: m.EnabledOnline,
182+
EnabledOffline: m.EnabledOffline,
183+
Hidden: m.Hidden,
184+
Type: m.Type,
185+
CreatedAt: m.CreatedAt,
186+
UpdatedAt: m.UpdatedAt,
187+
}
188+
}

apps/api-gql/internal/delivery/gql/mappers/timers.go

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package mappers
33
import (
44
"github.com/twirapp/twir/apps/api-gql/internal/delivery/gql/gqlmodel"
55
"github.com/twirapp/twir/apps/api-gql/internal/entity"
6+
"github.com/twirapp/twir/libs/integrations/streamelements"
67
)
78

89
func TimerEntityToGql(m entity.Timer) gqlmodel.Timer {
@@ -27,3 +28,15 @@ func TimerEntityToGql(m entity.Timer) gqlmodel.Timer {
2728
Responses: responses,
2829
}
2930
}
31+
32+
func StreamElementsTimerToGql(m streamelements.Timer) gqlmodel.StreamElementsTimer {
33+
return gqlmodel.StreamElementsTimer{
34+
ID: m.Id,
35+
Name: m.Name,
36+
Enabled: m.Enabled,
37+
ChatLines: m.ChatLines,
38+
Message: m.Message,
39+
CreatedAt: m.CreatedAt,
40+
UpdatedAt: m.UpdatedAt,
41+
}
42+
}

apps/api-gql/internal/delivery/gql/resolvers/commands.resolver.go

+29-52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/api-gql/internal/delivery/gql/resolvers/import.resolver.go

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/api-gql/internal/delivery/gql/resolvers/resolver.go

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_users"
3131
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_with_roles_users"
3232
"github.com/twirapp/twir/apps/api-gql/internal/services/song_requests"
33+
"github.com/twirapp/twir/apps/api-gql/internal/services/streamelements"
3334
"github.com/twirapp/twir/apps/api-gql/internal/services/timers"
3435
twir_users "github.com/twirapp/twir/apps/api-gql/internal/services/twir-users"
3536
twitchservice "github.com/twirapp/twir/apps/api-gql/internal/services/twitch"
@@ -91,6 +92,7 @@ type Deps struct {
9192
TTSService *tts.Service
9293
SongRequestsService *song_requests.Service
9394
CommunityRedemptionsService *community_redemptions.Service
95+
StreamElementsService *streamelements.Service
9496
Config config.Config
9597
}
9698

apps/api-gql/internal/delivery/gql/resolvers/timers.resolver.go

+42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/api-gql/schema/commands.graphqls apps/api-gql/internal/delivery/gql/schema/commands.graphqls

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extend type Mutation {
77
commandsCreate(opts: CommandsCreateOpts!): CommandCreatePayload! @isAuthenticated @hasAccessToSelectedDashboard @hasChannelRolesDashboardPermission(permission: MANAGE_COMMANDS)
88
commandsUpdate(id: UUID!, opts: CommandsUpdateOpts!): Boolean! @isAuthenticated @hasAccessToSelectedDashboard @hasChannelRolesDashboardPermission(permission: MANAGE_COMMANDS)
99
commandsRemove(id: UUID!): Boolean! @isAuthenticated @hasAccessToSelectedDashboard @hasChannelRolesDashboardPermission(permission: MANAGE_COMMANDS)
10+
commandsCreateMultiple(commands: [CommandsCreateOpts!]!): Boolean! @isAuthenticated @hasAccessToSelectedDashboard @hasChannelRolesDashboardPermission(permission: MANAGE_COMMANDS)
1011
}
1112

1213
type Command {

0 commit comments

Comments
 (0)