getBatchContext.ts 536 B

1234567891011121314151617
  1. // Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. import type { ClientBatchContext } from '#shared/types/server/apollo/client.ts'
  3. import type { Operation } from '@apollo/client/core'
  4. export default function getBatchContext(
  5. operation: Operation,
  6. ): ClientBatchContext {
  7. const defaultBatchContext: ClientBatchContext = {
  8. active: true,
  9. }
  10. const context = operation.getContext()
  11. const batch: Partial<ClientBatchContext> = context.batch || {}
  12. return Object.assign(defaultBatchContext, batch)
  13. }