@apollo/client
Advanced tools
Comparing version 0.0.0-pr-11617-20240226102810 to 0.0.0-pr-11617-20240226143959
@@ -431,3 +431,3 @@ 'use strict'; | ||
var version = "0.0.0-pr-11617-20240226102810"; | ||
var version = "0.0.0-pr-11617-20240226143959"; | ||
@@ -434,0 +434,0 @@ function maybe(thunk) { |
{ | ||
"name": "@apollo/client", | ||
"version": "0.0.0-pr-11617-20240226102810", | ||
"version": "0.0.0-pr-11617-20240226143959", | ||
"description": "A fully-featured caching GraphQL client.", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -133,3 +133,3 @@ 'use strict'; | ||
/*#__NO_SIDE_EFFECTS__*/ | ||
function makeHookWrappable(hookName, useHook, getClientFromOptions) { | ||
function makeHookWrappable(hookName, getClientFromOptions, useHook) { | ||
return function () { | ||
@@ -146,8 +146,10 @@ var args = arguments; | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function useQuery(query, options) { | ||
function useQuery() { | ||
useQuery = makeHookWrappable("useQuery", function (_, options) { return useApolloClient(options && options.client); }, _useQuery); | ||
return useQuery.apply(null, arguments); | ||
} | ||
function _useQuery(query, options) { | ||
if (options === void 0) { options = Object.create(null); } | ||
return useInternalState(useApolloClient(options.client), query).useQuery(options); | ||
} | ||
var wrapped$4 = /*#__PURE__*/ makeHookWrappable("useQuery", useQuery, function (_, options) { return useApolloClient(options && options.client); }); | ||
useQuery = wrapped$4; | ||
function useInternalState(client, query) { | ||
@@ -755,3 +757,7 @@ var stateRef = React__namespace.useRef(); | ||
function useFragment(options) { | ||
function useFragment() { | ||
useFragment = makeHookWrappable("useFragment", function (options) { return useApolloClient(options.client); }, _useFragment); | ||
return useFragment.apply(null, arguments); | ||
} | ||
function _useFragment(options) { | ||
var cache = useApolloClient(options.client).cache; | ||
@@ -781,4 +787,2 @@ var diffOptions = useDeepMemo(function () { | ||
} | ||
var wrapped$3 = /*#__PURE__*/ makeHookWrappable("useFragment", useFragment, function (options) { return useApolloClient(options.client); }); | ||
useFragment = wrapped$3; | ||
function diffToResult(diff) { | ||
@@ -797,3 +801,9 @@ var result = { | ||
function useSuspenseQuery(query, options) { | ||
function useSuspenseQuery() { | ||
useSuspenseQuery = makeHookWrappable("useSuspenseQuery", function (_, options) { | ||
return useApolloClient(typeof options === "object" ? options.client : undefined); | ||
}, _useSuspenseQuery); | ||
return useSuspenseQuery.apply(null, arguments); | ||
} | ||
function _useSuspenseQuery(query, options) { | ||
if (options === void 0) { options = Object.create(null); } | ||
@@ -868,6 +878,2 @@ var client = useApolloClient(options.client); | ||
} | ||
var wrapped$2 = /*#__PURE__*/ makeHookWrappable("useSuspenseQuery", useSuspenseQuery, function (_, options) { | ||
return useApolloClient(typeof options === "object" ? options.client : undefined); | ||
}); | ||
useSuspenseQuery = wrapped$2; | ||
function validateOptions(options) { | ||
@@ -920,3 +926,9 @@ var query = options.query, fetchPolicy = options.fetchPolicy, returnPartialData = options.returnPartialData; | ||
function useBackgroundQuery(query, options) { | ||
function useBackgroundQuery() { | ||
useBackgroundQuery = makeHookWrappable("useBackgroundQuery", function (_, options) { | ||
return useApolloClient(typeof options === "object" ? options.client : undefined); | ||
}, _useBackgroundQuery); | ||
return useBackgroundQuery.apply(null, arguments); | ||
} | ||
function _useBackgroundQuery(query, options) { | ||
if (options === void 0) { options = Object.create(null); } | ||
@@ -960,6 +972,2 @@ var client = useApolloClient(options.client); | ||
} | ||
var wrapped$1 = /*#__PURE__*/ makeHookWrappable("useBackgroundQuery", useBackgroundQuery, function (_, options) { | ||
return useApolloClient(typeof options === "object" ? options.client : undefined); | ||
}); | ||
useBackgroundQuery = wrapped$1; | ||
@@ -1041,3 +1049,7 @@ function useLoadableQuery(query, options) { | ||
function useReadQuery(queryRef) { | ||
function useReadQuery() { | ||
useReadQuery = makeHookWrappable("useReadQuery", function (ref) { return internal.unwrapQueryRef(ref)["observable"]; }, _useReadQuery); | ||
return useReadQuery.apply(null, arguments); | ||
} | ||
function _useReadQuery(queryRef) { | ||
var internalQueryRef = React__namespace.useMemo(function () { return internal.unwrapQueryRef(queryRef); }, [queryRef]); | ||
@@ -1065,4 +1077,2 @@ var getPromise = React__namespace.useCallback(function () { return internal.getWrappedPromise(queryRef); }, [queryRef]); | ||
} | ||
var wrapped = /*#__PURE__*/ makeHookWrappable("useReadQuery", useReadQuery, function (ref) { return internal.unwrapQueryRef(ref)["observable"]; }); | ||
useReadQuery = wrapped; | ||
@@ -1069,0 +1079,0 @@ exports.skipToken = skipToken; |
@@ -45,4 +45,4 @@ import type { useQuery, useSuspenseQuery, useBackgroundQuery, useReadQuery, useFragment } from "../index.js"; | ||
*/ | ||
export declare function makeHookWrappable<Name extends keyof WrappableHooks>(hookName: Name, useHook: WrappableHooks[Name], getClientFromOptions: (...args: Parameters<WrappableHooks[Name]>) => ObservableQuery<any> | ApolloClient<any>): WrappableHooks[Name]; | ||
export declare function makeHookWrappable<Name extends keyof WrappableHooks>(hookName: Name, getClientFromOptions: (...args: Parameters<WrappableHooks[Name]>) => ObservableQuery<any> | ApolloClient<any>, useHook: WrappableHooks[Name]): WrappableHooks[Name]; | ||
export {}; | ||
//# sourceMappingURL=wrapHook.d.ts.map |
@@ -29,3 +29,3 @@ var wrapperSymbol = Symbol.for("apollo.hook.wrappers"); | ||
/*#__NO_SIDE_EFFECTS__*/ | ||
export function makeHookWrappable(hookName, useHook, getClientFromOptions) { | ||
export function makeHookWrappable(hookName, getClientFromOptions, useHook) { | ||
return function () { | ||
@@ -32,0 +32,0 @@ var args = arguments; |
@@ -8,3 +8,10 @@ import { __spreadArray } from "tslib"; | ||
import { canonicalStringify } from "../../cache/index.js"; | ||
export function useBackgroundQuery(query, options) { | ||
export function useBackgroundQuery() { | ||
// @ts-expect-error Cannot assign to 'useBackgroundQuery' because it is a function.ts(2630) | ||
useBackgroundQuery = makeHookWrappable("useBackgroundQuery", function (_, options) { | ||
return useApolloClient(typeof options === "object" ? options.client : undefined); | ||
}, _useBackgroundQuery); | ||
return useBackgroundQuery.apply(null, arguments); | ||
} | ||
function _useBackgroundQuery(query, options) { | ||
if (options === void 0) { options = Object.create(null); } | ||
@@ -54,7 +61,2 @@ var client = useApolloClient(options.client); | ||
} | ||
var wrapped = /*#__PURE__*/ makeHookWrappable("useBackgroundQuery", useBackgroundQuery, function (_, options) { | ||
return useApolloClient(typeof options === "object" ? options.client : undefined); | ||
}); | ||
// @ts-expect-error Cannot assign to 'useBackgroundQuery' because it is a function.ts(2630) | ||
useBackgroundQuery = wrapped; | ||
//# sourceMappingURL=useBackgroundQuery.js.map |
@@ -8,3 +8,8 @@ import { __assign, __rest } from "tslib"; | ||
import { useDeepMemo, useLazyRef, makeHookWrappable, } from "./internal/index.js"; | ||
export function useFragment(options) { | ||
export function useFragment() { | ||
// @ts-expect-error Cannot assign to 'useFragment' because it is a function.ts(2630) | ||
useFragment = makeHookWrappable("useFragment", function (options) { return useApolloClient(options.client); }, _useFragment); | ||
return useFragment.apply(null, arguments); | ||
} | ||
function _useFragment(options) { | ||
var cache = useApolloClient(options.client).cache; | ||
@@ -39,5 +44,2 @@ var diffOptions = useDeepMemo(function () { | ||
} | ||
var wrapped = /*#__PURE__*/ makeHookWrappable("useFragment", useFragment, function (options) { return useApolloClient(options.client); }); | ||
// @ts-expect-error Cannot assign to 'useFragment' because it is a function.ts(2630) | ||
useFragment = wrapped; | ||
function diffToResult(diff) { | ||
@@ -44,0 +46,0 @@ var result = { |
@@ -15,43 +15,11 @@ import { __assign, __rest } from "tslib"; | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
/** | ||
* A hook for executing queries in an Apollo application. | ||
* | ||
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document. | ||
* | ||
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, and `data` properties you can use to render your UI. | ||
* | ||
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`. | ||
* | ||
* @example | ||
* ```jsx | ||
* import { gql, useQuery } from '@apollo/client'; | ||
* | ||
* const GET_GREETING = gql` | ||
* query GetGreeting($language: String!) { | ||
* greeting(language: $language) { | ||
* message | ||
* } | ||
* } | ||
* `; | ||
* | ||
* function Hello() { | ||
* const { loading, error, data } = useQuery(GET_GREETING, { | ||
* variables: { language: 'english' }, | ||
* }); | ||
* if (loading) return <p>Loading ...</p>; | ||
* return <h1>Hello {data.greeting.message}!</h1>; | ||
* } | ||
* ``` | ||
* @since 3.0.0 | ||
* @param query - A GraphQL query document parsed into an AST by `gql`. | ||
* @param options - Options to control how the query is executed. | ||
* @returns Query result object | ||
*/ | ||
export function useQuery(query, options) { | ||
export function useQuery() { | ||
// @ts-expect-error Cannot assign to 'useQuery' because it is a function. ts(2630) | ||
useQuery = makeHookWrappable("useQuery", function (_, options) { return useApolloClient(options && options.client); }, _useQuery); | ||
return useQuery.apply(null, arguments); | ||
} | ||
function _useQuery(query, options) { | ||
if (options === void 0) { options = Object.create(null); } | ||
return useInternalState(useApolloClient(options.client), query).useQuery(options); | ||
} | ||
var wrapped = /*#__PURE__*/ makeHookWrappable("useQuery", useQuery, function (_, options) { return useApolloClient(options && options.client); }); | ||
// @ts-expect-error Cannot assign to 'useQuery' because it is a function.ts(2630) | ||
useQuery = wrapped; | ||
export function useInternalState(client, query) { | ||
@@ -58,0 +26,0 @@ var stateRef = React.useRef(); |
@@ -6,3 +6,8 @@ import * as React from "rehackt"; | ||
import { useSyncExternalStore } from "./useSyncExternalStore.js"; | ||
export function useReadQuery(queryRef) { | ||
export function useReadQuery() { | ||
// @ts-expect-error Cannot assign to 'useReadQuery' because it is a function.ts(2630) | ||
useReadQuery = makeHookWrappable("useReadQuery", function (ref) { return unwrapQueryRef(ref)["observable"]; }, _useReadQuery); | ||
return useReadQuery.apply(null, arguments); | ||
} | ||
function _useReadQuery(queryRef) { | ||
var internalQueryRef = React.useMemo(function () { return unwrapQueryRef(queryRef); }, [queryRef]); | ||
@@ -30,5 +35,2 @@ var getPromise = React.useCallback(function () { return getWrappedPromise(queryRef); }, [queryRef]); | ||
} | ||
var wrapped = /*#__PURE__*/ makeHookWrappable("useReadQuery", useReadQuery, function (ref) { return unwrapQueryRef(ref)["observable"]; }); | ||
// @ts-expect-error Cannot assign to 'useReadQuery' because it is a function.ts(2630) | ||
useReadQuery = wrapped; | ||
//# sourceMappingURL=useReadQuery.js.map |
@@ -12,3 +12,10 @@ import { __assign, __spreadArray } from "tslib"; | ||
import { skipToken } from "./constants.js"; | ||
export function useSuspenseQuery(query, options) { | ||
export function useSuspenseQuery() { | ||
// @ts-expect-error Cannot assign to 'useSuspenseQuery' because it is a function. ts(2630) | ||
useSuspenseQuery = makeHookWrappable("useSuspenseQuery", function (_, options) { | ||
return useApolloClient(typeof options === "object" ? options.client : undefined); | ||
}, _useSuspenseQuery); | ||
return useSuspenseQuery.apply(null, arguments); | ||
} | ||
function _useSuspenseQuery(query, options) { | ||
if (options === void 0) { options = Object.create(null); } | ||
@@ -84,7 +91,2 @@ var client = useApolloClient(options.client); | ||
} | ||
var wrapped = /*#__PURE__*/ makeHookWrappable("useSuspenseQuery", useSuspenseQuery, function (_, options) { | ||
return useApolloClient(typeof options === "object" ? options.client : undefined); | ||
}); | ||
// @ts-expect-error Cannot assign to 'useSuspenseQuery' because it is a function.ts(2630) | ||
useSuspenseQuery = wrapped; | ||
function validateOptions(options) { | ||
@@ -91,0 +93,0 @@ var query = options.query, fetchPolicy = options.fetchPolicy, returnPartialData = options.returnPartialData; |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var version = "0.0.0-pr-11617-20240226102810"; | ||
var version = "0.0.0-pr-11617-20240226143959"; | ||
@@ -10,0 +10,0 @@ function maybe(thunk) { |
@@ -1,2 +0,2 @@ | ||
export var version = "0.0.0-pr-11617-20240226102810"; | ||
export var version = "0.0.0-pr-11617-20240226143959"; | ||
//# 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57919
6660118