Authorisation: @admin and @signedIn schema directives replace the 25 hand-copied resolver checks. A test fails if a mutation has neither and is not on the public allow-list, so a new mutation cannot ship unguarded. IDs: uint model IDs bind through graphql.UintID, removing the ten int(obj.ID) resolvers. Job status is a GraphQL enum, tied to services.statusOrder by a test. Input is strict, so the mutations no longer coerce an unknown status to "applied"; output is lenient so one legacy row cannot fail the list. deleteJobApplication and deleteJobAppReference now error on a missing id like the other deletes. The rowing reader, the job extractor and now the email classifier reach the Python service through one services.CallPython helper. The email pipeline's prompt and fence stripping moved to Python, and anthropic-sdk-go is gone from go.mod. Fix the auth test fixture, whose 11-byte secret had been panicking the services test package since InitAuth began requiring 32 bytes. Add a test that keeps the python service's compose environment list in step with the env registry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
47 lines
1.6 KiB
Go
47 lines
1.6 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.95
|
|
|
|
import (
|
|
"context"
|
|
|
|
"adam-french.co.uk/backend/graph/model"
|
|
"adam-french.co.uk/backend/models"
|
|
)
|
|
|
|
// CreateBookmark is the resolver for the createBookmark field.
|
|
func (r *mutationResolver) CreateBookmark(ctx context.Context, input model.CreateBookmarkInput) (*models.Bookmark, error) {
|
|
bookmark := models.Bookmark{Category: input.Category, Name: input.Name, Link: input.Link}
|
|
if err := r.Store.DB.Create(&bookmark).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &bookmark, nil
|
|
}
|
|
|
|
// DeleteBookmark is the resolver for the deleteBookmark field.
|
|
func (r *mutationResolver) DeleteBookmark(ctx context.Context, id int) (*models.Bookmark, error) {
|
|
// Loaded first so the deleted record can be returned to the client, and
|
|
// so a missing id is a clean "not found" rather than a silent no-op.
|
|
// Delete is a soft delete: deleted_at is set and the row stays.
|
|
var bookmark models.Bookmark
|
|
if err := r.Store.DB.First(&bookmark, id).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
if err := r.Store.DB.Delete(&bookmark).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &bookmark, nil
|
|
}
|
|
|
|
// Bookmarks is the resolver for the bookmarks field.
|
|
func (r *queryResolver) Bookmarks(ctx context.Context) ([]*models.Bookmark, error) {
|
|
var bookmarks []models.Bookmark
|
|
if err := r.Store.DB.Order("category ASC, created_at DESC").Find(&bookmarks).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return ptrs(bookmarks), nil
|
|
}
|