Organization.ts 988 B

123456789101112131415161718192021222324252627282930313233
  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 type { DeepPartial } from '#shared/types/utils.ts'
  5. import { convertToGraphQLId } from '#shared/graphql/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. } else {
  25. organization.members = {
  26. edges: [],
  27. totalCount: 0,
  28. }
  29. }
  30. return organization
  31. }