How to use the ts-invariant.invariant.error function in ts-invariant

To help you get started, we’ve selected a few ts-invariant 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 apollographql / apollo-client / packages / apollo-cache-inmemory / src / fragmentMatcher.ts View on Github external
// At this point we don't know if this fragment should match or not. It's
    // either:
    //
    // 1. (GOOD) A fragment on a matching interface or union.
    // 2. (BAD) A fragment on a non-matching concrete type or interface or union.
    //
    // If it's 2, we don't want it to match. If it's 1, we want it to match. We
    // can't tell the difference, so we warn the user, but still try to match
    // it (for backwards compatibility reasons). This unfortunately means that
    // using the `HeuristicFragmentMatcher` with unions and interfaces is
    // very unreliable. This will be addressed in a future major version of
    // Apollo Client, but for now the recommendation is to use the
    // `IntrospectionFragmentMatcher` when working with unions/interfaces.

    if (shouldWarn()) {
      invariant.error(
        'You are using the simple (heuristic) fragment matcher, but your ' +
          'queries contain union or interface types. Apollo Client will not be ' +
          'able to accurately map fragments. To make this error go away, use ' +
          'the `IntrospectionFragmentMatcher` as described in the docs: ' +
          'https://www.apollographql.com/docs/react/advanced/fragments.html#fragment-matcher',
      );
    }

    return 'heuristic';
  }
}
github apollographql / apollo-client / packages / apollo-client / src / core / QueryManager.ts View on Github external
function invoke(method: 'next' | 'error', argument: any) {
      if (observer[method]) {
        try {
          observer[method]!(argument);
        } catch (e) {
          invariant.error(e);
        }
      } else if (method === 'error') {
        invariant.error(argument);
      }
    }
github apollographql / apollo-client / packages / apollo-client / src / core / QueryManager.ts View on Github external
function invoke(method: 'next' | 'error', argument: any) {
      if (observer[method]) {
        try {
          observer[method]!(argument);
        } catch (e) {
          invariant.error(e);
        }
      } else if (method === 'error') {
        invariant.error(argument);
      }
    }
github apollographql / apollo-client / packages / apollo-client / src / core / ObservableQuery.ts View on Github external
error: (err: any) => {
          if (options.onError) {
            options.onError(err);
            return;
          }
          invariant.error('Unhandled GraphQL subscription error', err);
        },
      });
github apollographql / apollo-client / packages / apollo-client / src / core / ObservableQuery.ts View on Github external
function defaultSubscriptionObserverErrorCallback(error: ApolloError) {
  invariant.error('Unhandled error', error.message, error.stack);
}

ts-invariant

TypeScript implementation of invariant(condition, message)

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis