35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package graph
|
||
|
||
import (
|
||
"context"
|
||
"tailly_back_v2/internal/domain"
|
||
)
|
||
|
||
// userResolver реализует методы для работы с пользователями
|
||
type userResolver struct{ *Resolver }
|
||
|
||
// Query.user - получение пользователя по ID
|
||
func (r *queryResolver) User(ctx context.Context, id string) (*domain.User, error) {
|
||
return r.services.User.GetByID(ctx, id)
|
||
}
|
||
|
||
// CreatedAt is the resolver for the createdAt field.
|
||
func (r *userResolver) CreatedAt(ctx context.Context, obj *domain.User) (string, error) {
|
||
panic("not implemented")
|
||
}
|
||
|
||
// UpdatedAt is the resolver for the updatedAt field.
|
||
func (r *userResolver) UpdatedAt(ctx context.Context, obj *domain.User) (string, error) {
|
||
panic("not implemented")
|
||
}
|
||
|
||
// Mutation.updateProfile - обновление профиля
|
||
func (r *mutationResolver) UpdateProfile(ctx context.Context, username string, email string) (*domain.User, error) {
|
||
userID, err := getUserIDFromContext(ctx)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
return r.services.User.UpdateProfile(ctx, userID, username, email)
|
||
}
|