stufflog graphql server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.6 KiB

  1. package resolvers
  2. // This file will be automatically regenerated based on the schema, any resolver implementations
  3. // will be copied through when generating and any unknown code will be moved to the end.
  4. import (
  5. "context"
  6. "fmt"
  7. "git.aiterp.net/stufflog/server/graph/graphcore"
  8. "git.aiterp.net/stufflog/server/models"
  9. )
  10. func (r *issueItemResolver) Issue(ctx context.Context, obj *models.IssueItem) (*models.Issue, error) {
  11. return r.Database.Issues().Find(ctx, obj.IssueID)
  12. }
  13. func (r *issueItemResolver) Item(ctx context.Context, obj *models.IssueItem) (*models.Item, error) {
  14. return r.Database.Items().Find(ctx, obj.ItemID)
  15. }
  16. func (r *issueItemResolver) Remaining(ctx context.Context, obj *models.IssueItem) (int, error) {
  17. if obj.Acquired {
  18. return 0, nil
  19. }
  20. // TODO: Use logs
  21. return obj.Quantity, nil
  22. }
  23. // IssueItem returns graphcore.IssueItemResolver implementation.
  24. func (r *Resolver) IssueItem() graphcore.IssueItemResolver { return &issueItemResolver{r} }
  25. type issueItemResolver struct{ *Resolver }
  26. // !!! WARNING !!!
  27. // The code below was going to be deleted when updating resolvers. It has been copied here so you have
  28. // one last chance to move it out of harms way if you want. There are two reasons this happens:
  29. // - When renaming or deleting a resolver the old code will be put in here. You can safely delete
  30. // it when you're done.
  31. // - You have helper methods in this file. Move them out to keep these resolver files clean.
  32. func (r *issueItemResolver) Quanity(ctx context.Context, obj *models.IssueItem) (int, error) {
  33. panic(fmt.Errorf("not implemented"))
  34. }