The Renovate branches changed go.mod and package.json without go.sum or package-lock.json, so this tidies the module graph, regenerates the gqlgen code for v0.17.98 and refreshes the lockfile. katex stays on 0.16: @mdit/plugin-katex renders with its own katex ^0.16 and Markdown.vue loads only the stylesheet from the top-level package, so 0.19's CSS would no longer match the rendered HTML. renovate.json5 now caps it below 0.17 so the bump is not proposed again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
99 lines
2.8 KiB
Go
99 lines
2.8 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"
|
|
)
|
|
|
|
// CreatePlace is the resolver for the createPlace field.
|
|
func (r *mutationResolver) CreatePlace(ctx context.Context, input model.CreatePlaceInput) (*models.Place, error) {
|
|
// Any signed-in user, not just an admin — places are the one shared,
|
|
// collaboratively edited list on the site, so the schema marks these
|
|
// fields @signedIn rather than @admin. There is no per-user ownership, so
|
|
// any signed-in user can edit or delete any place.
|
|
place := models.Place{
|
|
Title: input.Title,
|
|
Location: input.Location,
|
|
Notes: input.Notes,
|
|
ImageURL: input.ImageURL,
|
|
Category: input.Category,
|
|
Cost: input.Cost,
|
|
}
|
|
if input.Priority != nil {
|
|
place.Priority = *input.Priority
|
|
}
|
|
if input.Done != nil {
|
|
place.Done = *input.Done
|
|
}
|
|
if err := r.Store.DB.Create(&place).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &place, nil
|
|
}
|
|
|
|
// UpdatePlace is the resolver for the updatePlace field.
|
|
func (r *mutationResolver) UpdatePlace(ctx context.Context, id int, input model.UpdatePlaceInput) (*models.Place, error) {
|
|
// Partial update, same pointer-means-supplied convention as job
|
|
// applications: nil fields are left as they are.
|
|
var place models.Place
|
|
if err := r.Store.DB.First(&place, id).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
if input.Title != nil {
|
|
place.Title = *input.Title
|
|
}
|
|
if input.Location != nil {
|
|
place.Location = input.Location
|
|
}
|
|
if input.Notes != nil {
|
|
place.Notes = input.Notes
|
|
}
|
|
if input.ImageURL != nil {
|
|
place.ImageURL = input.ImageURL
|
|
}
|
|
if input.Category != nil {
|
|
place.Category = input.Category
|
|
}
|
|
if input.Cost != nil {
|
|
place.Cost = input.Cost
|
|
}
|
|
if input.Priority != nil {
|
|
place.Priority = *input.Priority
|
|
}
|
|
if input.Done != nil {
|
|
place.Done = *input.Done
|
|
}
|
|
if err := r.Store.DB.Save(&place).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &place, nil
|
|
}
|
|
|
|
// DeletePlace is the resolver for the deletePlace field.
|
|
func (r *mutationResolver) DeletePlace(ctx context.Context, id int) (*models.Place, error) {
|
|
var place models.Place
|
|
if err := r.Store.DB.First(&place, id).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
if err := r.Store.DB.Delete(&place).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &place, nil
|
|
}
|
|
|
|
// Places is the resolver for the places field.
|
|
func (r *queryResolver) Places(ctx context.Context) ([]*models.Place, error) {
|
|
var places []models.Place
|
|
if err := r.Store.DB.Order("done ASC, priority DESC, created_at DESC").Find(&places).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return ptrs(places), nil
|
|
}
|