@apollo/client
Advanced tools
Comparing version 0.0.0-pr-11617-20240226102810 to 0.0.0-pr-11622-20240226120051
@@ -431,3 +431,3 @@ 'use strict'; | ||
var version = "0.0.0-pr-11617-20240226102810"; | ||
var version = "0.0.0-pr-11622-20240226120051"; | ||
@@ -434,0 +434,0 @@ function maybe(thunk) { |
{ | ||
"name": "@apollo/client", | ||
"version": "0.0.0-pr-11617-20240226102810", | ||
"version": "0.0.0-pr-11622-20240226120051", | ||
"description": "A fully-featured caching GraphQL client.", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -791,4 +791,31 @@ 'use strict'; | ||
function toApolloError(result) { | ||
return utilities.isNonEmptyArray(result.errors) ? | ||
new core.ApolloError({ graphQLErrors: result.errors }) | ||
: result.error; | ||
} | ||
var skipToken = Symbol.for("apollo.skipToken"); | ||
function useWatchQueryOptions(_a) { | ||
var client = _a.client, query = _a.query, options = _a.options; | ||
return useDeepMemo(function () { | ||
var _a; | ||
if (options === skipToken) { | ||
return { query: query, fetchPolicy: "standby" }; | ||
} | ||
var fetchPolicy = options.fetchPolicy || | ||
((_a = client.defaultOptions.watchQuery) === null || _a === void 0 ? void 0 : _a.fetchPolicy) || | ||
"cache-first"; | ||
var watchQueryOptions = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: fetchPolicy, query: query, notifyOnNetworkStatusChange: false, nextFetchPolicy: void 0 }); | ||
if (globalThis.__DEV__ !== false) { | ||
validateOptions(watchQueryOptions); | ||
} | ||
if (options.skip) { | ||
watchQueryOptions.fetchPolicy = "standby"; | ||
} | ||
return watchQueryOptions; | ||
}, [client, options, query]); | ||
} | ||
function useSuspenseQuery(query, options) { | ||
@@ -889,27 +916,2 @@ if (options === void 0) { options = Object.create(null); } | ||
} | ||
function toApolloError(result) { | ||
return utilities.isNonEmptyArray(result.errors) ? | ||
new core.ApolloError({ graphQLErrors: result.errors }) | ||
: result.error; | ||
} | ||
function useWatchQueryOptions(_a) { | ||
var client = _a.client, query = _a.query, options = _a.options; | ||
return useDeepMemo(function () { | ||
var _a; | ||
if (options === skipToken) { | ||
return { query: query, fetchPolicy: "standby" }; | ||
} | ||
var fetchPolicy = options.fetchPolicy || | ||
((_a = client.defaultOptions.watchQuery) === null || _a === void 0 ? void 0 : _a.fetchPolicy) || | ||
"cache-first"; | ||
var watchQueryOptions = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: fetchPolicy, query: query, notifyOnNetworkStatusChange: false, nextFetchPolicy: void 0 }); | ||
if (globalThis.__DEV__ !== false) { | ||
validateOptions(watchQueryOptions); | ||
} | ||
if (options.skip) { | ||
watchQueryOptions.fetchPolicy = "standby"; | ||
} | ||
return watchQueryOptions; | ||
}, [client, options, query]); | ||
} | ||
@@ -916,0 +918,0 @@ function useBackgroundQuery(query, options) { |
@@ -6,3 +6,3 @@ import { __spreadArray } from "tslib"; | ||
import { makeHookWrappable } from "./internal/index.js"; | ||
import { useWatchQueryOptions } from "./useSuspenseQuery.js"; | ||
import { useWatchQueryOptions } from "./internal/useWatchQueryOptions.js"; | ||
import { canonicalStringify } from "../../cache/index.js"; | ||
@@ -9,0 +9,0 @@ export function useBackgroundQuery(query, options) { |
@@ -6,3 +6,3 @@ import { __assign, __spreadArray } from "tslib"; | ||
import { useRenderGuard } from "./internal/index.js"; | ||
import { useWatchQueryOptions } from "./useSuspenseQuery.js"; | ||
import { useWatchQueryOptions } from "./internal/useWatchQueryOptions.js"; | ||
import { canonicalStringify } from "../../cache/index.js"; | ||
@@ -9,0 +9,0 @@ import { invariant } from "../../utilities/globals/index.js"; |
import * as React from "rehackt"; | ||
import { getWrappedPromise, unwrapQueryRef, updateWrappedQueryRef, } from "../internal/index.js"; | ||
import { __use, makeHookWrappable } from "./internal/index.js"; | ||
import { toApolloError } from "./useSuspenseQuery.js"; | ||
import { toApolloError } from "./internal/toApolloError.js"; | ||
import { useSyncExternalStore } from "./useSyncExternalStore.js"; | ||
@@ -6,0 +6,0 @@ export function useReadQuery(queryRef) { |
@@ -46,10 +46,3 @@ import type { ApolloClient, ApolloQueryResult, DocumentNode, OperationVariables, TypedDocumentNode, FetchMoreQueryOptions, WatchQueryOptions } from "../../core/index.js"; | ||
export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SkipToken | SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): UseSuspenseQueryResult<TData | undefined, TVariables>; | ||
export declare function toApolloError(result: ApolloQueryResult<any>): ApolloError | undefined; | ||
interface UseWatchQueryOptionsHookOptions<TData, TVariables extends OperationVariables> { | ||
client: ApolloClient<unknown>; | ||
query: DocumentNode | TypedDocumentNode<TData, TVariables>; | ||
options: SkipToken | SuspenseQueryHookOptions<TData, TVariables>; | ||
} | ||
export declare function useWatchQueryOptions<TData, TVariables extends OperationVariables>({ client, query, options, }: UseWatchQueryOptionsHookOptions<TData, TVariables>): WatchQueryOptions<TVariables, TData>; | ||
export {}; | ||
export declare function validateOptions(options: WatchQueryOptions): void; | ||
//# sourceMappingURL=useSuspenseQuery.d.ts.map |
@@ -1,12 +0,12 @@ | ||
import { __assign, __spreadArray } from "tslib"; | ||
import { __spreadArray } from "tslib"; | ||
import * as React from "rehackt"; | ||
import { invariant } from "../../utilities/globals/index.js"; | ||
import { ApolloError, NetworkStatus } from "../../core/index.js"; | ||
import { isNonEmptyArray } from "../../utilities/index.js"; | ||
import { NetworkStatus } from "../../core/index.js"; | ||
import { useApolloClient } from "./useApolloClient.js"; | ||
import { DocumentType, verifyDocumentType } from "../parser/index.js"; | ||
import { __use, useDeepMemo, makeHookWrappable } from "./internal/index.js"; | ||
import { __use, makeHookWrappable } from "./internal/index.js"; | ||
import { getSuspenseCache } from "../internal/index.js"; | ||
import { canonicalStringify } from "../../cache/index.js"; | ||
import { skipToken } from "./constants.js"; | ||
import { toApolloError } from "./internal/toApolloError.js"; | ||
import { useWatchQueryOptions } from "./internal/useWatchQueryOptions.js"; | ||
export function useSuspenseQuery(query, options) { | ||
@@ -88,3 +88,3 @@ if (options === void 0) { options = Object.create(null); } | ||
useSuspenseQuery = wrapped; | ||
function validateOptions(options) { | ||
export function validateOptions(options) { | ||
var query = options.query, fetchPolicy = options.fetchPolicy, returnPartialData = options.returnPartialData; | ||
@@ -110,29 +110,2 @@ verifyDocumentType(query, DocumentType.Query); | ||
} | ||
export function toApolloError(result) { | ||
return isNonEmptyArray(result.errors) ? | ||
new ApolloError({ graphQLErrors: result.errors }) | ||
: result.error; | ||
} | ||
export function useWatchQueryOptions(_a) { | ||
var client = _a.client, query = _a.query, options = _a.options; | ||
return useDeepMemo(function () { | ||
var _a; | ||
if (options === skipToken) { | ||
return { query: query, fetchPolicy: "standby" }; | ||
} | ||
var fetchPolicy = options.fetchPolicy || | ||
((_a = client.defaultOptions.watchQuery) === null || _a === void 0 ? void 0 : _a.fetchPolicy) || | ||
"cache-first"; | ||
var watchQueryOptions = __assign(__assign({}, options), { fetchPolicy: fetchPolicy, query: query, notifyOnNetworkStatusChange: false, nextFetchPolicy: void 0 }); | ||
if (globalThis.__DEV__ !== false) { | ||
validateOptions(watchQueryOptions); | ||
} | ||
// Assign the updated fetch policy after our validation since `standby` is | ||
// not a supported fetch policy on its own without the use of `skip`. | ||
if (options.skip) { | ||
watchQueryOptions.fetchPolicy = "standby"; | ||
} | ||
return watchQueryOptions; | ||
}, [client, options, query]); | ||
} | ||
//# sourceMappingURL=useSuspenseQuery.js.map |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var version = "0.0.0-pr-11617-20240226102810"; | ||
var version = "0.0.0-pr-11622-20240226120051"; | ||
@@ -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-11622-20240226120051"; | ||
//# 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
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
6663573
805
57923