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
8
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 2.4.10 to 2.4.11

scheduler/scheduler.d.ts

5

ApolloClient.d.ts
import { ApolloLink, FetchResult, GraphQLRequest } from 'apollo-link';
import { ExecutionResult } from 'graphql';
import { ApolloCache, DataProxy } from 'apollo-cache';
import { QueryManager } from './core/QueryManager';
import { ApolloQueryResult, OperationVariables } from './core/types';

@@ -29,3 +30,3 @@ import { ObservableQuery } from './core/ObservableQuery';

cache: ApolloCache<TCacheShape>;
private queryManager;
queryManager: QueryManager<TCacheShape> | undefined;
disableNetworkFetches: boolean;

@@ -53,2 +54,3 @@ version: string;

__requestRaw(payload: GraphQLRequest): Observable<ExecutionResult>;
initQueryManager(): QueryManager<TCacheShape>;
resetStore(): Promise<ApolloQueryResult<any>[] | null>;

@@ -61,5 +63,4 @@ clearStore(): Promise<void | null>;

restore(serializedState: TCacheShape): ApolloCache<TCacheShape>;
private initQueryManager;
private initProxy;
}
//# sourceMappingURL=ApolloClient.d.ts.map

58

ApolloClient.js

@@ -138,2 +138,31 @@ import * as tslib_1 from "tslib";

};
ApolloClient.prototype.initQueryManager = function () {
var _this = this;
if (!this.queryManager) {
this.queryManager = new QueryManager({
link: this.link,
store: this.store,
queryDeduplication: this.queryDeduplication,
ssrMode: this.ssrMode,
clientAwareness: this.clientAwareness,
onBroadcast: function () {
if (_this.devToolsHookCb) {
_this.devToolsHookCb({
action: {},
state: {
queries: _this.queryManager
? _this.queryManager.queryStore.getStore()
: {},
mutations: _this.queryManager
? _this.queryManager.mutationStore.getStore()
: {},
},
dataWithOptimisticResults: _this.cache.extract(true),
});
}
},
});
}
return this.queryManager;
};
ApolloClient.prototype.resetStore = function () {

@@ -188,31 +217,2 @@ var _this = this;

};
ApolloClient.prototype.initQueryManager = function () {
var _this = this;
if (!this.queryManager) {
this.queryManager = new QueryManager({
link: this.link,
store: this.store,
queryDeduplication: this.queryDeduplication,
ssrMode: this.ssrMode,
clientAwareness: this.clientAwareness,
onBroadcast: function () {
if (_this.devToolsHookCb) {
_this.devToolsHookCb({
action: {},
state: {
queries: _this.queryManager
? _this.queryManager.queryStore.getStore()
: {},
mutations: _this.queryManager
? _this.queryManager.mutationStore.getStore()
: {},
},
dataWithOptimisticResults: _this.cache.extract(true),
});
}
},
});
}
return this.queryManager;
};
ApolloClient.prototype.initProxy = function () {

@@ -219,0 +219,0 @@ if (!this.proxy) {

import { GraphQLError } from 'graphql';
import { NetworkStatus } from './networkStatus';
import { Observable } from '../util/Observable';
import { QueryScheduler } from '../scheduler/scheduler';
import { ApolloError } from '../errors/ApolloError';
import { QueryManager } from './QueryManager';
import { ApolloQueryResult, OperationVariables } from './types';

@@ -31,4 +31,6 @@ import { ModifiableWatchQueryOptions, WatchQueryOptions, FetchMoreQueryOptions, SubscribeToMoreOptions, ErrorPolicy } from './watchQueryOptions';

variables: TVariables;
private isCurrentlyPolling;
private shouldSubscribe;
private isTornDown;
private scheduler;
private queryManager;

@@ -40,4 +42,4 @@ private observers;

private lastError;
constructor({ queryManager, options, shouldSubscribe, }: {
queryManager: QueryManager<any>;
constructor({ scheduler, options, shouldSubscribe, }: {
scheduler: QueryScheduler<any>;
options: WatchQueryOptions<TVariables>;

@@ -44,0 +46,0 @@ shouldSubscribe?: boolean;

@@ -18,12 +18,14 @@ import * as tslib_1 from "tslib";

function ObservableQuery(_a) {
var queryManager = _a.queryManager, options = _a.options, _b = _a.shouldSubscribe, shouldSubscribe = _b === void 0 ? true : _b;
var scheduler = _a.scheduler, options = _a.options, _b = _a.shouldSubscribe, shouldSubscribe = _b === void 0 ? true : _b;
var _this = _super.call(this, function (observer) {
return _this.onSubscribe(observer);
}) || this;
_this.isCurrentlyPolling = false;
_this.isTornDown = false;
_this.options = options;
_this.variables = options.variables || {};
_this.queryId = queryManager.generateQueryId();
_this.queryId = scheduler.queryManager.generateQueryId();
_this.shouldSubscribe = shouldSubscribe;
_this.queryManager = queryManager;
_this.scheduler = scheduler;
_this.queryManager = scheduler.queryManager;
_this.observers = [];

@@ -255,4 +257,7 @@ _this.subscriptionHandles = [];

ObservableQuery.prototype.stopPolling = function () {
this.queryManager.stopPollingQuery(this.queryId);
this.options.pollInterval = undefined;
if (this.isCurrentlyPolling) {
this.scheduler.stopPollingQuery(this.queryId);
this.options.pollInterval = undefined;
this.isCurrentlyPolling = false;
}
};

@@ -264,4 +269,9 @@ ObservableQuery.prototype.startPolling = function (pollInterval) {

}
if (this.isCurrentlyPolling) {
this.scheduler.stopPollingQuery(this.queryId);
this.isCurrentlyPolling = false;
}
this.options.pollInterval = pollInterval;
this.queryManager.startPollingQuery(this.options, this.queryId);
this.isCurrentlyPolling = true;
this.scheduler.startPollingQuery(this.options, this.queryId);
};

@@ -301,3 +311,4 @@ ObservableQuery.prototype.onSubscribe = function (observer) {

}
this.queryManager.startPollingQuery(this.options, this.queryId);
this.isCurrentlyPolling = true;
this.scheduler.startPollingQuery(this.options, this.queryId);
}

@@ -319,3 +330,6 @@ var observer = {

this.isTornDown = true;
this.queryManager.stopPollingQuery(this.queryId);
if (this.isCurrentlyPolling) {
this.scheduler.stopPollingQuery(this.queryId);
this.isCurrentlyPolling = false;
}
this.subscriptionHandles.forEach(function (sub) { return sub.unsubscribe(); });

@@ -322,0 +336,0 @@ this.subscriptionHandles = [];

import { ApolloLink, FetchResult } from 'apollo-link';
import { DocumentNode } from 'graphql';
import { Cache } from 'apollo-cache';
import { QueryScheduler } from '../scheduler/scheduler';
import { Observer, Subscription, Observable } from '../util/Observable';

@@ -22,2 +23,3 @@ import { DataStore } from '../data/store';

export declare class QueryManager<TStore> {
scheduler: QueryScheduler<TStore>;
link: ApolloLink;

@@ -31,3 +33,2 @@ mutationStore: MutationStore;

private onBroadcast;
private ssrMode;
private idCounter;

@@ -81,13 +82,3 @@ private queries;

private buildOperationForLink;
checkInFlight(queryId: string): boolean;
pollingInfoByQueryId: Map<string, {
interval: number;
lastPollTimeMs: number;
options: WatchQueryOptions<OperationVariables>;
}>;
private nextPoll;
startPollingQuery(options: WatchQueryOptions, queryId: string, listener?: QueryListener): string;
stopPollingQuery(queryId: string): void;
private schedulePoll;
}
//# sourceMappingURL=QueryManager.d.ts.map

@@ -5,2 +5,3 @@ import * as tslib_1 from "tslib";

import { assign, getDefaultValues, getMutationDefinition, getOperationDefinition, getOperationName, getQueryDefinition, isProduction, hasDirectives, } from 'apollo-utilities';
import { QueryScheduler } from '../scheduler/scheduler';
import { isApolloError, ApolloError } from '../errors/ApolloError';

@@ -24,4 +25,2 @@ import { Observable } from '../util/Observable';

this.queryIdsByName = {};
this.pollingInfoByQueryId = new Map();
this.nextPoll = null;
this.link = link;

@@ -33,3 +32,3 @@ this.deduplicator = ApolloLink.from([new Deduplicator(), link]);

this.clientAwareness = clientAwareness;
this.ssrMode = ssrMode;
this.scheduler = new QueryScheduler({ queryManager: this, ssrMode: ssrMode });
}

@@ -391,3 +390,3 @@ QueryManager.prototype.mutate = function (_a) {

return new ObservableQuery({
queryManager: this,
scheduler: this.scheduler,
options: transformedOptions,

@@ -808,64 +807,2 @@ shouldSubscribe: shouldSubscribe,

};
QueryManager.prototype.checkInFlight = function (queryId) {
var query = this.queryStore.get(queryId);
return (query &&
query.networkStatus !== NetworkStatus.ready &&
query.networkStatus !== NetworkStatus.error);
};
QueryManager.prototype.startPollingQuery = function (options, queryId, listener) {
var pollInterval = options.pollInterval;
if (!pollInterval) {
throw new Error('Attempted to start a polling query without a polling interval.');
}
if (!this.ssrMode) {
this.pollingInfoByQueryId.set(queryId, {
interval: pollInterval,
lastPollTimeMs: Date.now() - 10,
options: tslib_1.__assign({}, options, { fetchPolicy: 'network-only' }),
});
if (listener) {
this.addQueryListener(queryId, listener);
}
this.schedulePoll(pollInterval);
}
return queryId;
};
QueryManager.prototype.stopPollingQuery = function (queryId) {
this.pollingInfoByQueryId.delete(queryId);
};
QueryManager.prototype.schedulePoll = function (timeLimitMs) {
var _this = this;
var now = Date.now();
if (this.nextPoll) {
if (timeLimitMs < this.nextPoll.time - now) {
clearTimeout(this.nextPoll.timeout);
}
else {
return;
}
}
this.nextPoll = {
time: now + timeLimitMs,
timeout: setTimeout(function () {
_this.nextPoll = null;
var nextTimeLimitMs = Infinity;
_this.pollingInfoByQueryId.forEach(function (info, queryId) {
if (info.interval < nextTimeLimitMs) {
nextTimeLimitMs = info.interval;
}
if (!_this.checkInFlight(queryId)) {
if (Date.now() - info.lastPollTimeMs >= info.interval) {
var updateLastPollTime = function () {
info.lastPollTimeMs = Date.now();
};
_this.fetchQuery(queryId, info.options, FetchType.poll).then(updateLastPollTime, updateLastPollTime);
}
}
});
if (isFinite(nextTimeLimitMs)) {
_this.schedulePoll(nextTimeLimitMs);
}
}, timeLimitMs),
};
};
return QueryManager;

@@ -872,0 +809,0 @@ }());

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

@@ -28,7 +28,8 @@ "main": "bundle.umd.js",

"@types/zen-observable": "^0.8.0",
"apollo-cache": "1.1.24",
"apollo-cache": "1.1.25",
"apollo-link": "^1.0.0",
"apollo-link-dedup": "^1.0.0",
"apollo-utilities": "1.1.1",
"apollo-utilities": "1.1.2",
"symbol-observable": "^1.0.2",
"tslib": "^1.9.3",
"zen-observable": "^0.8.0"

@@ -38,6 +39,3 @@ },

"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
},
"optionalDependencies": {
"@types/async": "2.0.50"
}
}

@@ -1,2 +0,2 @@

export declare const version = "2.4.10";
export declare const version = "2.4.11";
//# sourceMappingURL=version.d.ts.map

@@ -1,1 +0,1 @@

exports.version = "2.4.10"
exports.version = "2.4.11"

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 too big to display

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

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