Drop narration, history and restated-code comments across the repo, keep short ones for security boundaries, upstream quirks and ordering constraints, and record the convention in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
33 lines
1.0 KiB
Go
33 lines
1.0 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.98
|
|
|
|
import (
|
|
"context"
|
|
|
|
"adam-french.co.uk/backend/graph/model"
|
|
"adam-french.co.uk/backend/models"
|
|
)
|
|
|
|
// CreateActivity is the resolver for the createActivity field.
|
|
func (r *mutationResolver) CreateActivity(ctx context.Context, input model.CreateActivityInput) (*models.Activity, error) {
|
|
activity := models.Activity{Type: input.Type, Name: input.Name, Link: input.Link}
|
|
if err := r.Store.DB.Create(&activity).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &activity, nil
|
|
}
|
|
|
|
// Activities is the resolver for the activities field.
|
|
func (r *queryResolver) Activities(ctx context.Context) ([]*models.Activity, error) {
|
|
var activities []models.Activity
|
|
if err := r.Store.DB.Order("created_at DESC").Find(&activities).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return ptrs(activities), nil
|
|
}
|