GraphQL API and utilities for the rpdata project
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.

59 lines
1020 B

  1. package types
  2. import (
  3. "time"
  4. "git.aiterp.net/rpdata/api/model/file"
  5. )
  6. // FileResolver for the File graphql type
  7. type FileResolver struct{ F file.File }
  8. // ID resolves File.id
  9. func (f *FileResolver) ID() string {
  10. return f.F.ID
  11. }
  12. // Author resolves File.author
  13. func (f *FileResolver) Author() string {
  14. return f.F.Author
  15. }
  16. // Kind resolves File.kind
  17. func (f *FileResolver) Kind() string {
  18. return f.F.Kind
  19. }
  20. // Time resolves File.time
  21. func (f *FileResolver) Time() string {
  22. return f.F.Time.Format(time.RFC3339Nano)
  23. }
  24. // Public resolves File.public
  25. func (f *FileResolver) Public() bool {
  26. return f.F.Public
  27. }
  28. // Name resolves File.name
  29. func (f *FileResolver) Name() string {
  30. return f.F.Name
  31. }
  32. // MimeType resolves File.mimeType
  33. func (f *FileResolver) MimeType() string {
  34. return f.F.MimeType
  35. }
  36. // Size resolves File.size
  37. func (f *FileResolver) Size() int32 {
  38. return int32(f.F.Size)
  39. }
  40. // URL resolves File.url
  41. func (f *FileResolver) URL() *string {
  42. if f.F.URL == "" {
  43. return nil
  44. }
  45. return &f.F.URL
  46. }