diff --git a/docs/content/getting-started-dep.md b/docs/content/getting-started-dep.md index 204741adfe..93c8410c37 100644 --- a/docs/content/getting-started-dep.md +++ b/docs/content/getting-started-dep.md @@ -195,8 +195,6 @@ $ go run scripts/gqlgen.go Now we just need to fill in the `not implemented` parts. Update `resolver.go` ```go -//go:generate go run ./scripts/gqlgen.go - package gettingstarted import ( @@ -205,7 +203,7 @@ import ( "math/rand" ) -type Resolver struct{ +type Resolver struct { todos []Todo } @@ -221,13 +219,13 @@ func (r *Resolver) Todo() TodoResolver { type mutationResolver struct{ *Resolver } -func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (Todo, error) { - todo := Todo{ +func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) { + todo := &Todo{ Text: input.Text, ID: fmt.Sprintf("T%d", rand.Int()), UserID: input.UserID, } - r.todos = append(r.todos, todo) + r.todos = append(r.todos, *todo) return todo, nil } @@ -239,8 +237,8 @@ func (r *queryResolver) Todos(ctx context.Context) ([]Todo, error) { type todoResolver struct{ *Resolver } -func (r *todoResolver) User(ctx context.Context, obj *Todo) (User, error) { - return User{ID: obj.UserID, Name: "user " + obj.UserID}, nil +func (r *todoResolver) User(ctx context.Context, obj *Todo) (*User, error) { + return &User{ID: obj.UserID, Name: "user " + obj.UserID}, nil } ```