Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public markMutationResult(mutation: {
mutationId: string;
result: ExecutionResult;
document: DocumentNode;
variables: any;
updateQueries: { [queryId: string]: QueryWithUpdater };
update: ((proxy: DataProxy, mutationResult: Object) => void) | undefined;
}) {
// Incorporate the result from this mutation into the store
if (!graphQLResultHasError(mutation.result)) {
const cacheWrites: Cache.WriteOptions[] = [{
result: mutation.result.data,
dataId: 'ROOT_MUTATION',
query: mutation.document,
variables: mutation.variables,
}];
const { updateQueries } = mutation;
if (updateQueries) {
Object.keys(updateQueries).forEach(id => {
const { query, updater } = updateQueries[id];
// Read the current query result from the store.
const { result: currentQueryResult, complete } = this.cache.diff({
query: query.document,
variables: query.variables,
error: (err) => {
resolve();
error = err;
unsubscribeAll();
if (graphQLResultHasError(err) || err.graphQLErrors) {
// send error to observable, unsubscribe all, do not enqueue
observer.error(err);
return;
}
enqueueAgain();
}
});
next(result: ExecutionResult) {
if (graphQLResultHasError(result) && errorPolicy === 'none') {
error = new ApolloError({
graphQLErrors: result.errors,
});
return;
}
self.mutationStore.markMutationResult(mutationId);
if (fetchPolicy !== 'no-cache') {
self.dataStore.markMutationResult({
mutationId,
result,
document: mutation,
variables,
updateQueries: generateUpdateQueriesInfo(),
update: updateWithProxyFn,
public markQueryResult(
result: ExecutionResult,
document: DocumentNode,
variables: any,
fetchMoreForQueryId: string | undefined,
ignoreErrors: boolean = false,
) {
let writeWithErrors = !graphQLResultHasError(result);
if (ignoreErrors && graphQLResultHasError(result) && result.data) {
writeWithErrors = true;
}
if (!fetchMoreForQueryId && writeWithErrors) {
this.cache.write({
result: result.data,
dataId: 'ROOT_QUERY',
query: document,
variables: variables,
});
}
}
public markQueryResult(
result: ExecutionResult,
document: DocumentNode,
variables: any,
fetchMoreForQueryId: string | undefined,
ignoreErrors: boolean = false,
) {
let writeWithErrors = !graphQLResultHasError(result);
if (ignoreErrors && graphQLResultHasError(result) && result.data) {
writeWithErrors = true;
}
if (!fetchMoreForQueryId && writeWithErrors) {
this.cache.write({
result: result.data,
dataId: 'ROOT_QUERY',
query: document,
variables: variables,
});
}
}
public markQueryResult(
result: ExecutionResult,
document: DocumentNode,
variables: any,
fetchMoreForQueryId: string | undefined,
ignoreErrors: boolean = false,
) {
let writeWithErrors = !graphQLResultHasError(result);
if (ignoreErrors && graphQLResultHasError(result) && result.data) {
writeWithErrors = true;
}
if (!fetchMoreForQueryId && writeWithErrors) {
this.cache.write({
result: result.data,
dataId: 'ROOT_QUERY',
query: document,
variables: variables,
});
}
}
).map(result => {
if (!fetchPolicy || fetchPolicy !== 'no-cache') {
this.dataStore.markSubscriptionResult(
result,
query,
variables,
);
this.broadcastQueries();
}
if (graphQLResultHasError(result)) {
throw new ApolloError({
graphQLErrors: result.errors,
});
}
return result;
});
DataStore.prototype.markMutationResult = function (mutation) {
var _this = this;
if (!graphQLResultHasError(mutation.result)) {
var cacheWrites_1 = [];
cacheWrites_1.push({
result: mutation.result.data,
dataId: 'ROOT_MUTATION',
query: mutation.document,
variables: mutation.variables,
});
if (mutation.updateQueries) {
Object.keys(mutation.updateQueries)
.filter(function (id) { return mutation.updateQueries[id]; })
.forEach(function (queryId) {
var _a = mutation.updateQueries[queryId], query = _a.query, updater = _a.updater;
var _b = _this.cache.diff({
query: query.document,
variables: query.variables,
returnPartialData: true,
public markQueryResult(
result: ExecutionResult,
document: DocumentNode,
variables: any,
fetchMoreForQueryId: string | undefined,
ignoreErrors: boolean = false,
) {
let writeWithErrors = !graphQLResultHasError(result);
if (ignoreErrors && graphQLResultHasError(result) && result.data) {
writeWithErrors = true;
}
if (!fetchMoreForQueryId && writeWithErrors) {
this.cache.write({
result: result.data,
dataId: 'ROOT_QUERY',
query: document,
variables: variables,
});
}
}