getErrorContext.ts 527 B

12345678910111213141516
  1. // Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. import { Operation } from '@apollo/client/core'
  3. import { ClientErrorContext } from '@common/types/server/apollo/client'
  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. }