v0.0.13 Скорректирован метод Comments в postResolver
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
6758e706f2
commit
f9f1e16b1b
@ -3,7 +3,6 @@ package graph
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"tailly_back_v2/internal/domain"
|
||||
"time"
|
||||
)
|
||||
@ -47,22 +46,10 @@ func (r *postResolver) Author(ctx context.Context, obj *domain.Post) (*domain.Us
|
||||
|
||||
// Comments is the resolver for the comments field.
|
||||
func (r *postResolver) Comments(ctx context.Context, obj *domain.Post) ([]*domain.Comment, error) {
|
||||
log.Printf("Вызов резолвера Comments для поста %d", obj.ID)
|
||||
|
||||
// Логируем контекст
|
||||
if user, ok := ctx.Value("user").(*domain.User); ok {
|
||||
log.Printf("Пользователь: %d", user.ID)
|
||||
} else {
|
||||
log.Println("Пользователь не авторизован")
|
||||
}
|
||||
|
||||
comments, err := r.Services.Comment.GetByPostID(ctx, obj.ID)
|
||||
if err != nil {
|
||||
log.Printf("Ошибка получения комментариев: %v", err)
|
||||
return nil, fmt.Errorf("failed to get comments: %w", err)
|
||||
}
|
||||
|
||||
log.Printf("Найдено комментариев: %d", len(comments))
|
||||
return comments, nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user