How to use the @apollo/client.throwServerError function in @apollo/client

To help you get started, we’ve selected a few @apollo/client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seashell / drago / ui / src / graphql / apollo-provider.js View on Github external
export async function customFetch(requestInfo, init) {
  const response = await fetch(requestInfo, init)
  const res = response.clone()

  if (!res.ok) {
    const body = await res.json()
    if (response.status === 404) {
      throwServerError(res, body, 'Not found error')
    }
    if (response.status === 500) {
      throwServerError(res, body, `Internal error: ${body.Message}`)
    }
  }
  return response
}
github seashell / drago / ui / src / graphql / apollo-provider.js View on Github external
export async function customFetch(requestInfo, init) {
  const response = await fetch(requestInfo, init)
  const res = response.clone()

  if (!res.ok) {
    const body = await res.json()
    if (response.status === 404) {
      throwServerError(res, body, 'Not found error')
    }
    if (response.status === 500) {
      throwServerError(res, body, `Internal error: ${body.Message}`)
    }
  }
  return response
}