Socket
Socket
Sign inDemoInstall

@apollo/client

Package Overview
Dependencies
Maintainers
4
Versions
575
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 3.9.5 to 3.9.6

react/hooks/internal/wrapHook.d.ts

2

dev/dev.cjs.native.js

@@ -431,3 +431,3 @@ 'use strict';

var version = "3.9.5";
var version = "3.9.6";

@@ -434,0 +434,0 @@ function maybe(thunk) {

{
"name": "@apollo/client",
"version": "3.9.5",
"version": "3.9.6",
"description": "A fully-featured caching GraphQL client.",

@@ -62,3 +62,3 @@ "private": false,

"prop-types": "^15.7.2",
"rehackt": "0.0.5",
"rehackt": "0.0.6",
"response-iterator": "^0.2.6",

@@ -71,8 +71,8 @@ "symbol-observable": "^4.0.0",

"devDependencies": {
"@arethetypeswrong/cli": "0.13.8",
"@arethetypeswrong/cli": "0.13.10",
"@babel/parser": "7.23.9",
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.1",
"@graphql-tools/schema": "10.0.2",
"@microsoft/api-extractor": "7.40.1",
"@graphql-tools/schema": "10.0.3",
"@microsoft/api-extractor": "7.40.2",
"@rollup/plugin-node-resolve": "11.2.1",

@@ -92,13 +92,13 @@ "@size-limit/esbuild-why": "11.0.2",

"@types/lodash": "4.14.202",
"@types/node": "20.11.17",
"@types/node": "20.11.24",
"@types/node-fetch": "2.6.11",
"@types/react": "18.2.55",
"@types/react": "18.2.61",
"@types/react-dom": "18.2.19",
"@types/relay-runtime": "14.1.23",
"@types/use-sync-external-store": "0.0.6",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"@typescript-eslint/rule-tester": "6.21.0",
"@typescript-eslint/types": "6.21.0",
"@typescript-eslint/utils": "6.21.0",
"@typescript-eslint/eslint-plugin": "7.0.1",
"@typescript-eslint/parser": "7.0.1",
"@typescript-eslint/rule-tester": "7.0.1",
"@typescript-eslint/types": "7.0.1",
"@typescript-eslint/utils": "7.0.1",
"acorn": "8.11.3",

@@ -128,4 +128,4 @@ "blob-polyfill": "7.0.20220408",

"react-dom-17": "npm:react-dom@^17",
"react-error-boundary": "4.0.12",
"recast": "0.23.4",
"react-error-boundary": "4.0.13",
"recast": "0.23.5",
"resolve": "1.22.8",

@@ -139,3 +139,3 @@ "rimraf": "5.0.5",

"subscriptions-transport-ws": "0.11.0",
"terser": "5.27.0",
"terser": "5.27.1",
"ts-api-utils": "1.2.1",

@@ -149,3 +149,3 @@ "ts-jest": "29.1.2",

"wait-for-observables": "1.0.3",
"web-streams-polyfill": "3.3.2",
"web-streams-polyfill": "3.3.3",
"whatwg-fetch": "3.6.20"

@@ -152,0 +152,0 @@ },

@@ -87,5 +87,60 @@ 'use strict';

function useDeepMemo(memoFn, deps) {
var ref = React__namespace.useRef();
if (!ref.current || !equality.equal(ref.current.deps, deps)) {
ref.current = { value: memoFn(), deps: deps };
}
return ref.current.value;
}
function getRenderDispatcher() {
var _a, _b;
return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
}
var RenderDispatcher = null;
function useRenderGuard() {
RenderDispatcher = getRenderDispatcher();
return React__namespace.useCallback(function () {
return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher());
}, []);
}
var INIT = {};
function useLazyRef(getInitialValue) {
var ref = React__namespace.useRef(INIT);
if (ref.current === INIT) {
ref.current = getInitialValue();
}
return ref;
}
var useKey = "use";
var realHook = React__namespace[useKey];
var __use = realHook ||
function __use(promise) {
var statefulPromise = utilities.wrapPromiseWithState(promise);
switch (statefulPromise.status) {
case "pending":
throw statefulPromise;
case "rejected":
throw statefulPromise.reason;
case "fulfilled":
return statefulPromise.value;
}
};
var wrapperSymbol = Symbol.for("apollo.hook.wrappers");
function wrapHook(hookName, useHook, clientOrObsQuery) {
var queryManager = clientOrObsQuery["queryManager"];
var wrappers = queryManager && queryManager[wrapperSymbol];
var wrapper = wrappers && wrappers[hookName];
return wrapper ? wrapper(useHook) : useHook;
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
function useQuery(query, options) {
if (options === void 0) { options = Object.create(null); }
return wrapHook("useQuery", _useQuery, useApolloClient(options && options.client))(query, options);
}
function _useQuery(query, options) {
return useInternalState(useApolloClient(options.client), query).useQuery(options);

@@ -695,47 +750,6 @@ }

function useDeepMemo(memoFn, deps) {
var ref = React__namespace.useRef();
if (!ref.current || !equality.equal(ref.current.deps, deps)) {
ref.current = { value: memoFn(), deps: deps };
}
return ref.current.value;
function useFragment(options) {
return wrapHook("useFragment", _useFragment, useApolloClient(options.client))(options);
}
function getRenderDispatcher() {
var _a, _b;
return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
}
var RenderDispatcher = null;
function useRenderGuard() {
RenderDispatcher = getRenderDispatcher();
return React__namespace.useCallback(function () {
return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher());
}, []);
}
var INIT = {};
function useLazyRef(getInitialValue) {
var ref = React__namespace.useRef(INIT);
if (ref.current === INIT) {
ref.current = getInitialValue();
}
return ref;
}
var useKey = "use";
var realHook = React__namespace[useKey];
var __use = realHook ||
function __use(promise) {
var statefulPromise = utilities.wrapPromiseWithState(promise);
switch (statefulPromise.status) {
case "pending":
throw statefulPromise;
case "rejected":
throw statefulPromise.reason;
case "fulfilled":
return statefulPromise.value;
}
};
function useFragment(options) {
function _useFragment(options) {
var cache = useApolloClient(options.client).cache;

@@ -780,2 +794,5 @@ var diffOptions = useDeepMemo(function () {

if (options === void 0) { options = Object.create(null); }
return wrapHook("useSuspenseQuery", _useSuspenseQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
}
function _useSuspenseQuery(query, options) {
var client = useApolloClient(options.client);

@@ -898,2 +915,5 @@ var suspenseCache = internal.getSuspenseCache(client);

if (options === void 0) { options = Object.create(null); }
return wrapHook("useBackgroundQuery", _useBackgroundQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
}
function _useBackgroundQuery(query, options) {
var client = useApolloClient(options.client);

@@ -1013,2 +1033,5 @@ var suspenseCache = internal.getSuspenseCache(client);

function useReadQuery(queryRef) {
return wrapHook("useReadQuery", _useReadQuery, internal.unwrapQueryRef(queryRef)["observable"])(queryRef);
}
function _useReadQuery(queryRef) {
var internalQueryRef = React__namespace.useMemo(function () { return internal.unwrapQueryRef(queryRef); }, [queryRef]);

@@ -1015,0 +1038,0 @@ var getPromise = React__namespace.useCallback(function () { return internal.getWrappedPromise(queryRef); }, [queryRef]);

@@ -6,2 +6,3 @@ export { useDeepMemo } from "./useDeepMemo.js";

export { __use } from "./__use.js";
export { wrapHook } from "./wrapHook.js";
//# sourceMappingURL=index.d.ts.map

@@ -7,2 +7,3 @@ // These hooks are used internally and are not exported publicly by the library

export { __use } from "./__use.js";
export { wrapHook } from "./wrapHook.js";
//# sourceMappingURL=index.js.map

@@ -5,2 +5,3 @@ import { __spreadArray } from "tslib";

import { getSuspenseCache, unwrapQueryRef, updateWrappedQueryRef, wrapQueryRef, } from "../internal/index.js";
import { wrapHook } from "./internal/index.js";
import { useWatchQueryOptions } from "./useSuspenseQuery.js";

@@ -10,2 +11,5 @@ import { canonicalStringify } from "../../cache/index.js";

if (options === void 0) { options = Object.create(null); }
return wrapHook("useBackgroundQuery", _useBackgroundQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
}
function _useBackgroundQuery(query, options) {
var client = useApolloClient(options.client);

@@ -12,0 +16,0 @@ var suspenseCache = getSuspenseCache(client);

@@ -7,4 +7,7 @@ import { __assign, __rest } from "tslib";

import { useSyncExternalStore } from "./useSyncExternalStore.js";
import { useDeepMemo, useLazyRef } from "./internal/index.js";
import { useDeepMemo, useLazyRef, wrapHook } from "./internal/index.js";
export function useFragment(options) {
return wrapHook("useFragment", _useFragment, useApolloClient(options.client))(options);
}
function _useFragment(options) {
var cache = useApolloClient(options.client).cache;

@@ -11,0 +14,0 @@ var diffOptions = useDeepMemo(function () {

@@ -13,2 +13,3 @@ import { __assign, __rest } from "tslib";

import { canUseWeakMap, compact, isNonEmptyArray, maybeDeepFreeze, } from "../../utilities/index.js";
import { wrapHook } from "./internal/index.js";
var hasOwnProperty = Object.prototype.hasOwnProperty;

@@ -51,2 +52,5 @@ /**

if (options === void 0) { options = Object.create(null); }
return wrapHook("useQuery", _useQuery, useApolloClient(options && options.client))(query, options);
}
function _useQuery(query, options) {
return useInternalState(useApolloClient(options.client), query).useQuery(options);

@@ -53,0 +57,0 @@ }

import * as React from "rehackt";
import { getWrappedPromise, unwrapQueryRef, updateWrappedQueryRef, } from "../internal/index.js";
import { __use } from "./internal/index.js";
import { __use, wrapHook } from "./internal/index.js";
import { toApolloError } from "./useSuspenseQuery.js";
import { useSyncExternalStore } from "./useSyncExternalStore.js";
export function useReadQuery(queryRef) {
return wrapHook("useReadQuery", _useReadQuery, unwrapQueryRef(queryRef)["observable"])(queryRef);
}
function _useReadQuery(queryRef) {
var internalQueryRef = React.useMemo(function () { return unwrapQueryRef(queryRef); }, [queryRef]);

@@ -8,0 +11,0 @@ var getPromise = React.useCallback(function () { return getWrappedPromise(queryRef); }, [queryRef]);

@@ -8,3 +8,3 @@ import { __assign, __spreadArray } from "tslib";

import { DocumentType, verifyDocumentType } from "../parser/index.js";
import { __use, useDeepMemo } from "./internal/index.js";
import { __use, useDeepMemo, wrapHook } from "./internal/index.js";
import { getSuspenseCache } from "../internal/index.js";

@@ -15,2 +15,5 @@ import { canonicalStringify } from "../../cache/index.js";

if (options === void 0) { options = Object.create(null); }
return wrapHook("useSuspenseQuery", _useSuspenseQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
}
function _useSuspenseQuery(query, options) {
var client = useApolloClient(options.client);

@@ -17,0 +20,0 @@ var suspenseCache = getSuspenseCache(client);

@@ -240,7 +240,19 @@ import { __assign } from "tslib";

.then(function (result) {
var _a;
if (_this.promise.status === "pending") {
_this.result = result;
(_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
}
// In the case of `fetchMore`, this promise is resolved before a cache
// result is emitted due to the fact that `fetchMore` sets a `no-cache`
// fetch policy and runs `cache.batch` in its `.then` handler. Because
// the timing is different, we accidentally run this update twice
// causing an additional re-render with the `fetchMore` result by
// itself. By wrapping in `setTimeout`, this should provide a short
// delay to allow the `QueryInfo.notify` handler to run before this
// promise is checked.
// See https://github.com/apollographql/apollo-client/issues/11315 for
// more information
setTimeout(function () {
var _a;
if (_this.promise.status === "pending") {
_this.result = result;
(_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
}
});
})

@@ -247,0 +259,0 @@ .catch(function () { });

@@ -6,2 +6,3 @@ export { getSuspenseCache } from "./cache/getSuspenseCache.js";

export type { SuspenseCacheOptions } from "./cache/SuspenseCache.js";
export type { HookWrappers } from "../hooks/internal/wrapHook.js";
//# sourceMappingURL=index.d.ts.map

@@ -211,7 +211,9 @@ 'use strict';

.then(function (result) {
var _a;
if (_this.promise.status === "pending") {
_this.result = result;
(_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
}
setTimeout(function () {
var _a;
if (_this.promise.status === "pending") {
_this.result = result;
(_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
}
});
})

@@ -218,0 +220,0 @@ .catch(function () { });

@@ -29,3 +29,3 @@ import { __makeTemplateObject, __spreadArray } from "tslib";

export function setupPaginatedCase() {
var query = gql(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n query letters($limit: Int, $offset: Int) {\n letters(limit: $limit) {\n letter\n position\n }\n }\n "], ["\n query letters($limit: Int, $offset: Int) {\n letters(limit: $limit) {\n letter\n position\n }\n }\n "])));
var query = gql(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n query LettersQuery($limit: Int, $offset: Int) {\n letters(limit: $limit, offset: $offset) {\n letter\n position\n }\n }\n "], ["\n query LettersQuery($limit: Int, $offset: Int) {\n letters(limit: $limit, offset: $offset) {\n letter\n position\n }\n }\n "])));
var data = "ABCDEFGHIJKLMNOPQRSTUV".split("").map(function (letter, index) { return ({

@@ -32,0 +32,0 @@ __typename: "Letter",

@@ -7,3 +7,3 @@ 'use strict';

var version = "3.9.5";
var version = "3.9.6";

@@ -10,0 +10,0 @@ function maybe(thunk) {

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

export var version = "3.9.5";
export var version = "3.9.6";
//# sourceMappingURL=version.js.map

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 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 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

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

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