Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@apollo/react-hooks

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apollo/react-hooks - npm Package Compare versions

Comparing version 0.1.0-beta.10 to 0.1.0-beta.11

lib/ssr/RenderPromises.d.ts

2

lib/data/MutationData.d.ts

@@ -17,3 +17,3 @@ import { ApolloContextValue, OperationVariables, ExecutionResult, MutationFunctionOptions, MutationResult } from '@apollo/react-common';

afterExecute(): () => void;
protected cleanup(): void;
cleanup(): void;
private runMutation;

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

import * as tslib_1 from "tslib";
import { ApolloError } from 'apollo-client';
import { isEqual } from 'apollo-utilities';
import { equal as isEqual } from '@wry/equality';
import { DocumentType } from '@apollo/react-common';

@@ -19,2 +19,3 @@ import { OperationData } from './OperationData';

var _this = this;
this.isMounted = true;
this.verifyDocumentType(this.getOptions().mutation, DocumentType.Mutation);

@@ -21,0 +22,0 @@ var runMutation = function (options) { return _this.runMutation(options); };

@@ -15,4 +15,4 @@ import { ApolloClient } from 'apollo-client';

abstract execute(...args: any): any;
abstract afterExecute(...args: any): () => void;
protected abstract cleanup(): void;
abstract afterExecute(...args: any): void | (() => void);
abstract cleanup(): void;
protected unmount(): void;

@@ -19,0 +19,0 @@ protected refreshClient(): {

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

import { isEqual } from 'apollo-utilities';
import { equal as isEqual } from '@wry/equality';
import { invariant } from 'ts-invariant';

@@ -6,3 +6,3 @@ import { parser, operationName } from '@apollo/react-common';

function OperationData(options, context) {
this.isMounted = true;
this.isMounted = false;
this.previousOptions = {};

@@ -9,0 +9,0 @@ this.context = {};

import { ApolloQueryResult } from 'apollo-client';
import { ApolloContextValue, QueryResult } from '@apollo/react-common';
import { QueryOptions } from '../types';
import { QueryOptions, QueryTuple } from '../types';
import { OperationData } from './OperationData';

@@ -9,2 +9,4 @@ export declare class QueryData<TData, TVariables> extends OperationData {

private forceUpdate;
private runLazy;
private lazyOptions?;
constructor({ options, context, forceUpdate }: {

@@ -16,5 +18,12 @@ options: QueryOptions<TData, TVariables>;

execute(): QueryResult<TData, TVariables>;
executeLazy(): QueryTuple<TData, TVariables>;
fetchData(): Promise<ApolloQueryResult<any>> | boolean;
afterExecute(): () => void;
protected cleanup(): void;
afterExecute({ lazy }?: {
lazy?: boolean;
}): () => void;
cleanup(): void;
getOptions(): any;
private runLazyQuery;
private getExecuteResult;
private getExecuteSsrResult;
private updateCurrentData;

@@ -21,0 +30,0 @@ private prepareObservableQueryOptions;

import * as tslib_1 from "tslib";
import { ApolloError, NetworkStatus } from 'apollo-client';
import { isEqual } from 'apollo-utilities';
import { equal as isEqual } from '@wry/equality';
import { DocumentType } from '@apollo/react-common';

@@ -13,2 +13,13 @@ import { OperationData } from './OperationData';

_this.currentObservable = {};
_this.runLazy = false;
_this.runLazyQuery = function (options) {
_this.runLazy = true;
_this.lazyOptions = options;
_this.forceUpdate();
};
_this.getExecuteResult = function () {
var result = _this.getQueryResult();
_this.startQuerySubscription();
return result;
};
_this.forceUpdate = forceUpdate;

@@ -18,3 +29,2 @@ return _this;

QueryData.prototype.execute = function () {
var _this = this;
this.refreshClient();

@@ -27,12 +37,19 @@ var _a = this.getOptions(), skip = _a.skip, query = _a.query;

this.updateObservableQuery();
if (!skip) {
if (this.isMounted)
this.startQuerySubscription();
}
var finish = function () { return _this.getQueryResult(); };
if (this.context && this.context.renderPromises) {
var result = this.context.renderPromises.addQueryPromise(this, finish);
return result || { loading: true, networkStatus: NetworkStatus.loading };
}
return finish();
return this.getExecuteSsrResult() || this.getExecuteResult();
};
QueryData.prototype.executeLazy = function () {
return !this.runLazy
? [
this.runLazyQuery,
{
loading: false,
networkStatus: NetworkStatus.ready,
called: false,
data: undefined
}
]
: [this.runLazyQuery, this.execute()];
};
QueryData.prototype.fetchData = function () {

@@ -52,8 +69,11 @@ if (this.getOptions().skip)

}
var result = this.currentObservable.query.getCurrentResult();
return result.loading ? obs.result() : false;
var currentResult = this.currentObservable.query.getCurrentResult();
return currentResult.loading ? obs.result() : false;
};
QueryData.prototype.afterExecute = function () {
QueryData.prototype.afterExecute = function (_a) {
var _b = (_a === void 0 ? {} : _a).lazy, lazy = _b === void 0 ? false : _b;
this.isMounted = true;
this.handleErrorOrCompleted();
if (!lazy || this.runLazy) {
this.handleErrorOrCompleted();
}
return this.unmount.bind(this);

@@ -63,5 +83,30 @@ };

this.removeQuerySubscription();
this.currentObservable.query = null;
this.previousData.result = null;
delete this.currentObservable.query;
delete this.previousData.result;
};
QueryData.prototype.getOptions = function () {
var options = _super.prototype.getOptions.call(this);
var lazyOptions = this.lazyOptions || {};
var updatedOptions = tslib_1.__assign({}, options, { variables: tslib_1.__assign({}, options.variables, lazyOptions.variables), context: tslib_1.__assign({}, options.context, lazyOptions.context) });
if (this.runLazy) {
delete updatedOptions.skip;
}
return updatedOptions;
};
QueryData.prototype.getExecuteSsrResult = function () {
var result;
var ssrLoading = {
loading: true,
networkStatus: NetworkStatus.loading,
called: true,
data: {}
};
if (this.context && this.context.renderPromises) {
result = this.context.renderPromises.addQueryPromise(this, this.getExecuteResult);
if (!result) {
result = ssrLoading;
}
}
return result;
};
QueryData.prototype.updateCurrentData = function () {

@@ -112,3 +157,3 @@ if (this.isMounted) {

var _this = this;
if (this.currentObservable.subscription)
if (this.currentObservable.subscription || this.getOptions().skip)
return;

@@ -153,3 +198,3 @@ var obsQuery = this.currentObservable.query;

if (this.getOptions().skip) {
result = tslib_1.__assign({}, result, { data: undefined, error: undefined, loading: false });
result = tslib_1.__assign({}, result, { data: undefined, error: undefined, loading: false, called: true });
}

@@ -164,3 +209,3 @@ else {

}
Object.assign(result, { loading: loading, networkStatus: networkStatus, error: error });
Object.assign(result, { loading: loading, networkStatus: networkStatus, error: error, called: true });
if (loading) {

@@ -167,0 +212,0 @@ var previousData = this.previousData.result

@@ -18,4 +18,4 @@ import { ApolloContextValue, SubscriptionResult } from '@apollo/react-common';

};
afterExecute(): () => void;
protected cleanup(): void;
afterExecute(): void;
cleanup(): void;
private initialize;

@@ -22,0 +22,0 @@ private startSubscription;

import * as tslib_1 from "tslib";
import { isEqual } from 'apollo-utilities';
import { equal as isEqual } from '@wry/equality';
import { OperationData } from './OperationData';

@@ -39,3 +39,2 @@ var SubscriptionData = (function (_super) {

this.isMounted = true;
return this.unmount.bind(this);
};

@@ -42,0 +41,0 @@ SubscriptionData.prototype.cleanup = function () {

export { ApolloProvider, ApolloConsumer, getApolloContext, resetApolloContext } from '@apollo/react-common';
export { useQuery } from './useQuery';
export { useLazyQuery } from './useLazyQuery';
export { useMutation } from './useMutation';
export { useSubscription } from './useSubscription';
export { useApolloClient } from './useApolloClient';
export { getMarkupFromTree, getDataFromTree } from './ssr/getDataFromTree';
export { renderToStringWithData } from './ssr/renderToStringWithData';
export { RenderPromises } from './ssr/RenderPromises';
export * from './types';
export { ApolloProvider, ApolloConsumer, getApolloContext, resetApolloContext } from '@apollo/react-common';
export { useQuery } from './useQuery';
export { useLazyQuery } from './useLazyQuery';
export { useMutation } from './useMutation';
export { useSubscription } from './useSubscription';
export { useApolloClient } from './useApolloClient';
export { getMarkupFromTree, getDataFromTree } from './ssr/getDataFromTree';
export { renderToStringWithData } from './ssr/renderToStringWithData';
export { RenderPromises } from './ssr/RenderPromises';
//# sourceMappingURL=index.js.map
exports.__esModule = true;
exports.getDataFromTree = getDataFromTree;
exports.getMarkupFromTree = getMarkupFromTree;
exports.renderToStringWithData = renderToStringWithData;
exports.useApolloClient = useApolloClient;
exports.useLazyQuery = useLazyQuery;
exports.useMutation = useMutation;
exports.useQuery = useQuery;
exports.useSubscription = useSubscription;
exports.resetApolloContext = exports.ApolloProvider = exports.ApolloConsumer = void 0;
exports.RenderPromises = exports.resetApolloContext = exports.ApolloProvider = exports.ApolloConsumer = void 0;

@@ -24,3 +22,3 @@ var _reactCommon = require("@apollo/react-common");

var _apolloUtilities = require("apollo-utilities");
var _equality = require("@wry/equality");

@@ -33,3 +31,3 @@ var _tsInvariant = require("ts-invariant");

function OperationData(options, context) {
this.isMounted = true;
this.isMounted = false;
this.previousOptions = {};

@@ -47,3 +45,3 @@ this.context = {};

OperationData.prototype.setOptions = function (newOptions) {
if (!(0, _apolloUtilities.isEqual)(this.options, newOptions)) {
if (!(0, _equality.equal)(this.options, newOptions)) {
this.previousOptions = this.options;

@@ -98,2 +96,19 @@ }

_this.currentObservable = {};
_this.runLazy = false;
_this.runLazyQuery = function (options) {
_this.runLazy = true;
_this.lazyOptions = options;
_this.forceUpdate();
};
_this.getExecuteResult = function () {
var result = _this.getQueryResult();
_this.startQuerySubscription();
return result;
};
_this.forceUpdate = forceUpdate;

@@ -104,4 +119,2 @@ return _this;

QueryData.prototype.execute = function () {
var _this = this;
this.refreshClient();

@@ -119,20 +132,13 @@

this.updateObservableQuery();
if (this.isMounted) this.startQuerySubscription();
return this.getExecuteSsrResult() || this.getExecuteResult();
};
if (!skip) {
this.startQuerySubscription();
}
var finish = function () {
return _this.getQueryResult();
};
if (this.context && this.context.renderPromises) {
var result = this.context.renderPromises.addQueryPromise(this, finish);
return result || {
loading: true,
networkStatus: _apolloClient.NetworkStatus.loading
};
}
return finish();
QueryData.prototype.executeLazy = function () {
return !this.runLazy ? [this.runLazyQuery, {
loading: false,
networkStatus: _apolloClient.NetworkStatus.ready,
called: false,
data: undefined
}] : [this.runLazyQuery, this.execute()];
};

@@ -168,9 +174,15 @@

var result = this.currentObservable.query.getCurrentResult();
return result.loading ? obs.result() : false;
var currentResult = this.currentObservable.query.getCurrentResult();
return currentResult.loading ? obs.result() : false;
};
QueryData.prototype.afterExecute = function () {
QueryData.prototype.afterExecute = function (_a) {
var _b = (_a === void 0 ? {} : _a).lazy,
lazy = _b === void 0 ? false : _b;
this.isMounted = true;
this.handleErrorOrCompleted();
if (!lazy || this.runLazy) {
this.handleErrorOrCompleted();
}
return this.unmount.bind(this);

@@ -181,6 +193,42 @@ };

this.removeQuerySubscription();
this.currentObservable.query = null;
this.previousData.result = null;
delete this.currentObservable.query;
delete this.previousData.result;
};
QueryData.prototype.getOptions = function () {
var options = _super.prototype.getOptions.call(this);
var lazyOptions = this.lazyOptions || {};
var updatedOptions = (0, _tslib.__assign)({}, options, {
variables: (0, _tslib.__assign)({}, options.variables, lazyOptions.variables),
context: (0, _tslib.__assign)({}, options.context, lazyOptions.context)
});
if (this.runLazy) {
delete updatedOptions.skip;
}
return updatedOptions;
};
QueryData.prototype.getExecuteSsrResult = function () {
var result;
var ssrLoading = {
loading: true,
networkStatus: _apolloClient.NetworkStatus.loading,
called: true,
data: {}
};
if (this.context && this.context.renderPromises) {
result = this.context.renderPromises.addQueryPromise(this, this.getExecuteResult);
if (!result) {
result = ssrLoading;
}
}
return result;
};
QueryData.prototype.updateCurrentData = function () {

@@ -241,3 +289,3 @@ if (this.isMounted) {

if (!(0, _apolloUtilities.isEqual)(newObservableQueryOptions, this.previousData.observableQueryOptions)) {
if (!(0, _equality.equal)(newObservableQueryOptions, this.previousData.observableQueryOptions)) {
this.previousData.observableQueryOptions = newObservableQueryOptions;

@@ -251,3 +299,3 @@ this.currentObservable.query.setOptions(newObservableQueryOptions).catch(function () {});

if (this.currentObservable.subscription) return;
if (this.currentObservable.subscription || this.getOptions().skip) return;
var obsQuery = this.currentObservable.query;

@@ -260,3 +308,3 @@ this.currentObservable.subscription = obsQuery.subscribe({

if (_this.previousData.result && _this.previousData.result.loading === loading && _this.previousData.result.networkStatus === networkStatus && (0, _apolloUtilities.isEqual)(_this.previousData.result.data, data || {})) {
if (_this.previousData.result && _this.previousData.result.loading === loading && _this.previousData.result.networkStatus === networkStatus && (0, _equality.equal)(_this.previousData.result.data, data || {})) {
return;

@@ -301,3 +349,4 @@ }

error: undefined,
loading: false
loading: false,
called: true
});

@@ -323,3 +372,4 @@ } else {

networkStatus: networkStatus,
error: error
error: error,
called: true
});

@@ -373,3 +423,3 @@

if (this.previousOptions && !this.previousData.loading && (0, _apolloUtilities.isEqual)(this.previousOptions.query, query) && (0, _apolloUtilities.isEqual)(this.previousOptions.variables, variables)) {
if (this.previousOptions && !this.previousData.loading && (0, _equality.equal)(this.previousOptions.query, query) && (0, _equality.equal)(this.previousOptions.variables, variables)) {
return;

@@ -396,3 +446,20 @@ }

function useQuery(query, options) {
function useDeepMemo(memoFn, key) {
var ref = (0, _react.useRef)();
if (!ref.current || !(0, _equality.equal)(key, ref.current.key)) {
ref.current = {
key: key,
value: memoFn()
};
}
return ref.current.value;
}
function useBaseQuery(query, options, lazy) {
if (lazy === void 0) {
lazy = false;
}
var context = (0, _react.useContext)((0, _reactCommon.getApolloContext)());

@@ -403,3 +470,3 @@

}, 0),
_ignored = _a[0],
tick = _a[0],
forceUpdate = _a[1];

@@ -414,23 +481,37 @@

function getQueryDataRef() {
if (!queryDataRef.current) {
queryDataRef.current = new QueryData({
options: updatedOptions,
context: context,
forceUpdate: forceUpdate
});
}
return queryDataRef.current;
if (!queryDataRef.current) {
queryDataRef.current = new QueryData({
options: updatedOptions,
context: context,
forceUpdate: forceUpdate
});
}
var queryData = getQueryDataRef();
var queryData = queryDataRef.current;
queryData.setOptions(updatedOptions);
queryData.context = context;
var memo = {
options: updatedOptions,
context: context,
tick: tick
};
var result = useDeepMemo(function () {
return lazy ? queryData.executeLazy() : queryData.execute();
}, memo);
(0, _react.useEffect)(function () {
return queryData.afterExecute();
});
return queryData.execute();
return queryData.afterExecute({
lazy: lazy
});
}, [result]);
return result;
}
function useQuery(query, options) {
return useBaseQuery(query, options, false);
}
function useLazyQuery(query, options) {
return useBaseQuery(query, options, true);
}
var MutationData = function (_super) {

@@ -458,2 +539,3 @@ (0, _tslib.__extends)(MutationData, _super);

this.isMounted = true;
this.verifyDocumentType(this.getOptions().mutation, _reactCommon.DocumentType.Mutation);

@@ -586,3 +668,3 @@

MutationData.prototype.updateResult = function (result) {
if (this.isMounted && (!this.previousResult || !(0, _apolloUtilities.isEqual)(this.previousResult, result))) {
if (this.isMounted && (!this.previousResult || !(0, _equality.equal)(this.previousResult, result))) {
this.setResult(result);

@@ -666,3 +748,3 @@ this.previousResult = result;

if (shouldResubscribe !== false && this.previousOptions && Object.keys(this.previousOptions).length > 0 && (this.previousOptions.subscription !== this.getOptions().subscription || !(0, _apolloUtilities.isEqual)(this.previousOptions.variables, this.getOptions().variables))) {
if (shouldResubscribe !== false && this.previousOptions && Object.keys(this.previousOptions).length > 0 && (this.previousOptions.subscription !== this.getOptions().subscription || !(0, _equality.equal)(this.previousOptions.variables, this.getOptions().variables))) {
this.endSubscription();

@@ -683,3 +765,2 @@ delete this.currentObservable.query;

this.isMounted = true;
return this.unmount.bind(this);
};

@@ -799,2 +880,5 @@

});
(0, _react.useEffect)(function () {
return subscriptionData.cleanup.bind(subscriptionData);
}, []);
return subscriptionData.execute(result);

@@ -873,42 +957,5 @@ }

return RenderPromises;
}();
}();
function getDataFromTree(tree, context) {
if (context === void 0) {
context = {};
}
return getMarkupFromTree({
tree: tree,
context: context,
renderFunction: require('react-dom/server').renderToStaticMarkup
});
}
function getMarkupFromTree(_a) {
var tree = _a.tree,
_b = _a.context,
context = _b === void 0 ? {} : _b,
_c = _a.renderFunction,
renderFunction = _c === void 0 ? require('react-dom/server').renderToStaticMarkup : _c;
var renderPromises = new RenderPromises();
function process() {
var ApolloContext = (0, _reactCommon.getApolloContext)();
var html = renderFunction(_react.default.createElement(ApolloContext.Provider, {
value: (0, _tslib.__assign)({}, context, {
renderPromises: renderPromises
})
}, tree));
return renderPromises.hasPromises() ? renderPromises.consumeAndAwaitPromises().then(process) : html;
}
return Promise.resolve().then(process);
}
function renderToStringWithData(component) {
return getMarkupFromTree({
tree: component,
renderFunction: require('react-dom/server').renderToString
});
}
exports.RenderPromises = RenderPromises;

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

exports.__esModule=!0,exports.getDataFromTree=function(t,e){void 0===e&&(e={});return l({tree:t,context:e,renderFunction:require("react-dom/server").renderToStaticMarkup})},exports.getMarkupFromTree=l,exports.renderToStringWithData=function(t){return l({tree:t,renderFunction:require("react-dom/server").renderToString})},exports.useApolloClient=function(){var e=r.default.useContext((0,t.getApolloContext)()).client;return(0,o.invariant)(e,1),e},exports.useMutation=function(i,s){var o=(0,r.useContext)((0,t.getApolloContext)()),n=(0,r.useState)({called:!1,loading:!1}),u=n[0],p=n[1],c=s?(0,e.__assign)({},s,{mutation:i}):{mutation:i},l=(0,r.useRef)();var h=function(){l.current||(l.current=new a({options:c,context:o,result:u,setResult:p}));return l.current}();return h.setOptions(c),h.context=o,(0,r.useEffect)(function(){return h.afterExecute()}),h.execute(u)},exports.useQuery=function(i,s){var o=(0,r.useContext)((0,t.getApolloContext)()),n=(0,r.useReducer)(function(t){return t+1},0),a=(n[0],n[1]),p=s?(0,e.__assign)({},s,{query:i}):{query:i},c=(0,r.useRef)();var l=function(){c.current||(c.current=new u({options:p,context:o,forceUpdate:a}));return c.current}();return l.setOptions(p),l.context=o,(0,r.useEffect)(function(){return l.afterExecute()}),l.execute()},exports.useSubscription=function(i,s){var o=(0,r.useContext)((0,t.getApolloContext)()),n=(0,r.useState)({loading:!0,error:void 0,data:void 0}),u=n[0],a=n[1],c=s?(0,e.__assign)({},s,{subscription:i}):{subscription:i},l=(0,r.useRef)();var h=function(){l.current||(l.current=new p({options:c,context:o,setResult:a}));return l.current}();return h.setOptions(c),h.context=o,(0,r.useEffect)(function(){return h.afterExecute()}),h.execute(u)},exports.resetApolloContext=exports.ApolloProvider=exports.ApolloConsumer=void 0;var t=require("@apollo/react-common");exports.getApolloContext=t.getApolloContext,exports.ApolloConsumer=t.ApolloConsumer,exports.ApolloProvider=t.ApolloProvider,exports.resetApolloContext=t.resetApolloContext;var e=require("tslib"),r=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var i=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(t,r):{};i.get||i.set?Object.defineProperty(e,r,i):e[r]=t[r]}return e.default=t,e}(require("react")),i=require("apollo-client"),s=require("apollo-utilities"),o=require("ts-invariant");var n=function(){function e(t,e){this.isMounted=!0,this.previousOptions={},this.context={},this.options={},this.options=t||{},this.context=e||{}}return e.prototype.getOptions=function(){return this.options},e.prototype.setOptions=function(t){(0,s.isEqual)(this.options,t)||(this.previousOptions=this.options),this.options=t},e.prototype.unmount=function(){this.isMounted=!1},e.prototype.refreshClient=function(){var t=this.options&&this.options.client||this.context&&this.context.client;(0,o.invariant)(!!t,2);var e=!1;return t!==this.client&&(e=!0,this.client=t,this.cleanup()),{client:this.client,isNew:e}},e.prototype.verifyDocumentType=function(e,r){var i=(0,t.parser)(e);(0,t.operationName)(r),(0,t.operationName)(i.type);(0,o.invariant)(i.type===r,3)},e}(),u=function(r){function o(t){var e=t.options,i=t.context,s=t.forceUpdate,o=r.call(this,e,i)||this;return o.previousData={},o.currentObservable={},o.forceUpdate=s,o}return(0,e.__extends)(o,r),o.prototype.execute=function(){var t=this;this.refreshClient();var e=this.getOptions(),r=e.skip,s=e.query;(r||s!==this.previousData.query)&&(this.removeQuerySubscription(),this.previousData.query=s),this.updateObservableQuery(),r||this.startQuerySubscription();var o=function(){return t.getQueryResult()};return this.context&&this.context.renderPromises?this.context.renderPromises.addQueryPromise(this,o)||{loading:!0,networkStatus:i.NetworkStatus.loading}:o()},o.prototype.fetchData=function(){if(this.getOptions().skip)return!1;var t=this.getOptions(),r=(t.children,t.ssr),i=(t.displayName,t.skip,t.onCompleted,t.onError,t.partialRefetch,(0,e.__rest)(t,["children","ssr","displayName","skip","onCompleted","onError","partialRefetch"])),s=i.fetchPolicy;if(!1===r)return!1;"network-only"!==s&&"cache-and-network"!==s||(s="cache-first");var o=this.refreshClient().client.watchQuery((0,e.__assign)({},i,{fetchPolicy:s}));return this.context&&this.context.renderPromises&&this.context.renderPromises.registerSSRObservable(o,this.getOptions()),!!this.currentObservable.query.getCurrentResult().loading&&o.result()},o.prototype.afterExecute=function(){return this.isMounted=!0,this.handleErrorOrCompleted(),this.unmount.bind(this)},o.prototype.cleanup=function(){this.removeQuerySubscription(),this.currentObservable.query=null,this.previousData.result=null},o.prototype.updateCurrentData=function(){this.isMounted&&this.forceUpdate()},o.prototype.prepareObservableQueryOptions=function(){this.verifyDocumentType(this.getOptions().query,t.DocumentType.Query);var r=this.getOptions().displayName||"Query";return(0,e.__assign)({},this.getOptions(),{displayName:r,context:this.getOptions().context||{},metadata:{reactComponent:{displayName:r}}})},o.prototype.observableQueryFields=function(t){return{variables:t.variables,refetch:t.refetch.bind(t),fetchMore:t.fetchMore.bind(t),updateQuery:t.updateQuery.bind(t),startPolling:t.startPolling.bind(t),stopPolling:t.stopPolling.bind(t),subscribeToMore:t.subscribeToMore.bind(t)}},o.prototype.initializeObservableQuery=function(){if(this.context&&this.context.renderPromises&&(this.currentObservable.query=this.context.renderPromises.getSSRObservable(this.getOptions())),!this.currentObservable.query){var t=this.prepareObservableQueryOptions();this.previousData.observableQueryOptions=(0,e.__assign)({},t,{children:null}),this.currentObservable.query=this.refreshClient().client.watchQuery(t)}},o.prototype.updateObservableQuery=function(){this.currentObservable.query||this.initializeObservableQuery();var t=(0,e.__assign)({},this.prepareObservableQueryOptions(),{children:null});(0,s.isEqual)(t,this.previousData.observableQueryOptions)||(this.previousData.observableQueryOptions=t,this.currentObservable.query.setOptions(t).catch(function(){}))},o.prototype.startQuerySubscription=function(){var t=this;if(!this.currentObservable.subscription){var e=this.currentObservable.query;this.currentObservable.subscription=e.subscribe({next:function(e){var r=e.loading,i=e.networkStatus,o=e.data;t.previousData.result&&t.previousData.result.loading===r&&t.previousData.result.networkStatus===i&&(0,s.isEqual)(t.previousData.result.data,o||{})||t.updateCurrentData()},error:function(e){if(t.resubscribeToQuery(),!e.hasOwnProperty("graphQLErrors"))throw e;t.updateCurrentData()}})}},o.prototype.resubscribeToQuery=function(){this.removeQuerySubscription();var t=this.currentObservable.query.getLastError(),e=this.currentObservable.query.getLastResult();this.currentObservable.query.resetLastResults(),this.startQuerySubscription(),Object.assign(this.currentObservable.query,{lastError:t,lastResult:e})},o.prototype.getQueryResult=function(){var t=this,r={data:Object.create(null)};if(Object.assign(r,this.observableQueryFields(this.currentObservable.query)),this.getOptions().skip)r=(0,e.__assign)({},r,{data:void 0,error:void 0,loading:!1});else{var s=this.currentObservable.query.getCurrentResult(),o=s.loading,n=s.partial,u=s.networkStatus,a=s.errors,p=s.error,c=s.data;if(c=c||Object.create(null),a&&a.length>0&&(p=new i.ApolloError({graphQLErrors:a})),Object.assign(r,{loading:o,networkStatus:u,error:p}),o){var l=this.previousData.result?this.previousData.result.data:{};Object.assign(r.data,l,c)}else if(p)Object.assign(r,{data:(this.currentObservable.query.getLastResult()||{}).data});else{var h=this.currentObservable.query.options.fetchPolicy;if(this.getOptions().partialRefetch&&0===Object.keys(c).length&&n&&"cache-only"!==h)return Object.assign(r,{loading:!0,networkStatus:i.NetworkStatus.loading}),r.refetch(),r;Object.assign(r.data,c)}}return setTimeout(function(){t.currentObservable.query.resetQueryStoreErrors()}),r.client=this.client,this.previousData.loading=this.previousData.result&&this.previousData.result.loading||!1,this.previousData.result=r,r},o.prototype.handleErrorOrCompleted=function(){var t=this.currentObservable.query.getCurrentResult(),e=t.data,r=t.loading,i=t.error;if(!r){var o=this.getOptions(),n=o.query,u=o.variables,a=o.onCompleted,p=o.onError;if(this.previousOptions&&!this.previousData.loading&&(0,s.isEqual)(this.previousOptions.query,n)&&(0,s.isEqual)(this.previousOptions.variables,u))return;a&&!i?a(e):p&&i&&p(i)}},o.prototype.removeQuerySubscription=function(){this.currentObservable.subscription&&(this.currentObservable.subscription.unsubscribe(),delete this.currentObservable.subscription)},o}(n);var a=function(r){function o(e){var i=e.options,s=e.context,o=e.result,n=e.setResult,u=r.call(this,i,s)||this;return u.verifyDocumentType(i.mutation,t.DocumentType.Mutation),u.result=o,u.setResult=n,u.mostRecentMutationId=0,u}return(0,e.__extends)(o,r),o.prototype.execute=function(e){var r=this;this.verifyDocumentType(this.getOptions().mutation,t.DocumentType.Mutation);return[function(t){return r.runMutation(t)},e]},o.prototype.afterExecute=function(){return this.isMounted=!0,this.unmount.bind(this)},o.prototype.cleanup=function(){},o.prototype.runMutation=function(t){var e=this;void 0===t&&(t={}),this.onMutationStart();var r=this.generateNewMutationId();return this.mutate(t).then(function(t){return e.onMutationCompleted(t,r),t}).catch(function(t){if(e.onMutationError(t,r),!e.getOptions().onError)throw t})},o.prototype.mutate=function(t){var r=this.getOptions(),i=r.mutation,s=r.variables,o=r.optimisticResponse,n=r.update,u=r.context,a=void 0===u?{}:u,p=r.awaitRefetchQueries,c=void 0!==p&&p,l=r.fetchPolicy,h=(0,e.__assign)({},t),b=Object.assign({},s,h.variables);return delete h.variables,this.refreshClient().client.mutate((0,e.__assign)({mutation:i,optimisticResponse:o,refetchQueries:h.refetchQueries||this.getOptions().refetchQueries,awaitRefetchQueries:c,update:n,context:a,fetchPolicy:l,variables:b},h))},o.prototype.onMutationStart=function(){this.result.loading||this.getOptions().ignoreResults||this.updateResult({loading:!0,error:void 0,data:void 0,called:!0})},o.prototype.onMutationCompleted=function(t,e){var r=this.getOptions(),s=r.onCompleted,o=r.ignoreResults,n=t.data,u=t.errors,a=u&&u.length>0?new i.ApolloError({graphQLErrors:u}):void 0;this.isMostRecentMutation(e)&&!o&&this.updateResult({called:!0,loading:!1,data:n,error:a}),s&&s(n)},o.prototype.onMutationError=function(t,e){var r=this.getOptions().onError;this.isMostRecentMutation(e)&&this.updateResult({loading:!1,error:t,data:void 0,called:!0}),r&&r(t)},o.prototype.generateNewMutationId=function(){return++this.mostRecentMutationId},o.prototype.isMostRecentMutation=function(t){return this.mostRecentMutationId===t},o.prototype.updateResult=function(t){!this.isMounted||this.previousResult&&(0,s.isEqual)(this.previousResult,t)||(this.setResult(t),this.previousResult=t)},o}(n);var p=function(t){function r(e){var r=e.options,i=e.context,s=e.setResult,o=t.call(this,r,i)||this;return o.currentObservable={},o.setResult=s,o.initialize(r),o}return(0,e.__extends)(r,t),r.prototype.execute=function(t){var r=t;this.refreshClient().isNew&&(r=this.getLoadingResult());var i=this.getOptions().shouldResubscribe;return"function"==typeof i&&(i=!!i(this.getOptions())),!1!==i&&this.previousOptions&&Object.keys(this.previousOptions).length>0&&(this.previousOptions.subscription!==this.getOptions().subscription||!(0,s.isEqual)(this.previousOptions.variables,this.getOptions().variables))&&(this.endSubscription(),delete this.currentObservable.query,r=this.getLoadingResult()),this.initialize(this.getOptions()),this.startSubscription(),this.previousOptions=this.getOptions(),(0,e.__assign)({},r,{variables:this.getOptions().variables})},r.prototype.afterExecute=function(){return this.isMounted=!0,this.unmount.bind(this)},r.prototype.cleanup=function(){this.endSubscription(),delete this.currentObservable.query},r.prototype.initialize=function(t){this.currentObservable.query||(this.currentObservable.query=this.refreshClient().client.subscribe({query:t.subscription,variables:t.variables,fetchPolicy:t.fetchPolicy}))},r.prototype.startSubscription=function(){this.currentObservable.subscription||(this.currentObservable.subscription=this.currentObservable.query.subscribe({next:this.updateCurrentData.bind(this),error:this.updateError.bind(this),complete:this.completeSubscription.bind(this)}))},r.prototype.getLoadingResult=function(){return{loading:!0,error:void 0,data:void 0}},r.prototype.updateResult=function(t){this.isMounted&&this.setResult(t)},r.prototype.updateCurrentData=function(t){var e=this.getOptions().onSubscriptionData;this.updateResult({data:t.data,loading:!1,error:void 0}),e&&e({client:this.refreshClient().client,subscriptionData:t})},r.prototype.updateError=function(t){this.updateResult({error:t,loading:!1})},r.prototype.completeSubscription=function(){var t=this.getOptions().onSubscriptionComplete;t&&t(),this.endSubscription()},r.prototype.endSubscription=function(){this.currentObservable.subscription&&(this.currentObservable.subscription.unsubscribe(),delete this.currentObservable.subscription)},r}(n);var c=function(){function t(){this.queryPromises=new Map,this.queryInfoTrie=new Map}return t.prototype.registerSSRObservable=function(t,e){this.lookupQueryInfo(e).observable=t},t.prototype.getSSRObservable=function(t){return this.lookupQueryInfo(t).observable},t.prototype.addQueryPromise=function(t,e){return this.lookupQueryInfo(t.getOptions()).seen?e():(this.queryPromises.set(t.getOptions(),new Promise(function(e){e(t.fetchData())})),null)},t.prototype.hasPromises=function(){return this.queryPromises.size>0},t.prototype.consumeAndAwaitPromises=function(){var t=this,e=[];return this.queryPromises.forEach(function(r,i){t.lookupQueryInfo(i).seen=!0,e.push(r)}),this.queryPromises.clear(),Promise.all(e)},t.prototype.lookupQueryInfo=function(t){var e=this.queryInfoTrie,r=t.query,i=t.variables,s=e.get(r)||new Map;e.has(r)||e.set(r,s);var o=JSON.stringify(i),n=s.get(o)||{seen:!1,observable:null};return s.has(o)||s.set(o,n),n},t}();function l(i){var s=i.tree,o=i.context,n=void 0===o?{}:o,u=i.renderFunction,a=void 0===u?require("react-dom/server").renderToStaticMarkup:u,p=new c;return Promise.resolve().then(function i(){var o=(0,t.getApolloContext)(),u=a(r.default.createElement(o.Provider,{value:(0,e.__assign)({},n,{renderPromises:p})},s));return p.hasPromises()?p.consumeAndAwaitPromises().then(i):u})}
exports.__esModule=!0,exports.useApolloClient=function(){var e=r.default.useContext((0,t.getApolloContext)()).client;return(0,o.invariant)(e,1),e},exports.useLazyQuery=function(t,e){return a(t,e,!0)},exports.useMutation=function(i,s){var o=(0,r.useContext)((0,t.getApolloContext)()),n=(0,r.useState)({called:!1,loading:!1}),u=n[0],a=n[1],c=s?(0,e.__assign)({},s,{mutation:i}):{mutation:i},l=(0,r.useRef)();var h=function(){l.current||(l.current=new p({options:c,context:o,result:u,setResult:a}));return l.current}();return h.setOptions(c),h.context=o,(0,r.useEffect)(function(){return h.afterExecute()}),h.execute(u)},exports.useQuery=function(t,e){return a(t,e,!1)},exports.useSubscription=function(i,s){var o=(0,r.useContext)((0,t.getApolloContext)()),n=(0,r.useState)({loading:!0,error:void 0,data:void 0}),u=n[0],a=n[1],p=s?(0,e.__assign)({},s,{subscription:i}):{subscription:i},l=(0,r.useRef)();var h=function(){l.current||(l.current=new c({options:p,context:o,setResult:a}));return l.current}();return h.setOptions(p),h.context=o,(0,r.useEffect)(function(){return h.afterExecute()}),(0,r.useEffect)(function(){return h.cleanup.bind(h)},[]),h.execute(u)},exports.RenderPromises=exports.resetApolloContext=exports.ApolloProvider=exports.ApolloConsumer=void 0;var t=require("@apollo/react-common");exports.getApolloContext=t.getApolloContext,exports.ApolloConsumer=t.ApolloConsumer,exports.ApolloProvider=t.ApolloProvider,exports.resetApolloContext=t.resetApolloContext;var e=require("tslib"),r=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var i=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(t,r):{};i.get||i.set?Object.defineProperty(e,r,i):e[r]=t[r]}return e.default=t,e}(require("react")),i=require("apollo-client"),s=require("@wry/equality"),o=require("ts-invariant");var n=function(){function e(t,e){this.isMounted=!1,this.previousOptions={},this.context={},this.options={},this.options=t||{},this.context=e||{}}return e.prototype.getOptions=function(){return this.options},e.prototype.setOptions=function(t){(0,s.equal)(this.options,t)||(this.previousOptions=this.options),this.options=t},e.prototype.unmount=function(){this.isMounted=!1},e.prototype.refreshClient=function(){var t=this.options&&this.options.client||this.context&&this.context.client;(0,o.invariant)(!!t,2);var e=!1;return t!==this.client&&(e=!0,this.client=t,this.cleanup()),{client:this.client,isNew:e}},e.prototype.verifyDocumentType=function(e,r){var i=(0,t.parser)(e);(0,t.operationName)(r),(0,t.operationName)(i.type);(0,o.invariant)(i.type===r,3)},e}(),u=function(r){function o(t){var e=t.options,i=t.context,s=t.forceUpdate,o=r.call(this,e,i)||this;return o.previousData={},o.currentObservable={},o.runLazy=!1,o.runLazyQuery=function(t){o.runLazy=!0,o.lazyOptions=t,o.forceUpdate()},o.getExecuteResult=function(){var t=o.getQueryResult();return o.startQuerySubscription(),t},o.forceUpdate=s,o}return(0,e.__extends)(o,r),o.prototype.execute=function(){this.refreshClient();var t=this.getOptions(),e=t.skip,r=t.query;return(e||r!==this.previousData.query)&&(this.removeQuerySubscription(),this.previousData.query=r),this.updateObservableQuery(),this.isMounted&&this.startQuerySubscription(),this.getExecuteSsrResult()||this.getExecuteResult()},o.prototype.executeLazy=function(){return this.runLazy?[this.runLazyQuery,this.execute()]:[this.runLazyQuery,{loading:!1,networkStatus:i.NetworkStatus.ready,called:!1,data:void 0}]},o.prototype.fetchData=function(){if(this.getOptions().skip)return!1;var t=this.getOptions(),r=(t.children,t.ssr),i=(t.displayName,t.skip,t.onCompleted,t.onError,t.partialRefetch,(0,e.__rest)(t,["children","ssr","displayName","skip","onCompleted","onError","partialRefetch"])),s=i.fetchPolicy;if(!1===r)return!1;"network-only"!==s&&"cache-and-network"!==s||(s="cache-first");var o=this.refreshClient().client.watchQuery((0,e.__assign)({},i,{fetchPolicy:s}));return this.context&&this.context.renderPromises&&this.context.renderPromises.registerSSRObservable(o,this.getOptions()),!!this.currentObservable.query.getCurrentResult().loading&&o.result()},o.prototype.afterExecute=function(t){var e=(void 0===t?{}:t).lazy,r=void 0!==e&&e;return this.isMounted=!0,r&&!this.runLazy||this.handleErrorOrCompleted(),this.unmount.bind(this)},o.prototype.cleanup=function(){this.removeQuerySubscription(),delete this.currentObservable.query,delete this.previousData.result},o.prototype.getOptions=function(){var t=r.prototype.getOptions.call(this),i=this.lazyOptions||{},s=(0,e.__assign)({},t,{variables:(0,e.__assign)({},t.variables,i.variables),context:(0,e.__assign)({},t.context,i.context)});return this.runLazy&&delete s.skip,s},o.prototype.getExecuteSsrResult=function(){var t,e={loading:!0,networkStatus:i.NetworkStatus.loading,called:!0,data:{}};return this.context&&this.context.renderPromises&&((t=this.context.renderPromises.addQueryPromise(this,this.getExecuteResult))||(t=e)),t},o.prototype.updateCurrentData=function(){this.isMounted&&this.forceUpdate()},o.prototype.prepareObservableQueryOptions=function(){this.verifyDocumentType(this.getOptions().query,t.DocumentType.Query);var r=this.getOptions().displayName||"Query";return(0,e.__assign)({},this.getOptions(),{displayName:r,context:this.getOptions().context||{},metadata:{reactComponent:{displayName:r}}})},o.prototype.observableQueryFields=function(t){return{variables:t.variables,refetch:t.refetch.bind(t),fetchMore:t.fetchMore.bind(t),updateQuery:t.updateQuery.bind(t),startPolling:t.startPolling.bind(t),stopPolling:t.stopPolling.bind(t),subscribeToMore:t.subscribeToMore.bind(t)}},o.prototype.initializeObservableQuery=function(){if(this.context&&this.context.renderPromises&&(this.currentObservable.query=this.context.renderPromises.getSSRObservable(this.getOptions())),!this.currentObservable.query){var t=this.prepareObservableQueryOptions();this.previousData.observableQueryOptions=(0,e.__assign)({},t,{children:null}),this.currentObservable.query=this.refreshClient().client.watchQuery(t)}},o.prototype.updateObservableQuery=function(){this.currentObservable.query||this.initializeObservableQuery();var t=(0,e.__assign)({},this.prepareObservableQueryOptions(),{children:null});(0,s.equal)(t,this.previousData.observableQueryOptions)||(this.previousData.observableQueryOptions=t,this.currentObservable.query.setOptions(t).catch(function(){}))},o.prototype.startQuerySubscription=function(){var t=this;if(!this.currentObservable.subscription&&!this.getOptions().skip){var e=this.currentObservable.query;this.currentObservable.subscription=e.subscribe({next:function(e){var r=e.loading,i=e.networkStatus,o=e.data;t.previousData.result&&t.previousData.result.loading===r&&t.previousData.result.networkStatus===i&&(0,s.equal)(t.previousData.result.data,o||{})||t.updateCurrentData()},error:function(e){if(t.resubscribeToQuery(),!e.hasOwnProperty("graphQLErrors"))throw e;t.updateCurrentData()}})}},o.prototype.resubscribeToQuery=function(){this.removeQuerySubscription();var t=this.currentObservable.query.getLastError(),e=this.currentObservable.query.getLastResult();this.currentObservable.query.resetLastResults(),this.startQuerySubscription(),Object.assign(this.currentObservable.query,{lastError:t,lastResult:e})},o.prototype.getQueryResult=function(){var t=this,r={data:Object.create(null)};if(Object.assign(r,this.observableQueryFields(this.currentObservable.query)),this.getOptions().skip)r=(0,e.__assign)({},r,{data:void 0,error:void 0,loading:!1,called:!0});else{var s=this.currentObservable.query.getCurrentResult(),o=s.loading,n=s.partial,u=s.networkStatus,a=s.errors,p=s.error,c=s.data;if(c=c||Object.create(null),a&&a.length>0&&(p=new i.ApolloError({graphQLErrors:a})),Object.assign(r,{loading:o,networkStatus:u,error:p,called:!0}),o){var l=this.previousData.result?this.previousData.result.data:{};Object.assign(r.data,l,c)}else if(p)Object.assign(r,{data:(this.currentObservable.query.getLastResult()||{}).data});else{var h=this.currentObservable.query.options.fetchPolicy;if(this.getOptions().partialRefetch&&0===Object.keys(c).length&&n&&"cache-only"!==h)return Object.assign(r,{loading:!0,networkStatus:i.NetworkStatus.loading}),r.refetch(),r;Object.assign(r.data,c)}}return setTimeout(function(){t.currentObservable.query.resetQueryStoreErrors()}),r.client=this.client,this.previousData.loading=this.previousData.result&&this.previousData.result.loading||!1,this.previousData.result=r,r},o.prototype.handleErrorOrCompleted=function(){var t=this.currentObservable.query.getCurrentResult(),e=t.data,r=t.loading,i=t.error;if(!r){var o=this.getOptions(),n=o.query,u=o.variables,a=o.onCompleted,p=o.onError;if(this.previousOptions&&!this.previousData.loading&&(0,s.equal)(this.previousOptions.query,n)&&(0,s.equal)(this.previousOptions.variables,u))return;a&&!i?a(e):p&&i&&p(i)}},o.prototype.removeQuerySubscription=function(){this.currentObservable.subscription&&(this.currentObservable.subscription.unsubscribe(),delete this.currentObservable.subscription)},o}(n);function a(i,o,n){void 0===n&&(n=!1);var a=(0,r.useContext)((0,t.getApolloContext)()),p=(0,r.useReducer)(function(t){return t+1},0),c=p[0],l=p[1],h=o?(0,e.__assign)({},o,{query:i}):{query:i},b=(0,r.useRef)();b.current||(b.current=new u({options:h,context:a,forceUpdate:l}));var v=b.current;v.setOptions(h),v.context=a;var y,d,f,g=(y=function(){return n?v.executeLazy():v.execute()},d={options:h,context:a,tick:c},(f=(0,r.useRef)()).current&&(0,s.equal)(d,f.current.key)||(f.current={key:d,value:y()}),f.current.value);return(0,r.useEffect)(function(){return v.afterExecute({lazy:n})},[g]),g}var p=function(r){function o(e){var i=e.options,s=e.context,o=e.result,n=e.setResult,u=r.call(this,i,s)||this;return u.verifyDocumentType(i.mutation,t.DocumentType.Mutation),u.result=o,u.setResult=n,u.mostRecentMutationId=0,u}return(0,e.__extends)(o,r),o.prototype.execute=function(e){var r=this;this.isMounted=!0,this.verifyDocumentType(this.getOptions().mutation,t.DocumentType.Mutation);return[function(t){return r.runMutation(t)},e]},o.prototype.afterExecute=function(){return this.isMounted=!0,this.unmount.bind(this)},o.prototype.cleanup=function(){},o.prototype.runMutation=function(t){var e=this;void 0===t&&(t={}),this.onMutationStart();var r=this.generateNewMutationId();return this.mutate(t).then(function(t){return e.onMutationCompleted(t,r),t}).catch(function(t){if(e.onMutationError(t,r),!e.getOptions().onError)throw t})},o.prototype.mutate=function(t){var r=this.getOptions(),i=r.mutation,s=r.variables,o=r.optimisticResponse,n=r.update,u=r.context,a=void 0===u?{}:u,p=r.awaitRefetchQueries,c=void 0!==p&&p,l=r.fetchPolicy,h=(0,e.__assign)({},t),b=Object.assign({},s,h.variables);return delete h.variables,this.refreshClient().client.mutate((0,e.__assign)({mutation:i,optimisticResponse:o,refetchQueries:h.refetchQueries||this.getOptions().refetchQueries,awaitRefetchQueries:c,update:n,context:a,fetchPolicy:l,variables:b},h))},o.prototype.onMutationStart=function(){this.result.loading||this.getOptions().ignoreResults||this.updateResult({loading:!0,error:void 0,data:void 0,called:!0})},o.prototype.onMutationCompleted=function(t,e){var r=this.getOptions(),s=r.onCompleted,o=r.ignoreResults,n=t.data,u=t.errors,a=u&&u.length>0?new i.ApolloError({graphQLErrors:u}):void 0;this.isMostRecentMutation(e)&&!o&&this.updateResult({called:!0,loading:!1,data:n,error:a}),s&&s(n)},o.prototype.onMutationError=function(t,e){var r=this.getOptions().onError;this.isMostRecentMutation(e)&&this.updateResult({loading:!1,error:t,data:void 0,called:!0}),r&&r(t)},o.prototype.generateNewMutationId=function(){return++this.mostRecentMutationId},o.prototype.isMostRecentMutation=function(t){return this.mostRecentMutationId===t},o.prototype.updateResult=function(t){!this.isMounted||this.previousResult&&(0,s.equal)(this.previousResult,t)||(this.setResult(t),this.previousResult=t)},o}(n);var c=function(t){function r(e){var r=e.options,i=e.context,s=e.setResult,o=t.call(this,r,i)||this;return o.currentObservable={},o.setResult=s,o.initialize(r),o}return(0,e.__extends)(r,t),r.prototype.execute=function(t){var r=t;this.refreshClient().isNew&&(r=this.getLoadingResult());var i=this.getOptions().shouldResubscribe;return"function"==typeof i&&(i=!!i(this.getOptions())),!1!==i&&this.previousOptions&&Object.keys(this.previousOptions).length>0&&(this.previousOptions.subscription!==this.getOptions().subscription||!(0,s.equal)(this.previousOptions.variables,this.getOptions().variables))&&(this.endSubscription(),delete this.currentObservable.query,r=this.getLoadingResult()),this.initialize(this.getOptions()),this.startSubscription(),this.previousOptions=this.getOptions(),(0,e.__assign)({},r,{variables:this.getOptions().variables})},r.prototype.afterExecute=function(){this.isMounted=!0},r.prototype.cleanup=function(){this.endSubscription(),delete this.currentObservable.query},r.prototype.initialize=function(t){this.currentObservable.query||(this.currentObservable.query=this.refreshClient().client.subscribe({query:t.subscription,variables:t.variables,fetchPolicy:t.fetchPolicy}))},r.prototype.startSubscription=function(){this.currentObservable.subscription||(this.currentObservable.subscription=this.currentObservable.query.subscribe({next:this.updateCurrentData.bind(this),error:this.updateError.bind(this),complete:this.completeSubscription.bind(this)}))},r.prototype.getLoadingResult=function(){return{loading:!0,error:void 0,data:void 0}},r.prototype.updateResult=function(t){this.isMounted&&this.setResult(t)},r.prototype.updateCurrentData=function(t){var e=this.getOptions().onSubscriptionData;this.updateResult({data:t.data,loading:!1,error:void 0}),e&&e({client:this.refreshClient().client,subscriptionData:t})},r.prototype.updateError=function(t){this.updateResult({error:t,loading:!1})},r.prototype.completeSubscription=function(){var t=this.getOptions().onSubscriptionComplete;t&&t(),this.endSubscription()},r.prototype.endSubscription=function(){this.currentObservable.subscription&&(this.currentObservable.subscription.unsubscribe(),delete this.currentObservable.subscription)},r}(n);var l=function(){function t(){this.queryPromises=new Map,this.queryInfoTrie=new Map}return t.prototype.registerSSRObservable=function(t,e){this.lookupQueryInfo(e).observable=t},t.prototype.getSSRObservable=function(t){return this.lookupQueryInfo(t).observable},t.prototype.addQueryPromise=function(t,e){return this.lookupQueryInfo(t.getOptions()).seen?e():(this.queryPromises.set(t.getOptions(),new Promise(function(e){e(t.fetchData())})),null)},t.prototype.hasPromises=function(){return this.queryPromises.size>0},t.prototype.consumeAndAwaitPromises=function(){var t=this,e=[];return this.queryPromises.forEach(function(r,i){t.lookupQueryInfo(i).seen=!0,e.push(r)}),this.queryPromises.clear(),Promise.all(e)},t.prototype.lookupQueryInfo=function(t){var e=this.queryInfoTrie,r=t.query,i=t.variables,s=e.get(r)||new Map;e.has(r)||e.set(r,s);var o=JSON.stringify(i),n=s.get(o)||{seen:!1,observable:null};return s.has(o)||s.set(o,n),n},t}();exports.RenderPromises=l;
import { parser, operationName, DocumentType, getApolloContext } from '@apollo/react-common';
export { ApolloConsumer, ApolloProvider, getApolloContext, resetApolloContext } from '@apollo/react-common';
import { __extends, __rest, __assign } from 'tslib';
import React, { useContext, useReducer, useRef, useEffect, useState } from 'react';
import React, { useRef, useContext, useReducer, useEffect, useState } from 'react';
import { NetworkStatus, ApolloError } from 'apollo-client';
import { isEqual } from 'apollo-utilities';
import { equal } from '@wry/equality';
import { invariant } from 'ts-invariant';

@@ -11,3 +11,3 @@

function OperationData(options, context) {
this.isMounted = true;
this.isMounted = false;
this.previousOptions = {};

@@ -23,3 +23,3 @@ this.context = {};

OperationData.prototype.setOptions = function (newOptions) {
if (!isEqual(this.options, newOptions)) {
if (!equal(this.options, newOptions)) {
this.previousOptions = this.options;

@@ -66,2 +66,13 @@ }

_this.currentObservable = {};
_this.runLazy = false;
_this.runLazyQuery = function (options) {
_this.runLazy = true;
_this.lazyOptions = options;
_this.forceUpdate();
};
_this.getExecuteResult = function () {
var result = _this.getQueryResult();
_this.startQuerySubscription();
return result;
};
_this.forceUpdate = forceUpdate;

@@ -71,3 +82,2 @@ return _this;

QueryData.prototype.execute = function () {
var _this = this;
this.refreshClient();

@@ -80,12 +90,19 @@ var _a = this.getOptions(), skip = _a.skip, query = _a.query;

this.updateObservableQuery();
if (!skip) {
if (this.isMounted)
this.startQuerySubscription();
}
var finish = function () { return _this.getQueryResult(); };
if (this.context && this.context.renderPromises) {
var result = this.context.renderPromises.addQueryPromise(this, finish);
return result || { loading: true, networkStatus: NetworkStatus.loading };
}
return finish();
return this.getExecuteSsrResult() || this.getExecuteResult();
};
QueryData.prototype.executeLazy = function () {
return !this.runLazy
? [
this.runLazyQuery,
{
loading: false,
networkStatus: NetworkStatus.ready,
called: false,
data: undefined
}
]
: [this.runLazyQuery, this.execute()];
};
QueryData.prototype.fetchData = function () {

@@ -105,8 +122,11 @@ if (this.getOptions().skip)

}
var result = this.currentObservable.query.getCurrentResult();
return result.loading ? obs.result() : false;
var currentResult = this.currentObservable.query.getCurrentResult();
return currentResult.loading ? obs.result() : false;
};
QueryData.prototype.afterExecute = function () {
QueryData.prototype.afterExecute = function (_a) {
var _b = (_a === void 0 ? {} : _a).lazy, lazy = _b === void 0 ? false : _b;
this.isMounted = true;
this.handleErrorOrCompleted();
if (!lazy || this.runLazy) {
this.handleErrorOrCompleted();
}
return this.unmount.bind(this);

@@ -116,5 +136,30 @@ };

this.removeQuerySubscription();
this.currentObservable.query = null;
this.previousData.result = null;
delete this.currentObservable.query;
delete this.previousData.result;
};
QueryData.prototype.getOptions = function () {
var options = _super.prototype.getOptions.call(this);
var lazyOptions = this.lazyOptions || {};
var updatedOptions = __assign({}, options, { variables: __assign({}, options.variables, lazyOptions.variables), context: __assign({}, options.context, lazyOptions.context) });
if (this.runLazy) {
delete updatedOptions.skip;
}
return updatedOptions;
};
QueryData.prototype.getExecuteSsrResult = function () {
var result;
var ssrLoading = {
loading: true,
networkStatus: NetworkStatus.loading,
called: true,
data: {}
};
if (this.context && this.context.renderPromises) {
result = this.context.renderPromises.addQueryPromise(this, this.getExecuteResult);
if (!result) {
result = ssrLoading;
}
}
return result;
};
QueryData.prototype.updateCurrentData = function () {

@@ -156,3 +201,3 @@ if (this.isMounted) {

var newObservableQueryOptions = __assign({}, this.prepareObservableQueryOptions(), { children: null });
if (!isEqual(newObservableQueryOptions, this.previousData.observableQueryOptions)) {
if (!equal(newObservableQueryOptions, this.previousData.observableQueryOptions)) {
this.previousData.observableQueryOptions = newObservableQueryOptions;

@@ -166,3 +211,3 @@ this.currentObservable

var _this = this;
if (this.currentObservable.subscription)
if (this.currentObservable.subscription || this.getOptions().skip)
return;

@@ -176,3 +221,3 @@ var obsQuery = this.currentObservable.query;

_this.previousData.result.networkStatus === networkStatus &&
isEqual(_this.previousData.result.data, data || {})) {
equal(_this.previousData.result.data, data || {})) {
return;

@@ -208,3 +253,3 @@ }

if (this.getOptions().skip) {
result = __assign({}, result, { data: undefined, error: undefined, loading: false });
result = __assign({}, result, { data: undefined, error: undefined, loading: false, called: true });
}

@@ -219,3 +264,3 @@ else {

}
Object.assign(result, { loading: loading, networkStatus: networkStatus, error: error });
Object.assign(result, { loading: loading, networkStatus: networkStatus, error: error, called: true });
if (loading) {

@@ -265,4 +310,4 @@ var previousData = this.previousData.result

!this.previousData.loading &&
isEqual(this.previousOptions.query, query) &&
isEqual(this.previousOptions.variables, variables)) {
equal(this.previousOptions.query, query) &&
equal(this.previousOptions.variables, variables)) {
return;

@@ -287,24 +332,44 @@ }

function useQuery(query, options) {
function useDeepMemo(memoFn, key) {
var ref = useRef();
if (!ref.current || !equal(key, ref.current.key)) {
ref.current = { key: key, value: memoFn() };
}
return ref.current.value;
}
function useBaseQuery(query, options, lazy) {
if (lazy === void 0) { lazy = false; }
var context = useContext(getApolloContext());
var _a = useReducer(function (x) { return x + 1; }, 0), _ignored = _a[0], forceUpdate = _a[1];
var _a = useReducer(function (x) { return x + 1; }, 0), tick = _a[0], forceUpdate = _a[1];
var updatedOptions = options ? __assign({}, options, { query: query }) : { query: query };
var queryDataRef = useRef();
function getQueryDataRef() {
if (!queryDataRef.current) {
queryDataRef.current = new QueryData({
options: updatedOptions,
context: context,
forceUpdate: forceUpdate
});
}
return queryDataRef.current;
if (!queryDataRef.current) {
queryDataRef.current = new QueryData({
options: updatedOptions,
context: context,
forceUpdate: forceUpdate
});
}
var queryData = getQueryDataRef();
var queryData = queryDataRef.current;
queryData.setOptions(updatedOptions);
queryData.context = context;
useEffect(function () { return queryData.afterExecute(); });
return queryData.execute();
var memo = {
options: updatedOptions,
context: context,
tick: tick
};
var result = useDeepMemo(function () { return (lazy ? queryData.executeLazy() : queryData.execute()); }, memo);
useEffect(function () { return queryData.afterExecute({ lazy: lazy }); }, [result]);
return result;
}
function useQuery(query, options) {
return useBaseQuery(query, options, false);
}
function useLazyQuery(query, options) {
return useBaseQuery(query, options, true);
}
var MutationData = (function (_super) {

@@ -323,2 +388,3 @@ __extends(MutationData, _super);

var _this = this;
this.isMounted = true;
this.verifyDocumentType(this.getOptions().mutation, DocumentType.Mutation);

@@ -410,3 +476,3 @@ var runMutation = function (options) { return _this.runMutation(options); };

if (this.isMounted &&
(!this.previousResult || !isEqual(this.previousResult, result))) {
(!this.previousResult || !equal(this.previousResult, result))) {
this.setResult(result);

@@ -465,3 +531,3 @@ this.previousResult = result;

(this.previousOptions.subscription !== this.getOptions().subscription ||
!isEqual(this.previousOptions.variables, this.getOptions().variables))) {
!equal(this.previousOptions.variables, this.getOptions().variables))) {
this.endSubscription();

@@ -478,3 +544,2 @@ delete this.currentObservable.query;

this.isMounted = true;
return this.unmount.bind(this);
};

@@ -574,2 +639,3 @@ SubscriptionData.prototype.cleanup = function () {

useEffect(function () { return subscriptionData.afterExecute(); });
useEffect(function () { return subscriptionData.cleanup.bind(subscriptionData); }, []);
return subscriptionData.execute(result);

@@ -639,31 +705,4 @@ }

}());
function getDataFromTree(tree, context) {
if (context === void 0) { context = {}; }
return getMarkupFromTree({
tree: tree,
context: context,
renderFunction: require('react-dom/server').renderToStaticMarkup
});
}
function getMarkupFromTree(_a) {
var tree = _a.tree, _b = _a.context, context = _b === void 0 ? {} : _b, _c = _a.renderFunction, renderFunction = _c === void 0 ? require('react-dom/server').renderToStaticMarkup : _c;
var renderPromises = new RenderPromises();
function process() {
var ApolloContext = getApolloContext();
var html = renderFunction(React.createElement(ApolloContext.Provider, { value: __assign({}, context, { renderPromises: renderPromises }) }, tree));
return renderPromises.hasPromises()
? renderPromises.consumeAndAwaitPromises().then(process)
: html;
}
return Promise.resolve().then(process);
}
function renderToStringWithData(component) {
return getMarkupFromTree({
tree: component,
renderFunction: require('react-dom/server').renderToString
});
}
export { getDataFromTree, getMarkupFromTree, renderToStringWithData, useApolloClient, useMutation, useQuery, useSubscription };
export { RenderPromises, useApolloClient, useLazyQuery, useMutation, useQuery, useSubscription };
//# sourceMappingURL=react-hooks.esm.js.map
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports", "@apollo/react-common", "tslib", "react", "apollo-client", "apollo-utilities", "ts-invariant"], factory);
define(["exports", "@apollo/react-common", "tslib", "react", "apollo-client", "@wry/equality", "ts-invariant"], factory);
} else if (typeof exports !== "undefined") {
factory(exports, require("@apollo/react-common"), require("tslib"), require("react"), require("apollo-client"), require("apollo-utilities"), require("ts-invariant"));
factory(exports, require("@apollo/react-common"), require("tslib"), require("react"), require("apollo-client"), require("@wry/equality"), require("ts-invariant"));
} else {

@@ -10,16 +10,14 @@ var mod = {

};
factory(mod.exports, global.reactCommon, global.tslib, global.react, global.apolloClient, global.apolloUtilities, global.tsInvariant);
factory(mod.exports, global.reactCommon, global.tslib, global.react, global.apolloClient, global.equality, global.tsInvariant);
global.unknown = mod.exports;
}
})(this, function (_exports, _reactCommon, _tslib, _react, _apolloClient, _apolloUtilities, _tsInvariant) {
})(this, function (_exports, _reactCommon, _tslib, _react, _apolloClient, _equality, _tsInvariant) {
_exports.__esModule = true;
_exports.getDataFromTree = getDataFromTree;
_exports.getMarkupFromTree = getMarkupFromTree;
_exports.renderToStringWithData = renderToStringWithData;
_exports.useApolloClient = useApolloClient;
_exports.useLazyQuery = useLazyQuery;
_exports.useMutation = useMutation;
_exports.useQuery = useQuery;
_exports.useSubscription = useSubscription;
_exports.resetApolloContext = _exports.ApolloProvider = _exports.ApolloConsumer = void 0;
_exports.RenderPromises = _exports.resetApolloContext = _exports.ApolloProvider = _exports.ApolloConsumer = void 0;
_exports.getApolloContext = _reactCommon.getApolloContext;

@@ -35,3 +33,3 @@ _exports.ApolloConsumer = _reactCommon.ApolloConsumer;

function OperationData(options, context) {
this.isMounted = true;
this.isMounted = false;
this.previousOptions = {};

@@ -49,3 +47,3 @@ this.context = {};

OperationData.prototype.setOptions = function (newOptions) {
if (!(0, _apolloUtilities.isEqual)(this.options, newOptions)) {
if (!(0, _equality.equal)(this.options, newOptions)) {
this.previousOptions = this.options;

@@ -100,2 +98,19 @@ }

_this.currentObservable = {};
_this.runLazy = false;
_this.runLazyQuery = function (options) {
_this.runLazy = true;
_this.lazyOptions = options;
_this.forceUpdate();
};
_this.getExecuteResult = function () {
var result = _this.getQueryResult();
_this.startQuerySubscription();
return result;
};
_this.forceUpdate = forceUpdate;

@@ -106,4 +121,2 @@ return _this;

QueryData.prototype.execute = function () {
var _this = this;
this.refreshClient();

@@ -121,20 +134,13 @@

this.updateObservableQuery();
if (this.isMounted) this.startQuerySubscription();
return this.getExecuteSsrResult() || this.getExecuteResult();
};
if (!skip) {
this.startQuerySubscription();
}
var finish = function () {
return _this.getQueryResult();
};
if (this.context && this.context.renderPromises) {
var result = this.context.renderPromises.addQueryPromise(this, finish);
return result || {
loading: true,
networkStatus: _apolloClient.NetworkStatus.loading
};
}
return finish();
QueryData.prototype.executeLazy = function () {
return !this.runLazy ? [this.runLazyQuery, {
loading: false,
networkStatus: _apolloClient.NetworkStatus.ready,
called: false,
data: undefined
}] : [this.runLazyQuery, this.execute()];
};

@@ -170,9 +176,15 @@

var result = this.currentObservable.query.getCurrentResult();
return result.loading ? obs.result() : false;
var currentResult = this.currentObservable.query.getCurrentResult();
return currentResult.loading ? obs.result() : false;
};
QueryData.prototype.afterExecute = function () {
QueryData.prototype.afterExecute = function (_a) {
var _b = (_a === void 0 ? {} : _a).lazy,
lazy = _b === void 0 ? false : _b;
this.isMounted = true;
this.handleErrorOrCompleted();
if (!lazy || this.runLazy) {
this.handleErrorOrCompleted();
}
return this.unmount.bind(this);

@@ -183,6 +195,42 @@ };

this.removeQuerySubscription();
this.currentObservable.query = null;
this.previousData.result = null;
delete this.currentObservable.query;
delete this.previousData.result;
};
QueryData.prototype.getOptions = function () {
var options = _super.prototype.getOptions.call(this);
var lazyOptions = this.lazyOptions || {};
var updatedOptions = (0, _tslib.__assign)({}, options, {
variables: (0, _tslib.__assign)({}, options.variables, lazyOptions.variables),
context: (0, _tslib.__assign)({}, options.context, lazyOptions.context)
});
if (this.runLazy) {
delete updatedOptions.skip;
}
return updatedOptions;
};
QueryData.prototype.getExecuteSsrResult = function () {
var result;
var ssrLoading = {
loading: true,
networkStatus: _apolloClient.NetworkStatus.loading,
called: true,
data: {}
};
if (this.context && this.context.renderPromises) {
result = this.context.renderPromises.addQueryPromise(this, this.getExecuteResult);
if (!result) {
result = ssrLoading;
}
}
return result;
};
QueryData.prototype.updateCurrentData = function () {

@@ -243,3 +291,3 @@ if (this.isMounted) {

if (!(0, _apolloUtilities.isEqual)(newObservableQueryOptions, this.previousData.observableQueryOptions)) {
if (!(0, _equality.equal)(newObservableQueryOptions, this.previousData.observableQueryOptions)) {
this.previousData.observableQueryOptions = newObservableQueryOptions;

@@ -253,3 +301,3 @@ this.currentObservable.query.setOptions(newObservableQueryOptions).catch(function () {});

if (this.currentObservable.subscription) return;
if (this.currentObservable.subscription || this.getOptions().skip) return;
var obsQuery = this.currentObservable.query;

@@ -262,3 +310,3 @@ this.currentObservable.subscription = obsQuery.subscribe({

if (_this.previousData.result && _this.previousData.result.loading === loading && _this.previousData.result.networkStatus === networkStatus && (0, _apolloUtilities.isEqual)(_this.previousData.result.data, data || {})) {
if (_this.previousData.result && _this.previousData.result.loading === loading && _this.previousData.result.networkStatus === networkStatus && (0, _equality.equal)(_this.previousData.result.data, data || {})) {
return;

@@ -303,3 +351,4 @@ }

error: undefined,
loading: false
loading: false,
called: true
});

@@ -325,3 +374,4 @@ } else {

networkStatus: networkStatus,
error: error
error: error,
called: true
});

@@ -375,3 +425,3 @@

if (this.previousOptions && !this.previousData.loading && (0, _apolloUtilities.isEqual)(this.previousOptions.query, query) && (0, _apolloUtilities.isEqual)(this.previousOptions.variables, variables)) {
if (this.previousOptions && !this.previousData.loading && (0, _equality.equal)(this.previousOptions.query, query) && (0, _equality.equal)(this.previousOptions.variables, variables)) {
return;

@@ -398,3 +448,20 @@ }

function useQuery(query, options) {
function useDeepMemo(memoFn, key) {
var ref = (0, _react.useRef)();
if (!ref.current || !(0, _equality.equal)(key, ref.current.key)) {
ref.current = {
key: key,
value: memoFn()
};
}
return ref.current.value;
}
function useBaseQuery(query, options, lazy) {
if (lazy === void 0) {
lazy = false;
}
var context = (0, _react.useContext)((0, _reactCommon.getApolloContext)());

@@ -405,3 +472,3 @@

}, 0),
_ignored = _a[0],
tick = _a[0],
forceUpdate = _a[1];

@@ -416,23 +483,37 @@

function getQueryDataRef() {
if (!queryDataRef.current) {
queryDataRef.current = new QueryData({
options: updatedOptions,
context: context,
forceUpdate: forceUpdate
});
}
return queryDataRef.current;
if (!queryDataRef.current) {
queryDataRef.current = new QueryData({
options: updatedOptions,
context: context,
forceUpdate: forceUpdate
});
}
var queryData = getQueryDataRef();
var queryData = queryDataRef.current;
queryData.setOptions(updatedOptions);
queryData.context = context;
var memo = {
options: updatedOptions,
context: context,
tick: tick
};
var result = useDeepMemo(function () {
return lazy ? queryData.executeLazy() : queryData.execute();
}, memo);
(0, _react.useEffect)(function () {
return queryData.afterExecute();
});
return queryData.execute();
return queryData.afterExecute({
lazy: lazy
});
}, [result]);
return result;
}
function useQuery(query, options) {
return useBaseQuery(query, options, false);
}
function useLazyQuery(query, options) {
return useBaseQuery(query, options, true);
}
var MutationData = function (_super) {

@@ -460,2 +541,3 @@ (0, _tslib.__extends)(MutationData, _super);

this.isMounted = true;
this.verifyDocumentType(this.getOptions().mutation, _reactCommon.DocumentType.Mutation);

@@ -588,3 +670,3 @@

MutationData.prototype.updateResult = function (result) {
if (this.isMounted && (!this.previousResult || !(0, _apolloUtilities.isEqual)(this.previousResult, result))) {
if (this.isMounted && (!this.previousResult || !(0, _equality.equal)(this.previousResult, result))) {
this.setResult(result);

@@ -668,3 +750,3 @@ this.previousResult = result;

if (shouldResubscribe !== false && this.previousOptions && Object.keys(this.previousOptions).length > 0 && (this.previousOptions.subscription !== this.getOptions().subscription || !(0, _apolloUtilities.isEqual)(this.previousOptions.variables, this.getOptions().variables))) {
if (shouldResubscribe !== false && this.previousOptions && Object.keys(this.previousOptions).length > 0 && (this.previousOptions.subscription !== this.getOptions().subscription || !(0, _equality.equal)(this.previousOptions.variables, this.getOptions().variables))) {
this.endSubscription();

@@ -685,3 +767,2 @@ delete this.currentObservable.query;

this.isMounted = true;
return this.unmount.bind(this);
};

@@ -801,2 +882,5 @@

});
(0, _react.useEffect)(function () {
return subscriptionData.cleanup.bind(subscriptionData);
}, []);
return subscriptionData.execute(result);

@@ -875,44 +959,6 @@ }

return RenderPromises;
}();
}();
function getDataFromTree(tree, context) {
if (context === void 0) {
context = {};
}
return getMarkupFromTree({
tree: tree,
context: context,
renderFunction: require('react-dom/server').renderToStaticMarkup
});
}
function getMarkupFromTree(_a) {
var tree = _a.tree,
_b = _a.context,
context = _b === void 0 ? {} : _b,
_c = _a.renderFunction,
renderFunction = _c === void 0 ? require('react-dom/server').renderToStaticMarkup : _c;
var renderPromises = new RenderPromises();
function process() {
var ApolloContext = (0, _reactCommon.getApolloContext)();
var html = renderFunction(_react.default.createElement(ApolloContext.Provider, {
value: (0, _tslib.__assign)({}, context, {
renderPromises: renderPromises
})
}, tree));
return renderPromises.hasPromises() ? renderPromises.consumeAndAwaitPromises().then(process) : html;
}
return Promise.resolve().then(process);
}
function renderToStringWithData(component) {
return getMarkupFromTree({
tree: component,
renderFunction: require('react-dom/server').renderToString
});
}
_exports.RenderPromises = RenderPromises;
});

@@ -5,3 +5,3 @@ /// <reference types="zen-observable" />

import { Observable } from 'apollo-link';
import { OperationVariables, QueryFunctionOptions, QueryResult, BaseMutationOptions, MutationResult, MutationFunctionOptions, ExecutionResult, BaseSubscriptionOptions, SubscriptionResult } from '@apollo/react-common';
import { OperationVariables, QueryFunctionOptions, QueryResult, BaseMutationOptions, MutationResult, MutationFunctionOptions, ExecutionResult, BaseSubscriptionOptions, SubscriptionResult, Context } from '@apollo/react-common';
import { DocumentNode } from 'graphql';

@@ -18,2 +18,5 @@ export declare type CommonOptions<TOptions> = TOptions & {

}
export interface LazyQueryHookOptions<TData = any, TVariables = OperationVariables> extends Omit<QueryFunctionOptions<TData, TVariables>, 'skip'> {
query?: DocumentNode;
}
export interface QueryPreviousData<TData, TVariables> {

@@ -31,2 +34,7 @@ client?: ApolloClient<object>;

}
export interface QueryLazyOptions<TVariables> {
variables?: TVariables;
context?: Context;
}
export declare type QueryTuple<TData, TVariables> = [(options?: QueryLazyOptions<TVariables>) => void, QueryResult<TData, TVariables>];
export interface MutationHookOptions<TData = any, TVariables = OperationVariables> extends BaseMutationOptions<TData, TVariables> {

@@ -33,0 +41,0 @@ mutation?: DocumentNode;

@@ -1,26 +0,5 @@

import * as tslib_1 from "tslib";
import { useContext, useEffect, useReducer, useRef } from 'react';
import { getApolloContext } from '@apollo/react-common';
import { QueryData } from './data/QueryData';
import { useBaseQuery } from './utils/useBaseQuery';
export function useQuery(query, options) {
var context = useContext(getApolloContext());
var _a = useReducer(function (x) { return x + 1; }, 0), _ignored = _a[0], forceUpdate = _a[1];
var updatedOptions = options ? tslib_1.__assign({}, options, { query: query }) : { query: query };
var queryDataRef = useRef();
function getQueryDataRef() {
if (!queryDataRef.current) {
queryDataRef.current = new QueryData({
options: updatedOptions,
context: context,
forceUpdate: forceUpdate
});
}
return queryDataRef.current;
}
var queryData = getQueryDataRef();
queryData.setOptions(updatedOptions);
queryData.context = context;
useEffect(function () { return queryData.afterExecute(); });
return queryData.execute();
return useBaseQuery(query, options, false);
}
//# sourceMappingURL=useQuery.js.map

@@ -29,4 +29,5 @@ import * as tslib_1 from "tslib";

useEffect(function () { return subscriptionData.afterExecute(); });
useEffect(function () { return subscriptionData.cleanup.bind(subscriptionData); }, []);
return subscriptionData.execute(result);
}
//# sourceMappingURL=useSubscription.js.map
{
"name": "@apollo/react-hooks",
"description": "React Apollo Hooks.",
"version": "0.1.0-beta.10",
"version": "0.1.0-beta.11",
"author": "opensource@apollographql.com",

@@ -25,3 +25,3 @@ "keywords": [

"scripts": {
"clean": "rm -Rf ./lib/* ./meta/bundlesize/* ./meta/coverage/*",
"clean": "rm -Rf ./lib/* ./meta/bundlesize/* ./meta/coverage/* ./.rpt2_cache",
"prepare": "npm run build",

@@ -46,4 +46,4 @@ "prebuild": "npm run clean",

"dependencies": {
"@apollo/react-common": "^0.1.0-beta.8",
"apollo-utilities": "^1.3.2",
"@apollo/react-common": "^0.1.0-beta.9",
"@wry/equality": "^0.1.9",
"ts-invariant": "^0.4.4",

@@ -59,8 +59,8 @@ "tslib": "^1.10.0"

"devDependencies": {
"jest": "^24.8.0",
"rollup": "1.16.2",
"tsc-watch": "^2.2.1",
"typescript": "^3.5.2"
"jest": "24.8.0",
"rollup": "1.16.7",
"tsc-watch": "2.2.1",
"typescript": "3.5.3"
},
"gitHead": "808e66755990a649202a662a6c6e8b8d20a0e9fb"
"gitHead": "bd87da901113c81e3e7e2a7edaeac791895abb96"
}

@@ -17,6 +17,8 @@ # <a href="https://www.apollographql.com/"><img src="https://user-images.githubusercontent.com/841294/53402609-b97a2180-39ba-11e9-8100-812bab86357c.png" height="100" alt="React Apollo"></a>

2. [Hooks Overview](#hooks-overview)
- [`useQuery`](#useQuery)
- [`useMutation`](#useMutation)
- [`useSubscription`](#useSubscription)
- [`useApolloClient`](#useApolloClient)
- [`useQuery`](#useQuery)
- [`useMutation`](#useMutation)
- [`useSubscription`](#useSubscription)
- [`useApolloClient`](#useApolloClient)
3. [Reference]()

@@ -33,2 +35,3 @@

<a name="useQuery"></a>
#### a) [`useQuery`](https://github.com/apollographql/react-apollo/blob/release-3.0.0/packages/hooks/src/useQuery.ts)

@@ -42,3 +45,3 @@

options?: QueryHookOptions<TData, TVariables>
): QueryResult<TData, TVariables>
): QueryResult<TData, TVariables>;
```

@@ -128,2 +131,3 @@

<a name="useMutation"></a>
#### b) [`useMutation`](https://github.com/apollographql/react-apollo/blob/release-3.0.0/packages/hooks/src/useMutation.ts)

@@ -137,3 +141,3 @@

options?: MutationHookOptions<TData, TVariables>
): MutationTuple<TData, TVariables>
): MutationTuple<TData, TVariables>;
```

@@ -269,2 +273,3 @@

<a name="useSubscription"></a>
#### c) [`useSubscription`](https://github.com/apollographql/react-apollo/blob/release-3.0.0/packages/hooks/src/useSubscription.ts)

@@ -278,3 +283,3 @@

options?: SubscriptionHookOptions<TData, TVariables>
)
);
```

@@ -321,2 +326,3 @@

<a name="useApolloClient"></a>
#### d) [`useApolloClient`](https://github.com/apollographql/react-apollo/blob/release-3.0.0/packages/hooks/src/useApolloClient.ts)

@@ -327,3 +333,3 @@

```ts
export function useApolloClient(): ApolloClient<object>
export function useApolloClient(): ApolloClient<object>;
```

@@ -347,5 +353,1 @@

- Need help? Join us in the [Apollo Spectrum community](https://spectrum.chat/apollo)

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

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