How to use the apollo-client/errors/ApolloError.isApolloError 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 sensu / sensu-go / dashboard / src / mutations / createSilence.js View on Github external
.catch(error => {
      // HACK: Transform query root-level "resource already exists" error to
      // mutation specific validation errors. This temporarily simulates how we
      // intend to report this error state in the future and can be removed once
      // the API has been updated.
      if (isApolloError(error) && error.message === RESOURCE_EXISTS_ERROR) {
        return {
          data: {
            createSilence: {
              silence: null,
              errors: [
                {
                  code: "VALIDATION_UNIQUE_CONSTRAINT",
                  input: "check",
                },
                {
                  code: "VALIDATION_UNIQUE_CONSTRAINT",
                  input: "subscription",
                },
              ],
            },
          },
github sensu / sensu-go / dashboard / src / lib / component / root / ErrorRoot.js View on Github external
const unwrapError = error => {
  if (error instanceof Error) {
    const meta = {};

    if (error instanceof ReactError) {
      return {
        componentStack: error.componentStack,
        ...unwrapError(error.original),
      };
    }

    if (isApolloError(error) && error.networkError) {
      return unwrapError(error.networkError);
    }

    if (error instanceof FetchError) {
      if (error.original) {
        return {
          url: error.url,
          statusCode: error.statusCode,
          ...unwrapError(error.original),
        };
      }

      meta.url = error.url;
      meta.statusCode = error.statusCode;
    }
github sensu / sensu-go / dashboard / src / lib / component / ErrorRoot.js View on Github external
const unwrapError = error => {
  if (error instanceof Error) {
    const meta = {};

    if (error instanceof ReactError) {
      return {
        componentStack: error.componentStack,
        ...unwrapError(error.original),
      };
    }

    if (isApolloError(error) && error.networkError) {
      return unwrapError(error.networkError);
    }

    if (error instanceof FetchError) {
      if (error.original) {
        return {
          url: error.url,
          statusCode: error.statusCode,
          ...unwrapError(error.original),
        };
      }

      meta.url = error.url;
      meta.statusCode = error.statusCode;
    }