getErrorContext.ts 541 B

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