Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
: onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors) {
graphQLErrors.forEach(({ message, locations, path }) =>
// tslint:disable-next-line
invariant.warn(
`[GraphQL error]: Message: ${message}, Location: ` +
`${locations}, Path: ${path}`,
),
);
}
if (networkError) {
// tslint:disable-next-line
invariant.warn(`[Network error]: ${networkError}`);
}
});
constructor(config: InMemoryCacheConfig = {}) {
super();
this.config = { ...defaultConfig, ...config };
// backwards compat
if ((this.config as any).customResolvers) {
invariant.warn(
'customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version.',
);
this.config.cacheRedirects = (this.config as any).customResolvers;
}
if ((this.config as any).cacheResolvers) {
invariant.warn(
'cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version.',
);
this.config.cacheRedirects = (this.config as any).cacheResolvers;
}
this.addTypename = !!this.config.addTypename;
// Passing { resultCaching: false } in the InMemoryCache constructor options
// will completely disable dependency tracking, which will improve memory
// without having all of the selection set values available.
// This is because the @client field values might have already
// been written to the cache separately (e.g. via Apollo
// Cache's `writeData` capabilities). Because of this, we'll
// skip the missing field warning for fields with @client
// directives.
isClient = selection.directives.some(
directive => directive.name && directive.name.value === 'client',
);
}
if (!isDefered && !isClient && context.fragmentMatcherFunction) {
// XXX We'd like to throw an error, but for backwards compatibility's sake
// we just print a warning for the time being.
//throw new WriteError(`Missing field ${resultFieldKey} in ${JSON.stringify(result, null, 2).substring(0, 100)}`);
invariant.warn(
`Missing field ${resultFieldKey} in ${JSON.stringify(
result,
null,
2,
).substring(0, 100)}`,
);
}
}
} else {
// This is not a field, so it must be a fragment, either inline or named
let fragment: InlineFragmentNode | FragmentDefinitionNode;
if (isInlineFragment(selection)) {
fragment = selection;
} else {
// Named fragment
}
const { __typename = isRootQuery && 'Query' } = obj;
if (!__typename) {
if (shouldWarn()) {
invariant.warn(`You're using fragments in your queries, but either don't have the addTypename:
true option set in Apollo Client, or you are trying to write a fragment to the store without the __typename.
Please turn on the addTypename option and include __typename when writing fragments so that Apollo Client
can accurately match fragments.`);
invariant.warn(
'Could not find __typename on Fragment ',
typeCondition,
obj,
);
invariant.warn(
`DEPRECATION WARNING: using fragments without __typename is unsupported behavior ` +
`and will be removed in future versions of Apollo client. You should fix this and set addTypename to true now.`,
);
}
return 'heuristic';
}
if (__typename === typeCondition) {
return true;
}
// 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.
graphQLErrors.map(({ message, locations, path }) =>
// tslint:disable-next-line
invariant.warn(
`[GraphQL error]: Message: ${message}, Location: ` +
`${locations}, Path: ${path}`,
),
);
public initQueryManager(): QueryManager {
invariant.warn(
'Calling the initQueryManager method is no longer necessary, ' +
'and it will be removed from ApolloClient in version 3.0.',
);
return this.queryManager;
}
next: data => {
if (completed) {
invariant.warn(
`Promise Wrapper does not support multiple results from Observable`,
);
} else {
completed = true;
resolve(data);
}
},
error: reject,
next: data => {
if (completed) {
invariant.warn(
`Promise Wrapper does not support multiple results from Observable`,
);
} else {
completed = true;
resolve(data);
}
},
error: reject,
public static concat(
first: ApolloLink | RequestHandler,
second: ApolloLink | RequestHandler,
) {
const firstLink = toLink(first);
if (isTerminating(firstLink)) {
invariant.warn(
new LinkError(
`You are calling concat on a terminating link, which will have no effect`,
firstLink,
),
);
return firstLink;
}
const nextLink = toLink(second);
if (isTerminating(nextLink)) {
return new ApolloLink(
operation =>
firstLink.request(
operation,
op => nextLink.request(op) || Observable.of(),
) || Observable.of(),
next: data => {
if (completed) {
invariant.warn(
`Promise Wrapper does not support multiple results from Observable`,
);
} else {
completed = true;
resolve(data);
}
},
error: reject,