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) } switch { case input.ParentPostID != nil: return r.Storage.AddCommentToPost(&input) case input.ParentCommentID != nil: return r.Storage.AddReplyToComment(&input) default: return nil, fmt.Errorf("parent post or parent comment ids weren't specified") } } // Mutation returns MutationResolver implementation. func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } type mutationResolver struct{ *Resolver }