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.37 import ( "context" "errors" "somepi.ddns.net/gitea/gilex-dev/YetAnotherToDoList/globals" "somepi.ddns.net/gitea/gilex-dev/YetAnotherToDoList/graph/model" ) // CreateUser is the resolver for the createUser field. func (r *mutationResolver) CreateUser(ctx context.Context, input model.NewUser) (*model.User, error) { todo, err := globals.DB.AddUser(input) if err != nil { globals.Logger.Println("Failed to add new user:", err) return nil, errors.New("failed to add new user") } return todo, nil } // CreateTodo is the resolver for the createTodo field. func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) { todo, err := globals.DB.AddTodo(input) if err != nil { globals.Logger.Println("Failed to add new todo:", err) return nil, errors.New("failed to add new todo") } return todo, nil } // UpdateTodo is the resolver for the updateTodo field. func (r *mutationResolver) UpdateTodo(ctx context.Context, id string, changes model.UpdateTodo) (*model.Todo, error) { return globals.DB.UpdateTodo(id, &changes) } // UpdateUser is the resolver for the updateUser field. func (r *mutationResolver) UpdateUser(ctx context.Context, id string, changes model.UpdateUser) (*model.User, error) { return globals.DB.UpdateUser(id, &changes) } // DeleteUser is the resolver for the deleteUser field. func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (*string, error) { return globals.DB.DeleteUser(id) } // DeleteTodo is the resolver for the deleteTodo field. func (r *mutationResolver) DeleteTodo(ctx context.Context, id string) (*string, error) { return globals.DB.DeleteTodo(id) } // Todos is the resolver for the todos field. func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) { return globals.DB.GetAllTodos() } // Users is the resolver for the users field. func (r *queryResolver) Users(ctx context.Context) ([]*model.User, error) { return globals.DB.GetAllUsers() } // User is the resolver for the user field. func (r *queryResolver) User(ctx context.Context, id string) (*model.User, error) { return globals.DB.GetUser(&model.User{ID: id}) } // Todo is the resolver for the todo field. func (r *queryResolver) Todo(ctx context.Context, id string) (*model.Todo, error) { return globals.DB.GetTodo(&model.Todo{ID: id}) } // User is the resolver for the user field. func (r *todoResolver) User(ctx context.Context, obj *model.Todo) (*model.User, error) { // TODO: implement dataloader return globals.DB.GetUser(obj.User) } // Todos is the resolver for the todos field. func (r *userResolver) Todos(ctx context.Context, obj *model.User) ([]*model.Todo, error) { return globals.DB.GetTodosFrom(obj) } // Mutation returns MutationResolver implementation. func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } // Todo returns TodoResolver implementation. func (r *Resolver) Todo() TodoResolver { return &todoResolver{r} } // User returns UserResolver implementation. func (r *Resolver) User() UserResolver { return &userResolver{r} } type mutationResolver struct{ *Resolver } type queryResolver struct{ *Resolver } type todoResolver struct{ *Resolver } type userResolver struct{ *Resolver }