ozon-task/graph/schema.resolvers.go
2024-06-25 02:34:10 +03:00

42 lines
1.5 KiB
Go

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.49
import (
"context"
"fmt"
"git.obamna.ru/erius/ozon-task/graph/model"
)
// AddPost is the resolver for the add_post field.
func (r *mutationResolver) AddPost(ctx context.Context, input *model.PostInput) (*model.AddResult, error) {
return r.Storage.AddPost(input)
}
// AddComment is the resolver for the add_comment field.
func (r *mutationResolver) AddComment(ctx context.Context, input *model.CommentInput) (*model.AddResult, error) {
if len(input.Contents) > model.CommentLengthLimit {
return nil, fmt.Errorf("exceeded max comment length of %d chars", model.CommentLengthLimit)
}
if input.ParentCommentID == nil && input.ParentPostID == nil {
return nil, fmt.Errorf("parent post or parent comment ids weren't specified")
}
return r.Storage.AddComment(input)
}
// AllPosts is the resolver for the all_posts field.
func (r *queryResolver) AllPosts(ctx context.Context) ([]*model.Post, error) {
return r.Storage.GetPosts()
}
// Mutation returns MutationResolver implementation.
func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} }
// Query returns QueryResolver implementation.
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }
type mutationResolver struct{ *Resolver }
type queryResolver struct{ *Resolver }