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.3.2 to 2.3.3

26

ApolloClient.d.ts

@@ -8,7 +8,7 @@ import { ApolloLink, FetchResult, GraphQLRequest } from 'apollo-link';

import { Observable } from './util/Observable';
import { WatchQueryOptions, SubscriptionOptions, MutationOptions, ModifiableWatchQueryOptions, MutationBaseOptions } from './core/watchQueryOptions';
import { QueryOptions, WatchQueryOptions, SubscriptionOptions, MutationOptions, ModifiableWatchQueryOptions, MutationBaseOptions } from './core/watchQueryOptions';
import { DataStore } from './data/store';
export interface DefaultOptions {
watchQuery?: ModifiableWatchQueryOptions;
query?: ModifiableWatchQueryOptions;
query?: QueryOptions;
mutate?: MutationBaseOptions;

@@ -81,11 +81,11 @@ }

/**
* This resolves a single query according to the options specified and returns a
* {@link Promise} which is either resolved with the resulting data or rejected
* with an error.
* This resolves a single query according to the options specified and
* returns a {@link Promise} which is either resolved with the resulting data
* or rejected with an error.
*
* @param options An object of type {@link WatchQueryOptions} that allows us to describe
* how this query should be treated e.g. whether it is a polling query, whether it should hit the
* @param options An object of type {@link QueryOptions} that allows us to
* describe how this query should be treated e.g. whether it should hit the
* server at all or just resolve from the cache, etc.
*/
query<T>(options: WatchQueryOptions): Promise<ApolloQueryResult<T>>;
query<T>(options: QueryOptions): Promise<ApolloQueryResult<T>>;
/**

@@ -110,3 +110,3 @@ * This resolves a single mutation according to the options specified and returns a

*/
readQuery<T>(options: DataProxy.Query): T | null;
readQuery<T, TVariables = any>(options: DataProxy.Query<TVariables>): T | null;
/**

@@ -123,3 +123,3 @@ * Tries to read some data from the store in the shape of the provided

*/
readFragment<T>(options: DataProxy.Fragment): T | null;
readFragment<T, TVariables = any>(options: DataProxy.Fragment<TVariables>): T | null;
/**

@@ -130,3 +130,3 @@ * Writes some data in the shape of the provided GraphQL query directly to

*/
writeQuery(options: DataProxy.WriteQueryOptions): void;
writeQuery<TData = any, TVariables = any>(options: DataProxy.WriteQueryOptions<TData, TVariables>): void;
/**

@@ -143,3 +143,3 @@ * Writes some data in the shape of the provided GraphQL fragment directly to

*/
writeFragment(options: DataProxy.WriteFragmentOptions): void;
writeFragment<TData = any, TVariables = any>(options: DataProxy.WriteFragmentOptions<TData, TVariables>): void;
/**

@@ -155,3 +155,3 @@ * Sugar for writeQuery & writeFragment

*/
writeData(options: DataProxy.WriteDataOptions): void;
writeData<TData = any>(options: DataProxy.WriteDataOptions<TData>): void;
__actionHookForDevTools(cb: () => any): void;

@@ -158,0 +158,0 @@ __requestRaw(payload: GraphQLRequest): Observable<ExecutionResult>;

@@ -131,8 +131,8 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {

/**
* This resolves a single query according to the options specified and returns a
* {@link Promise} which is either resolved with the resulting data or rejected
* with an error.
* This resolves a single query according to the options specified and
* returns a {@link Promise} which is either resolved with the resulting data
* or rejected with an error.
*
* @param options An object of type {@link WatchQueryOptions} that allows us to describe
* how this query should be treated e.g. whether it is a polling query, whether it should hit the
* @param options An object of type {@link QueryOptions} that allows us to
* describe how this query should be treated e.g. whether it should hit the
* server at all or just resolve from the cache, etc.

@@ -148,3 +148,4 @@ */

}
// XXX Overwriting options is probably not the best way to do this long term...
// XXX Overwriting options is probably not the best way to do this long
// term...
if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {

@@ -151,0 +152,0 @@ options = __assign({}, options, { fetchPolicy: 'cache-first' });

@@ -6,3 +6,3 @@ import { GraphQLError } from 'graphql';

import { ApolloError } from '../errors/ApolloError';
import { ApolloQueryResult } from './types';
import { ApolloQueryResult, OperationVariables } from './types';
import { ModifiableWatchQueryOptions, WatchQueryOptions, FetchMoreQueryOptions, SubscribeToMoreOptions, ErrorPolicy } from './watchQueryOptions';

@@ -18,20 +18,14 @@ import { QueryStoreValue } from '../data/queries';

};
export interface FetchMoreOptions {
updateQuery: (previousQueryResult: {
[key: string]: any;
}, options: {
fetchMoreResult?: {
[key: string]: any;
};
variables: {
[key: string]: any;
};
}) => Object;
export interface FetchMoreOptions<TData = any, TVariables = OperationVariables> {
updateQuery: (previousQueryResult: TData, options: {
fetchMoreResult?: TData;
variables?: TVariables;
}) => TData;
}
export interface UpdateQueryOptions {
variables?: Object;
export interface UpdateQueryOptions<TVariables> {
variables?: TVariables;
}
export declare const hasError: (storeValue: QueryStoreValue, policy?: ErrorPolicy) => true | Error | null | undefined;
export declare class ObservableQuery<T> extends Observable<ApolloQueryResult<T>> {
options: WatchQueryOptions;
export declare class ObservableQuery<TData = any, TVariables = OperationVariables> extends Observable<ApolloQueryResult<TData>> {
options: WatchQueryOptions<TVariables>;
queryId: string;

@@ -42,5 +36,3 @@ /**

*/
variables: {
[key: string]: any;
};
variables: TVariables;
private isCurrentlyPolling;

@@ -57,6 +49,6 @@ private shouldSubscribe;

scheduler: QueryScheduler<any>;
options: WatchQueryOptions;
options: WatchQueryOptions<TVariables>;
shouldSubscribe?: boolean;
});
result(): Promise<ApolloQueryResult<T>>;
result(): Promise<ApolloQueryResult<TData>>;
/**

@@ -68,10 +60,10 @@ * Return the result of the query from the local cache as well as some fetching status

*/
currentResult(): ApolloCurrentResult<T>;
getLastResult(): ApolloQueryResult<T>;
currentResult(): ApolloCurrentResult<TData>;
getLastResult(): ApolloQueryResult<TData>;
getLastError(): ApolloError;
resetLastResults(): void;
refetch(variables?: any): Promise<ApolloQueryResult<T>>;
fetchMore(fetchMoreOptions: FetchMoreQueryOptions & FetchMoreOptions): Promise<ApolloQueryResult<T>>;
subscribeToMore(options: SubscribeToMoreOptions): () => void;
setOptions(opts: ModifiableWatchQueryOptions): Promise<ApolloQueryResult<T>>;
refetch(variables?: TVariables): Promise<ApolloQueryResult<TData>>;
fetchMore<K extends keyof TVariables>(fetchMoreOptions: FetchMoreQueryOptions<TVariables, K> & FetchMoreOptions<TData, TVariables>): Promise<ApolloQueryResult<TData>>;
subscribeToMore(options: SubscribeToMoreOptions<TData, TVariables>): () => void;
setOptions(opts: ModifiableWatchQueryOptions): Promise<ApolloQueryResult<TData>>;
/**

@@ -97,4 +89,4 @@ * Update the variables of this observable query, and fetch the new results

*/
setVariables(variables: any, tryFetch?: boolean, fetchResults?: boolean): Promise<ApolloQueryResult<T>>;
updateQuery(mapFn: (previousQueryResult: any, options: UpdateQueryOptions) => any): void;
setVariables(variables: TVariables, tryFetch?: boolean, fetchResults?: boolean): Promise<ApolloQueryResult<TData>>;
updateQuery(mapFn: (previousQueryResult: TData, options: UpdateQueryOptions<TVariables>) => TData): void;
stopPolling(): void;

@@ -101,0 +93,0 @@ startPolling(pollInterval: number): void;

@@ -170,7 +170,7 @@ var __extends = (this && this.__extends) || (function () {

// update observable variables
this.variables = __assign({}, this.variables, variables);
this.variables = Object.assign({}, this.variables, variables);
}
if (!isEqual(this.options.variables, this.variables)) {
// Update the existing options with new variables
this.options.variables = __assign({}, this.options.variables, this.variables);
this.options.variables = Object.assign({}, this.options.variables, this.variables);
}

@@ -201,3 +201,3 @@ // Override fetchPolicy for this call only

// fetch the same query with a possibly new variables
combinedOptions = __assign({}, _this.options, fetchMoreOptions, { variables: __assign({}, _this.variables, fetchMoreOptions.variables) });
combinedOptions = __assign({}, _this.options, fetchMoreOptions, { variables: Object.assign({}, _this.variables, fetchMoreOptions.variables) });
}

@@ -260,3 +260,3 @@ combinedOptions.fetchPolicy = 'network-only';

var oldOptions = this.options;
this.options = __assign({}, this.options, opts);
this.options = Object.assign({}, this.options, opts);
if (opts.pollInterval) {

@@ -263,0 +263,0 @@ this.startPolling(opts.pollInterval);

@@ -9,3 +9,3 @@ import { ApolloLink, FetchResult } from 'apollo-link';

import { QueryStore } from '../data/queries';
import { WatchQueryOptions, SubscriptionOptions, MutationOptions } from './watchQueryOptions';
import { QueryOptions, WatchQueryOptions, SubscriptionOptions, MutationOptions } from './watchQueryOptions';
import { ObservableQuery } from './ObservableQuery';

@@ -51,3 +51,3 @@ import { QueryListener, ApolloQueryResult, FetchType } from './types';

watchQuery<T>(options: WatchQueryOptions, shouldSubscribe?: boolean): ObservableQuery<T>;
query<T>(options: WatchQueryOptions): Promise<ApolloQueryResult<T>>;
query<T>(options: QueryOptions): Promise<ApolloQueryResult<T>>;
generateQueryId(): string;

@@ -54,0 +54,0 @@ stopQueryInStore(queryId: string): void;

@@ -473,3 +473,4 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {

if (!options.query) {
throw new Error('query option is required. You must specify your GraphQL document in the query option.');
throw new Error('query option is required. You must specify your GraphQL document ' +
'in the query option.');
}

@@ -485,6 +486,2 @@ if (options.query.kind !== 'Document') {

}
if (typeof options.notifyOnNetworkStatusChange !== 'undefined') {
throw new Error('Cannot call "query" with "notifyOnNetworkStatusChange" option. Only "watchQuery" has that option.');
}
options.notifyOnNetworkStatusChange = false;
var requestId = this.idCounter;

@@ -491,0 +488,0 @@ return new Promise(function (resolve, reject) {

@@ -6,2 +6,5 @@ import { DocumentNode, GraphQLError } from 'graphql';

export declare type QueryListener = (queryStoreValue: QueryStoreValue, newData?: any) => void;
export declare type OperationVariables = {
[key: string]: any;
};
export declare type PureQueryOptions = {

@@ -8,0 +11,0 @@ query: DocumentNode;

@@ -5,3 +5,3 @@ import { DocumentNode, ExecutionResult } from 'graphql';

import { MutationQueryReducersMap } from './types';
import { PureQueryOptions } from './types';
import { PureQueryOptions, OperationVariables } from './types';
/**

@@ -25,5 +25,5 @@ * fetchPolicy determines where the client may return a result from. The options are:

/**
* We can change these options to an ObservableQuery
* Common options shared across all query interfaces.
*/
export interface ModifiableWatchQueryOptions {
export interface QueryBaseOptions<TVariables = OperationVariables> {
/**

@@ -33,11 +33,4 @@ * A map going from variable name to variable value, where the variables are used

*/
variables?: {
[key: string]: any;
};
variables?: TVariables;
/**
* The time interval (in milliseconds) on which this query should be
* refetched from the server.
*/
pollInterval?: number;
/**
* Specifies the {@link FetchPolicy} to be used for this query

@@ -54,11 +47,7 @@ */

fetchResults?: boolean;
/**
* Whether or not updates to the network status should trigger next on the observer of this query
*/
notifyOnNetworkStatusChange?: boolean;
}
/**
* The argument to a query
* Query options.
*/
export interface WatchQueryOptions extends ModifiableWatchQueryOptions {
export interface QueryOptions<TVariables = OperationVariables> extends QueryBaseOptions<TVariables> {
/**

@@ -79,22 +68,35 @@ * A GraphQL document that consists of a single query to be sent down to the

}
export interface FetchMoreQueryOptions {
/**
* We can change these options to an ObservableQuery
*/
export interface ModifiableWatchQueryOptions<TVariables = OperationVariables> extends QueryBaseOptions<TVariables> {
/**
* The time interval (in milliseconds) on which this query should be
* refetched from the server.
*/
pollInterval?: number;
/**
* Whether or not updates to the network status should trigger next on the observer of this query
*/
notifyOnNetworkStatusChange?: boolean;
}
/**
* Watched query options.
*/
export interface WatchQueryOptions<TVariables = OperationVariables> extends QueryOptions<TVariables>, ModifiableWatchQueryOptions<TVariables> {
}
export interface FetchMoreQueryOptions<TVariables, K extends keyof TVariables> {
query?: DocumentNode;
variables?: {
[key: string]: any;
};
variables?: Pick<TVariables, K>;
}
export declare type UpdateQueryFn = (previousQueryResult: Object, options: {
export declare type UpdateQueryFn<TData = any, TVariables = OperationVariables> = (previousQueryResult: TData, options: {
subscriptionData: {
data: any;
data: TData;
};
variables?: {
[key: string]: any;
};
}) => Object;
export declare type SubscribeToMoreOptions = {
variables?: TVariables;
}) => TData;
export declare type SubscribeToMoreOptions<TData = any, TVariables = OperationVariables> = {
document: DocumentNode;
variables?: {
[key: string]: any;
};
updateQuery?: UpdateQueryFn;
variables?: TVariables;
updateQuery?: UpdateQueryFn<TData, TVariables>;
onError?: (error: Error) => void;

@@ -101,0 +103,0 @@ };

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

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

"@types/zen-observable": "^0.5.3",
"apollo-cache": "^1.1.9",
"apollo-cache": "^1.1.10",
"apollo-link": "^1.0.0",
"apollo-link-dedup": "^1.0.0",
"apollo-utilities": "^1.0.13",
"apollo-utilities": "^1.0.14",
"symbol-observable": "^1.0.2",

@@ -46,3 +46,3 @@ "zen-observable": "^0.8.0"

"@types/node": "10.1.3",
"apollo-cache-inmemory": "^1.2.2",
"apollo-cache-inmemory": "^1.2.3",
"benchmark": "2.1.4",

@@ -49,0 +49,0 @@ "browserify": "15.2.0",

@@ -77,3 +77,3 @@ # [Apollo Client](https://www.apollographql.com/client/) [![npm version](https://badge.fury.io/js/apollo-client.svg)](https://badge.fury.io/js/apollo-client) [![Get on Slack](https://img.shields.io/badge/slack-join-orange.svg)](http://www.apollostack.com/#slack) [![Open Source Helpers](https://www.codetriage.com/apollographql/apollo-client/badges/users.svg)](https://www.codetriage.com/apollographql/apollo-client)

To learn more about all of the features available to you through the `apollo-client` package, be sure to read through the (**`apollo-client` API reference**)[https://www.apollographql.com/docs/react/api/apollo-client.html].
To learn more about all of the features available to you through the `apollo-client` package, be sure to read through the [**`apollo-client` API reference**](https://www.apollographql.com/docs/react/api/apollo-client.html).

@@ -95,3 +95,3 @@ [`ApolloClient`]: https://www.apollographql.com/docs/react/api/apollo-client.html

- [Blaze](http://github.com/Swydo/blaze-apollo)
- [Vanilla JS](http://apollographql.com/docs/react/reference)
- [Vanilla JS](https://www.apollographql.com/docs/react/api/apollo-client.html)
- [Next.js](https://github.com/zeit/next.js/tree/master/examples/with-apollo)

@@ -98,0 +98,0 @@

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

export declare const version = "2.3.2";
export declare const version = "2.3.3";

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

exports.version = "2.3.2"
exports.version = "2.3.3"

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

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