You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
package resolvers
|
|
|
|
import (
|
|
"context"
|
|
"git.aiterp.net/rpdata/api/graph2/graphcore"
|
|
"git.aiterp.net/rpdata/api/models"
|
|
)
|
|
|
|
// Queries
|
|
|
|
func (r *queryResolver) Post(ctx context.Context, id string) (*models.Post, error) {
|
|
return r.s.Logs.FindPosts(ctx, id)
|
|
}
|
|
|
|
func (r *queryResolver) Posts(ctx context.Context, filter *models.PostFilter) ([]*models.Post, error) {
|
|
return r.s.Logs.ListPosts(ctx, filter)
|
|
}
|
|
|
|
// Mutation
|
|
|
|
func (r *mutationResolver) AddPost(ctx context.Context, input graphcore.PostAddInput) (*models.Post, error) {
|
|
return r.s.Logs.AddPost(ctx, input.LogID, input.Time, input.Kind, input.Nick, input.Text)
|
|
}
|
|
|
|
func (r *mutationResolver) EditPost(ctx context.Context, input graphcore.PostEditInput) (*models.Post, error) {
|
|
return r.s.Logs.EditPost(ctx, input.ID, models.PostUpdate{
|
|
Time: input.Time,
|
|
Kind: input.Kind,
|
|
Nick: input.Nick,
|
|
Text: input.Text,
|
|
})
|
|
}
|
|
|
|
func (r *mutationResolver) MovePost(ctx context.Context, input graphcore.PostMoveInput) ([]*models.Post, error) {
|
|
return r.s.Logs.MovePost(ctx, input.ID, input.ToPosition)
|
|
}
|
|
|
|
func (r *mutationResolver) RemovePost(ctx context.Context, input graphcore.PostRemoveInput) (*models.Post, error) {
|
|
return r.s.Logs.DeletePost(ctx, input.ID)
|
|
}
|