YetAnotherToDoList/graph/schema.resolvers.go

49 lines
1.6 KiB
Go
Raw Normal View History

2023-08-19 23:47:36 +02:00
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.36
import (
"context"
2023-09-01 21:33:26 +02:00
"crypto/rand"
"math/big"
2023-08-19 23:47:36 +02:00
"somepi.ddns.net/gitea/gilex-dev/YetAnotherToDoList/graph/model"
)
// CreateTodo is the resolver for the createTodo field.
func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) {
2023-09-01 21:33:26 +02:00
rand, _ := rand.Int(rand.Reader, big.NewInt(100))
todo := &model.Todo{
ID: rand.String(),
Text: input.Text,
User: &model.User{ID: input.UserID, Name: "User-" + input.UserID},
}
r.todos = append(r.todos, todo)
return todo, nil
2023-08-19 23:47:36 +02:00
}
// Todos is the resolver for the todos field.
func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) {
2023-09-01 21:33:26 +02:00
return r.todos, nil
}
// User is the resolver for the user field.
func (r *todoResolver) User(ctx context.Context, obj *model.Todo) (*model.User, error) {
return &model.User{ID: obj.User.ID, Name: obj.User.Name}, nil
2023-08-19 23:47:36 +02:00
}
// Mutation returns MutationResolver implementation.
func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} }
// Query returns QueryResolver implementation.
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }
2023-09-01 21:33:26 +02:00
// Todo returns TodoResolver implementation.
func (r *Resolver) Todo() TodoResolver { return &todoResolver{r} }
2023-08-19 23:47:36 +02:00
type mutationResolver struct{ *Resolver }
type queryResolver struct{ *Resolver }
2023-09-01 21:33:26 +02:00
type todoResolver struct{ *Resolver }