How to use the apollo-client.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 sysgears / apollo-universal-starter-kit / modules / payments / client-react / stripe / subscription / containers / UpdateCreditCard.native.tsx View on Github external
const { t, history, navigation } = this.props;
    let preparedCreditCard;

    try {
      // create credit card token
      preparedCreditCard = await createCreditCardToken(creditCardInput, stripe);

      await updateCard({ variables: { input: preparedCreditCard } });

      this.setState({ submitting: false });
      history ? history.push('/profile') : navigation.navigate('Profile');
    } catch (e) {
      this.setState({
        submitting: false
      });
      if (isApolloError(e)) {
        if (e.graphQLErrors[0].extensions.code === 'resource_missing') {
          throw new FormError(t('stripeError'), e);
        } else {
          throw new FormError(t('serverError'), e);
        }
      } else {
        throw new FormError(t('creditCardError'));
      }
    }
  };
github sysgears / apollo-universal-starter-kit / modules / payments / client-react / stripe / subscription / containers / UpdateCreditCard.tsx View on Github external
const onSubmit = (updateCard: any) => async (creditCardInput: CreditCardInput, stripe?: any) => {
    setSubmitting(true);
    let preparedCreditCard;

    try {
      // create credit card token
      preparedCreditCard = await createCreditCardToken(creditCardInput, stripe);

      await updateCard({ variables: { input: preparedCreditCard } });

      setSubmitting(false);
      history ? history.push('/profile') : navigation.navigate('Profile');
    } catch (e) {
      setSubmitting(false);

      if (isApolloError(e)) {
        if (e.graphQLErrors[0].extensions.code === 'resource_missing') {
          throw new FormError(t('stripeError'), e);
        } else {
          throw new FormError(t('serverError'), e);
        }
      } else {
        throw new FormError(t('creditCardError'));
      }
    }
  };
github sysgears / apollo-universal-starter-kit / modules / payments / client-react / stripe / subscription / containers / AddSubscription.tsx View on Github external
const onSubmit = (addSubscription: any) => async (creditCardInput: CreditCardInput, stripe?: any) => {
    setSubmitting(true);
    let preparedCreditCard;

    try {
      // create credit card token
      preparedCreditCard = await createCreditCardToken(creditCardInput, stripe);

      await addSubscription({ variables: { input: preparedCreditCard } });

      setSubmitting(false);
      history ? history.push('/subscriber-page') : navigation.goBack();
    } catch (e) {
      setSubmitting(false);
      if (isApolloError(e)) {
        if (e.graphQLErrors[0].extensions.code === 'resource_missing') {
          throw new FormError(t('stripeError'), e);
        } else {
          throw new FormError(t('serverError'), e);
        }
      } else {
        throw new FormError(t('creditCardError'));
      }
    }
  };