Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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';
}
}
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);
}
}
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);
}
}
error: (err: any) => {
if (options.onError) {
options.onError(err);
return;
}
invariant.error('Unhandled GraphQL subscription error', err);
},
});
function defaultSubscriptionObserverErrorCallback(error: ApolloError) {
invariant.error('Unhandled error', error.message, error.stack);
}