github.com/maeglindeveloper/gqlgen@v0.13.1-0.20210413081235-57808b12a0a0/example/config/todo.resolvers.go (about)

     1  package config
     2  
     3  // This file will be automatically regenerated based on the schema, any resolver implementations
     4  // will be copied through when generating and any unknown code will be moved to the end.
     5  
     6  import (
     7  	"context"
     8  	"fmt"
     9  )
    10  
    11  func (r *todoResolver) ID(ctx context.Context, obj *Todo) (string, error) {
    12  	if obj.ID != "" {
    13  		return obj.ID, nil
    14  	}
    15  
    16  	obj.ID = fmt.Sprintf("TODO:%d", obj.DatabaseID)
    17  
    18  	return obj.ID, nil
    19  }
    20  
    21  // Todo returns TodoResolver implementation.
    22  func (r *Resolver) Todo() TodoResolver { return &todoResolver{r} }
    23  
    24  type todoResolver struct{ *Resolver }