registerRelayStylePagination.ts 576 B

123456789101112131415161718
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { relayStylePagination } from '@apollo/client/utilities'
  3. import type { InMemoryCacheConfig } from '@apollo/client/cache/inmemory/types'
  4. export default function registerRelayStylePagination(
  5. config: InMemoryCacheConfig,
  6. queryName: string,
  7. fields: string[],
  8. ): InMemoryCacheConfig {
  9. config.typePolicies ||= {}
  10. config.typePolicies.Query ||= {}
  11. config.typePolicies.Query.fields ||= {}
  12. config.typePolicies.Query.fields[queryName] = relayStylePagination(fields)
  13. return config
  14. }