erius
e0aa12b126
Removed unnecesary bindings for ID and Int in gqlgen.yml Minor changes to Makefile docker-clean target Reduced docker-compose postgres healthcheck interval for faster local db connections Added pagination to graphql schema, the paginated queries are WIP Removed unneeded fields from the model structs Added allowComment check when adding comments Switched gorm logger to Info mode App now panics if the specified APP_STORAGE in env doesn't exist Reworked database methods, still barely working and are WIP
37 lines
1.3 KiB
Go
37 lines
1.3 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)
|
|
}
|
|
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 }
|