variants.model.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import {
  2. BaseModel,
  3. BooleanField,
  4. DateField,
  5. FloatField,
  6. IntField,
  7. NumericField,
  8. JSONField,
  9. BytesField,
  10. EnumField,
  11. StringField,
  12. } from 'warthog';
  13. import { ObjectType, Field, createUnionType } from 'type-graphql';
  14. @ObjectType()
  15. export class DataObjectOwnerChannel {
  16. public isTypeOf: string = 'DataObjectOwnerChannel';
  17. @IntField({
  18. description: `Channel identifier`,
  19. })
  20. channel!: number;
  21. @IntField({
  22. nullable: true,
  23. description: `Variant needs to have at least one property. This value is not used.`,
  24. })
  25. dummy?: number;
  26. }
  27. @ObjectType()
  28. export class DataObjectOwnerCouncil {
  29. public isTypeOf: string = 'DataObjectOwnerCouncil';
  30. @IntField({
  31. nullable: true,
  32. description: `Variant needs to have at least one property. This value is not used.`,
  33. })
  34. dummy?: number;
  35. }
  36. @ObjectType()
  37. export class DataObjectOwnerDao {
  38. public isTypeOf: string = 'DataObjectOwnerDao';
  39. @IntField({
  40. description: `DAO identifier`,
  41. })
  42. dao!: number;
  43. }
  44. @ObjectType()
  45. export class DataObjectOwnerMember {
  46. public isTypeOf: string = 'DataObjectOwnerMember';
  47. @IntField({
  48. description: `Member identifier`,
  49. })
  50. member!: number;
  51. @IntField({
  52. nullable: true,
  53. description: `Variant needs to have at least one property. This value is not used.`,
  54. })
  55. dummy?: number;
  56. }
  57. @ObjectType()
  58. export class DataObjectOwnerWorkingGroup {
  59. public isTypeOf: string = 'DataObjectOwnerWorkingGroup';
  60. @IntField({
  61. description: `Working group identifier`,
  62. })
  63. workingGroup!: number;
  64. }
  65. export const DataObjectOwner = createUnionType({
  66. name: 'DataObjectOwner',
  67. types: () => [
  68. DataObjectOwnerMember,
  69. DataObjectOwnerChannel,
  70. DataObjectOwnerDao,
  71. DataObjectOwnerCouncil,
  72. DataObjectOwnerWorkingGroup,
  73. ],
  74. resolveType: (value) => (value.isTypeOf ? value.isTypeOf : undefined),
  75. });