New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

apollo-client

Package Overview
Dependencies
Maintainers
2
Versions
309
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-client - npm Package Compare versions

Comparing version 0.4.10 to 0.4.11

util/errorHandling.d.ts

1

index.d.ts

@@ -86,2 +86,3 @@ import { NetworkInterface, createNetworkInterface, addQueryMerging } from './networkInterface';

};
refetchQueries?: string[];
}) => Promise<{

@@ -88,0 +89,0 @@ data: any;

2

ObservableQuery.d.ts

@@ -17,3 +17,3 @@ import { WatchQueryOptions, FetchMoreQueryOptions } from './watchQueryOptions';

options: WatchQueryOptions;
private queryId;
queryId: string;
private scheduler;

@@ -20,0 +20,0 @@ private queryManager;

@@ -8,2 +8,3 @@ "use strict";

var Observable_1 = require('./util/Observable');
var errorHandling_1 = require('./util/errorHandling');
var assign = require('lodash.assign');

@@ -46,3 +47,4 @@ var ObservableQuery = (function (_super) {

this.refetch = function (variables) {
variables = variables || _this.options.variables;
variables = variables || _this.options.variables ?
assign({}, _this.options.variables, variables) : undefined;
if (_this.options.noFetch) {

@@ -65,4 +67,7 @@ throw new Error('noFetch option should not use query refetch.');

else {
combinedOptions =
assign({}, _this.options, fetchMoreOptions);
var variables = _this.options.variables || fetchMoreOptions.variables ?
assign({}, _this.options.variables, fetchMoreOptions.variables) : undefined;
combinedOptions = assign({}, _this.options, fetchMoreOptions, {
variables: variables,
});
}

@@ -77,12 +82,15 @@ combinedOptions = assign({}, combinedOptions, {

var _a = _this.queryManager.getQueryWithPreviousResult(_this.queryId), previousResult = _a.previousResult, queryVariables = _a.queryVariables, querySelectionSet = _a.querySelectionSet, _b = _a.queryFragments, queryFragments = _b === void 0 ? [] : _b;
_this.queryManager.store.dispatch({
type: 'APOLLO_UPDATE_QUERY_RESULT',
newResult: reducer(previousResult, {
fetchMoreResult: fetchMoreResult,
var newResult = errorHandling_1.tryFunctionOrLogError(function () { return reducer(previousResult, {
fetchMoreResult: fetchMoreResult,
queryVariables: queryVariables,
}); });
if (newResult) {
_this.queryManager.store.dispatch({
type: 'APOLLO_UPDATE_QUERY_RESULT',
newResult: newResult,
queryVariables: queryVariables,
}),
queryVariables: queryVariables,
querySelectionSet: querySelectionSet,
queryFragments: queryFragments,
});
querySelectionSet: querySelectionSet,
queryFragments: queryFragments,
});
}
});

@@ -89,0 +97,0 @@ };

{
"name": "apollo-client",
"version": "0.4.10",
"version": "0.4.11",
"description": "A simple yet functional GraphQL client.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -30,2 +30,3 @@ import { NetworkInterface } from './networkInterface';

private observableQueries;
private queryIdsByName;
constructor({networkInterface, store, reduxRootKey, queryTransformer, shouldBatch, batchInterval}: {

@@ -40,3 +41,3 @@ networkInterface: NetworkInterface;

broadcastNewStore(store: any): void;
mutate({mutation, variables, resultBehaviors, fragments, optimisticResponse, updateQueries}: {
mutate({mutation, variables, resultBehaviors, fragments, optimisticResponse, updateQueries, refetchQueries}: {
mutation: Document;

@@ -48,2 +49,3 @@ variables?: Object;

updateQueries?: MutationQueryReducersMap;
refetchQueries?: string[];
}): Promise<ApolloQueryResult>;

@@ -78,2 +80,3 @@ queryListenerForObserver(queryId: string, options: WatchQueryOptions, observer: Observer<ApolloQueryResult>): QueryListener;

private fetchQueryOverInterface(queryId, options, network);
private refetchQueryByName(queryName);
private isDifferentResult(queryId, result);

@@ -80,0 +83,0 @@ private broadcastQueries();

@@ -13,2 +13,3 @@ "use strict";

var scheduler_1 = require('./scheduler');
var errorHandling_1 = require('./util/errorHandling');
var errors_1 = require('./errors');

@@ -39,2 +40,3 @@ var ObservableQuery_1 = require('./ObservableQuery');

this.observableQueries = {};
this.queryIdsByName = {};
if (this.store['subscribe']) {

@@ -58,3 +60,3 @@ var currentStoreData_1;

var _this = this;
var mutation = _a.mutation, variables = _a.variables, _b = _a.resultBehaviors, resultBehaviors = _b === void 0 ? [] : _b, _c = _a.fragments, fragments = _c === void 0 ? [] : _c, optimisticResponse = _a.optimisticResponse, updateQueries = _a.updateQueries;
var mutation = _a.mutation, variables = _a.variables, _b = _a.resultBehaviors, resultBehaviors = _b === void 0 ? [] : _b, _c = _a.fragments, fragments = _c === void 0 ? [] : _c, optimisticResponse = _a.optimisticResponse, updateQueries = _a.updateQueries, _d = _a.refetchQueries, refetchQueries = _d === void 0 ? [] : _d;
var mutationId = this.generateQueryId();

@@ -103,2 +105,3 @@ mutation = getFromAST_1.addFragmentsToDocument(mutation, fragments);

});
refetchQueries.forEach(function (name) { _this.refetchQueryByName(name); });
resolve(result);

@@ -233,2 +236,8 @@ })

this.observableQueries[queryId] = { observableQuery: observableQuery, subscriptions: [] };
var queryDef = getFromAST_1.getQueryDefinition(observableQuery.options.query);
if (queryDef.name && queryDef.name.value) {
var queryName = getFromAST_1.getQueryDefinition(observableQuery.options.query).name.value;
this.queryIdsByName[queryName] = this.queryIdsByName[queryName] || [];
this.queryIdsByName[queryName].push(observableQuery.queryId);
}
};

@@ -247,3 +256,8 @@ QueryManager.prototype.addQuerySubscription = function (queryId, querySubscription) {

QueryManager.prototype.removeObservableQuery = function (queryId) {
var observableQuery = this.observableQueries[queryId].observableQuery;
var queryName = getFromAST_1.getQueryDefinition(observableQuery.options.query).name.value;
delete this.observableQueries[queryId];
this.queryIdsByName[queryName] = this.queryIdsByName[queryName].filter(function (val) {
return !(observableQuery.queryId === val);
});
};

@@ -319,29 +333,24 @@ QueryManager.prototype.resetStore = function () {

var resultBehaviors = [];
var queryIdsByName = {};
Object.keys(this.observableQueries).forEach(function (queryId) {
var observableQuery = _this.observableQueries[queryId].observableQuery;
var queryName = getFromAST_1.getQueryDefinition(observableQuery.options.query).name.value;
queryIdsByName[queryName] =
queryIdsByName[queryName] || [];
queryIdsByName[queryName].push(queryId);
});
Object.keys(updateQueries).forEach(function (queryName) {
var reducer = updateQueries[queryName];
var queries = queryIdsByName[queryName];
if (!queries) {
var queryIds = _this.queryIdsByName[queryName];
if (!queryIds) {
return;
}
queries.forEach(function (queryId) {
queryIds.forEach(function (queryId) {
var _a = _this.getQueryWithPreviousResult(queryId, isOptimistic), previousResult = _a.previousResult, queryVariables = _a.queryVariables, querySelectionSet = _a.querySelectionSet, queryFragments = _a.queryFragments;
resultBehaviors.push({
type: 'QUERY_RESULT',
newResult: reducer(previousResult, {
mutationResult: mutationResult,
queryName: queryName,
var newResult = errorHandling_1.tryFunctionOrLogError(function () { return reducer(previousResult, {
mutationResult: mutationResult,
queryName: queryName,
queryVariables: queryVariables,
}); });
if (newResult) {
resultBehaviors.push({
type: 'QUERY_RESULT',
newResult: newResult,
queryVariables: queryVariables,
}),
queryVariables: queryVariables,
querySelectionSet: querySelectionSet,
queryFragments: queryFragments,
});
querySelectionSet: querySelectionSet,
queryFragments: queryFragments,
});
}
});

@@ -482,2 +491,8 @@ });

};
QueryManager.prototype.refetchQueryByName = function (queryName) {
var _this = this;
this.queryIdsByName[queryName].forEach(function (queryId) {
_this.observableQueries[queryId].observableQuery.refetch();
});
};
QueryManager.prototype.isDifferentResult = function (queryId, result) {

@@ -484,0 +499,0 @@ return !isEqual(this.queryResults[queryId], result);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc