v0.0.11 Реализован функционал удаления поста и изображения из S3
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3fb0d5dacd
commit
5840927f5e
@ -101,6 +101,7 @@ type ComplexityRoot struct {
|
||||
ConfirmEmail func(childComplexity int, token string) int
|
||||
CreateComment func(childComplexity int, postID int, content string) int
|
||||
CreatePost func(childComplexity int, title string, content string) int
|
||||
DeletePost func(childComplexity int, id int) int
|
||||
LikePost func(childComplexity int, postID int) int
|
||||
Login func(childComplexity int, input domain.LoginInput) int
|
||||
MarkAsRead func(childComplexity int, messageID int) int
|
||||
@ -205,6 +206,7 @@ type MutationResolver interface {
|
||||
RequestEmailConfirmation(ctx context.Context) (bool, error)
|
||||
ConfirmEmail(ctx context.Context, token string) (bool, error)
|
||||
ResendEmailConfirmation(ctx context.Context) (bool, error)
|
||||
DeletePost(ctx context.Context, id int) (bool, error)
|
||||
}
|
||||
type PostResolver interface {
|
||||
Author(ctx context.Context, obj *domain.Post) (*domain.User, error)
|
||||
@ -476,6 +478,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.Mutation.CreatePost(childComplexity, args["title"].(string), args["content"].(string)), true
|
||||
|
||||
case "Mutation.deletePost":
|
||||
if e.complexity.Mutation.DeletePost == nil {
|
||||
break
|
||||
}
|
||||
|
||||
args, err := ec.field_Mutation_deletePost_args(ctx, rawArgs)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return e.complexity.Mutation.DeletePost(childComplexity, args["id"].(int)), true
|
||||
|
||||
case "Mutation.likePost":
|
||||
if e.complexity.Mutation.LikePost == nil {
|
||||
break
|
||||
@ -945,6 +959,26 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
|
||||
}
|
||||
}
|
||||
|
||||
func processArgField[T any](
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
fieldName string,
|
||||
valueMapperFn func(ctx context.Context, value any) (T, error),
|
||||
) (T, error) {
|
||||
if _, ok := rawArgs[fieldName]; !ok {
|
||||
var zeroVal T
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField(fieldName))
|
||||
if tmp, ok := rawArgs[fieldName]; ok {
|
||||
return valueMapperFn(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal T
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
type executionContext struct {
|
||||
*graphql.OperationContext
|
||||
*executableSchema
|
||||
@ -1009,756 +1043,285 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...)
|
||||
func (ec *executionContext) field_Mutation_changePassword_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_changePassword_argsOldPassword(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "oldPassword", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["oldPassword"] = arg0
|
||||
arg1, err := ec.field_Mutation_changePassword_argsNewPassword(ctx, rawArgs)
|
||||
arg1, err := processArgField(ctx, rawArgs, "newPassword", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["newPassword"] = arg1
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_changePassword_argsOldPassword(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["oldPassword"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("oldPassword"))
|
||||
if tmp, ok := rawArgs["oldPassword"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_changePassword_argsNewPassword(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["newPassword"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("newPassword"))
|
||||
if tmp, ok := rawArgs["newPassword"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_confirmEmail_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_confirmEmail_argsToken(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "token", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["token"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_confirmEmail_argsToken(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["token"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("token"))
|
||||
if tmp, ok := rawArgs["token"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_createComment_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_createComment_argsPostID(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "postId", ec.unmarshalNInt2int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["postId"] = arg0
|
||||
arg1, err := ec.field_Mutation_createComment_argsContent(ctx, rawArgs)
|
||||
arg1, err := processArgField(ctx, rawArgs, "content", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["content"] = arg1
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_createComment_argsPostID(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (int, error) {
|
||||
if _, ok := rawArgs["postId"]; !ok {
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("postId"))
|
||||
if tmp, ok := rawArgs["postId"]; ok {
|
||||
return ec.unmarshalNInt2int(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_createComment_argsContent(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["content"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("content"))
|
||||
if tmp, ok := rawArgs["content"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_createPost_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_createPost_argsTitle(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "title", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["title"] = arg0
|
||||
arg1, err := ec.field_Mutation_createPost_argsContent(ctx, rawArgs)
|
||||
arg1, err := processArgField(ctx, rawArgs, "content", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["content"] = arg1
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_createPost_argsTitle(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["title"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
|
||||
func (ec *executionContext) field_Mutation_deletePost_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := processArgField(ctx, rawArgs, "id", ec.unmarshalNInt2int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("title"))
|
||||
if tmp, ok := rawArgs["title"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_createPost_argsContent(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["content"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("content"))
|
||||
if tmp, ok := rawArgs["content"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
args["id"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_likePost_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_likePost_argsPostID(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "postId", ec.unmarshalNInt2int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["postId"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_likePost_argsPostID(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (int, error) {
|
||||
if _, ok := rawArgs["postId"]; !ok {
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("postId"))
|
||||
if tmp, ok := rawArgs["postId"]; ok {
|
||||
return ec.unmarshalNInt2int(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_login_argsInput(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "input", ec.unmarshalNLoginInput2tailly_back_v2ᚋinternalᚋdomainᚐLoginInput)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["input"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_login_argsInput(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (domain.LoginInput, error) {
|
||||
if _, ok := rawArgs["input"]; !ok {
|
||||
var zeroVal domain.LoginInput
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
|
||||
if tmp, ok := rawArgs["input"]; ok {
|
||||
return ec.unmarshalNLoginInput2tailly_back_v2ᚋinternalᚋdomainᚐLoginInput(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal domain.LoginInput
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_markAsRead_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_markAsRead_argsMessageID(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "messageId", ec.unmarshalNInt2int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["messageId"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_markAsRead_argsMessageID(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (int, error) {
|
||||
if _, ok := rawArgs["messageId"]; !ok {
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("messageId"))
|
||||
if tmp, ok := rawArgs["messageId"]; ok {
|
||||
return ec.unmarshalNInt2int(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_refreshTokens_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_refreshTokens_argsRefreshToken(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "refreshToken", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["refreshToken"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_refreshTokens_argsRefreshToken(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["refreshToken"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("refreshToken"))
|
||||
if tmp, ok := rawArgs["refreshToken"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_register_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_register_argsInput(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "input", ec.unmarshalNRegisterInput2tailly_back_v2ᚋinternalᚋdomainᚐRegisterInput)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["input"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_register_argsInput(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (domain.RegisterInput, error) {
|
||||
if _, ok := rawArgs["input"]; !ok {
|
||||
var zeroVal domain.RegisterInput
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
|
||||
if tmp, ok := rawArgs["input"]; ok {
|
||||
return ec.unmarshalNRegisterInput2tailly_back_v2ᚋinternalᚋdomainᚐRegisterInput(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal domain.RegisterInput
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_renameDevice_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_renameDevice_argsDeviceID(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "deviceId", ec.unmarshalNInt2int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["deviceId"] = arg0
|
||||
arg1, err := ec.field_Mutation_renameDevice_argsName(ctx, rawArgs)
|
||||
arg1, err := processArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["name"] = arg1
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_renameDevice_argsDeviceID(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (int, error) {
|
||||
if _, ok := rawArgs["deviceId"]; !ok {
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("deviceId"))
|
||||
if tmp, ok := rawArgs["deviceId"]; ok {
|
||||
return ec.unmarshalNInt2int(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_renameDevice_argsName(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["name"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("name"))
|
||||
if tmp, ok := rawArgs["name"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_sendMessage_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_sendMessage_argsReceiverID(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "receiverId", ec.unmarshalNInt2int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["receiverId"] = arg0
|
||||
arg1, err := ec.field_Mutation_sendMessage_argsContent(ctx, rawArgs)
|
||||
arg1, err := processArgField(ctx, rawArgs, "content", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["content"] = arg1
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_sendMessage_argsReceiverID(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (int, error) {
|
||||
if _, ok := rawArgs["receiverId"]; !ok {
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("receiverId"))
|
||||
if tmp, ok := rawArgs["receiverId"]; ok {
|
||||
return ec.unmarshalNInt2int(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_sendMessage_argsContent(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["content"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("content"))
|
||||
if tmp, ok := rawArgs["content"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_terminateSession_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_terminateSession_argsSessionID(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "sessionId", ec.unmarshalNInt2int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["sessionId"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_terminateSession_argsSessionID(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (int, error) {
|
||||
if _, ok := rawArgs["sessionId"]; !ok {
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("sessionId"))
|
||||
if tmp, ok := rawArgs["sessionId"]; ok {
|
||||
return ec.unmarshalNInt2int(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_unlikePost_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_unlikePost_argsPostID(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "postId", ec.unmarshalNInt2int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["postId"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_unlikePost_argsPostID(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (int, error) {
|
||||
if _, ok := rawArgs["postId"]; !ok {
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("postId"))
|
||||
if tmp, ok := rawArgs["postId"]; ok {
|
||||
return ec.unmarshalNInt2int(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_updateProfile_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_updateProfile_argsUsername(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "username", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["username"] = arg0
|
||||
arg1, err := ec.field_Mutation_updateProfile_argsEmail(ctx, rawArgs)
|
||||
arg1, err := processArgField(ctx, rawArgs, "email", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["email"] = arg1
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_updateProfile_argsUsername(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["username"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("username"))
|
||||
if tmp, ok := rawArgs["username"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_updateProfile_argsEmail(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["email"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
|
||||
if tmp, ok := rawArgs["email"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Query___type_argsName(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["name"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Query___type_argsName(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (string, error) {
|
||||
if _, ok := rawArgs["name"]; !ok {
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("name"))
|
||||
if tmp, ok := rawArgs["name"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal string
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_getChatHistory_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Query_getChatHistory_argsUserID(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "userId", ec.unmarshalNInt2int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["userId"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Query_getChatHistory_argsUserID(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (int, error) {
|
||||
if _, ok := rawArgs["userId"]; !ok {
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("userId"))
|
||||
if tmp, ok := rawArgs["userId"]; ok {
|
||||
return ec.unmarshalNInt2int(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_post_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Query_post_argsID(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "id", ec.unmarshalNInt2int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["id"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Query_post_argsID(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (int, error) {
|
||||
if _, ok := rawArgs["id"]; !ok {
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
|
||||
if tmp, ok := rawArgs["id"]; ok {
|
||||
return ec.unmarshalNInt2int(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Query_user_argsID(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "id", ec.unmarshalNInt2int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["id"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Query_user_argsID(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (int, error) {
|
||||
if _, ok := rawArgs["id"]; !ok {
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
|
||||
if tmp, ok := rawArgs["id"]; ok {
|
||||
return ec.unmarshalNInt2int(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal int
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field___Directive_args_argsIncludeDeprecated(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["includeDeprecated"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field___Directive_args_argsIncludeDeprecated(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (*bool, error) {
|
||||
if _, ok := rawArgs["includeDeprecated"]; !ok {
|
||||
var zeroVal *bool
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated"))
|
||||
if tmp, ok := rawArgs["includeDeprecated"]; ok {
|
||||
return ec.unmarshalOBoolean2ᚖbool(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal *bool
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field___Field_args_argsIncludeDeprecated(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["includeDeprecated"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field___Field_args_argsIncludeDeprecated(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (*bool, error) {
|
||||
if _, ok := rawArgs["includeDeprecated"]; !ok {
|
||||
var zeroVal *bool
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated"))
|
||||
if tmp, ok := rawArgs["includeDeprecated"]; ok {
|
||||
return ec.unmarshalOBoolean2ᚖbool(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal *bool
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field___Type_enumValues_argsIncludeDeprecated(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["includeDeprecated"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field___Type_enumValues_argsIncludeDeprecated(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (bool, error) {
|
||||
if _, ok := rawArgs["includeDeprecated"]; !ok {
|
||||
var zeroVal bool
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated"))
|
||||
if tmp, ok := rawArgs["includeDeprecated"]; ok {
|
||||
return ec.unmarshalOBoolean2bool(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal bool
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field___Type_fields_argsIncludeDeprecated(ctx, rawArgs)
|
||||
arg0, err := processArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["includeDeprecated"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field___Type_fields_argsIncludeDeprecated(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (bool, error) {
|
||||
if _, ok := rawArgs["includeDeprecated"]; !ok {
|
||||
var zeroVal bool
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated"))
|
||||
if tmp, ok := rawArgs["includeDeprecated"]; ok {
|
||||
return ec.unmarshalOBoolean2bool(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal bool
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
// endregion ***************************** args.gotpl *****************************
|
||||
|
||||
@ -3934,6 +3497,61 @@ func (ec *executionContext) fieldContext_Mutation_resendEmailConfirmation(_ cont
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Mutation_deletePost(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Mutation_deletePost(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.Mutation().DeletePost(rctx, fc.Args["id"].(int))
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(bool)
|
||||
fc.Result = res
|
||||
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Mutation_deletePost(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Mutation",
|
||||
Field: field,
|
||||
IsMethod: true,
|
||||
IsResolver: true,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Boolean does not have child fields")
|
||||
},
|
||||
}
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err = ec.Recover(ctx, r)
|
||||
ec.Error(ctx, err)
|
||||
}
|
||||
}()
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
if fc.Args, err = ec.field_Mutation_deletePost_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return fc, err
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Post_id(ctx context.Context, field graphql.CollectedField, obj *domain.Post) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Post_id(ctx, field)
|
||||
if err != nil {
|
||||
@ -8571,6 +8189,13 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
|
||||
if out.Values[i] == graphql.Null {
|
||||
out.Invalids++
|
||||
}
|
||||
case "deletePost":
|
||||
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
||||
return ec._Mutation_deletePost(ctx, field)
|
||||
})
|
||||
if out.Values[i] == graphql.Null {
|
||||
out.Invalids++
|
||||
}
|
||||
default:
|
||||
panic("unknown field " + strconv.Quote(field.Name))
|
||||
}
|
||||
@ -9856,6 +9481,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v any) (
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
|
||||
_ = sel
|
||||
res := graphql.MarshalBoolean(v)
|
||||
if res == graphql.Null {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
@ -9997,6 +9623,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v any) (int,
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler {
|
||||
_ = sel
|
||||
res := graphql.MarshalInt(v)
|
||||
if res == graphql.Null {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
@ -10250,6 +9877,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v any)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
|
||||
_ = sel
|
||||
res := graphql.MarshalString(v)
|
||||
if res == graphql.Null {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
@ -10341,6 +9969,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
|
||||
_ = sel
|
||||
res := graphql.MarshalString(v)
|
||||
if res == graphql.Null {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
@ -10529,6 +10158,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v a
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
|
||||
_ = sel
|
||||
res := graphql.MarshalString(v)
|
||||
if res == graphql.Null {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
@ -10544,6 +10174,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v any) (
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
|
||||
_ = sel
|
||||
_ = ctx
|
||||
res := graphql.MarshalBoolean(v)
|
||||
return res
|
||||
}
|
||||
@ -10560,6 +10192,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
|
||||
if v == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
_ = sel
|
||||
_ = ctx
|
||||
res := graphql.MarshalBoolean(*v)
|
||||
return res
|
||||
}
|
||||
@ -10576,6 +10210,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
|
||||
if v == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
_ = sel
|
||||
_ = ctx
|
||||
res := graphql.MarshalString(*v)
|
||||
return res
|
||||
}
|
||||
|
||||
@ -134,3 +134,26 @@ func (r *mutationResolver) CreatePost(ctx context.Context, title string, content
|
||||
}
|
||||
return post, nil
|
||||
}
|
||||
|
||||
// DeletePost is the resolver for the deletePost field.
|
||||
func (r *mutationResolver) DeletePost(ctx context.Context, id int) (bool, error) {
|
||||
userID, err := getUserIDFromContext(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("unauthorized: %w", err)
|
||||
}
|
||||
|
||||
post, err := r.Services.Post.GetByID(ctx, id)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to get post: %w", err)
|
||||
}
|
||||
|
||||
if post.AuthorID != userID {
|
||||
return false, fmt.Errorf("you can only delete your own posts")
|
||||
}
|
||||
|
||||
err = r.Services.Post.Delete(ctx, id)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to delete post: %w", err)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@ -2,4 +2,4 @@ package graph
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.72
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.77
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"tailly_back_v2/internal/domain"
|
||||
)
|
||||
|
||||
@ -35,8 +36,26 @@ func (r *postRepository) Update(ctx context.Context, post *domain.Post) error {
|
||||
}
|
||||
|
||||
func (r *postRepository) Delete(ctx context.Context, id int) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
query := `
|
||||
DELETE FROM posts
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
result, err := r.db.ExecContext(ctx, query, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete post: %w", err)
|
||||
}
|
||||
|
||||
rowsAffected, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get rows affected: %w", err)
|
||||
}
|
||||
|
||||
if rowsAffected == 0 {
|
||||
return ErrPostNotFound
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewPostRepository(db *sql.DB) *postRepository {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user