Organization.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { faker } from '@faker-js/faker'
  3. import type { Organization } from '#shared/graphql/types.ts'
  4. import { convertToGraphQLId } from '#shared/graphql/utils.ts'
  5. import type { DeepPartial } from '#shared/types/utils.ts'
  6. export default (parent: any): DeepPartial<Organization> => {
  7. const organization: DeepPartial<Organization> = {
  8. id: convertToGraphQLId('Organization', 1),
  9. domain: faker.internet.domainName(),
  10. objectAttributeValues: [],
  11. }
  12. // to not go into an infine loop
  13. if (parent?.__typename === 'User') {
  14. organization.members = {
  15. edges: [{ __typename: 'UserEdge', node: parent, cursor: 'AB' }],
  16. pageInfo: {
  17. endCursor: 'AB',
  18. startCursor: 'AB',
  19. hasNextPage: false,
  20. hasPreviousPage: false,
  21. },
  22. totalCount: 1,
  23. }
  24. organization.secondaryMembers = {
  25. edges: [{ __typename: 'UserEdge', node: parent, cursor: 'AB' }],
  26. pageInfo: {
  27. endCursor: 'AB',
  28. startCursor: 'AB',
  29. hasNextPage: false,
  30. hasPreviousPage: false,
  31. },
  32. totalCount: 1,
  33. }
  34. organization.allMembers = {
  35. edges: [{ __typename: 'UserEdge', node: parent, cursor: 'AB' }],
  36. pageInfo: {
  37. endCursor: 'AB',
  38. startCursor: 'AB',
  39. hasNextPage: false,
  40. hasPreviousPage: false,
  41. },
  42. totalCount: 2,
  43. }
  44. } else {
  45. organization.members = {
  46. edges: [],
  47. totalCount: 0,
  48. }
  49. organization.secondaryMembers = {
  50. edges: [],
  51. totalCount: 0,
  52. }
  53. organization.allMembers = {
  54. edges: [],
  55. totalCount: 0,
  56. }
  57. }
  58. return organization
  59. }