adding fake error

This commit is contained in:
talksik
2023-05-23 17:50:28 -07:00
parent b251506d0a
commit d3f116a753
+4
View File
@@ -8,7 +8,9 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/99designs/gqlgen/graphql"
"github.com/talksik/graphql-golang/graph/model" "github.com/talksik/graphql-golang/graph/model"
gqperror "github.com/vektah/gqlparser/v2/gqlerror"
) )
var todos = []*model.Todo{ var todos = []*model.Todo{
@@ -60,6 +62,8 @@ func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo)
// Todos is the resolver for the todos field. // Todos is the resolver for the todos field.
func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) { func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) {
graphql.AddError(ctx, gqperror.Errorf("user not found"))
return todos, nil return todos, nil
} }