B:BD[
3.1366] → [
3.1366:1442]
B:BD[
2.248] → [
2.248:286]
func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) {
panic(fmt.Errorf("not implemented"))
func (r *queryResolver) Todos(ctx context.Context) ([]model.Todo, error) {
res, err := r.graph.Query("(:todo)")
if err != nil {
return nil, fmt.Errorf("Todos: %w", err)
}
var ret []model.Todo
for r := res.Record(); res.Next(); r = res.Record() {
id, ok := r.GetByIndex(0).(string)
if !ok {
return nil, fmt.Errorf("Todos: %+v ID not found", r)
}
prop, ok := r.GetByIndex(1).(map[string]interface{})
if !ok {
return nil, fmt.Errorf("Todos: %+v properties not found", r)
}
user, ok := r.GetByIndex(2).(string)
if !ok {
return nil, fmt.Errorf("Todos: %+v user not found", r)
}
ret = append(ret, model.Todo{ID: id, Properties: prop, UserID: user})
}
return ret, nil