Comparing version 3.0.0-alpha-e4462058.0 to 3.0.0-alpha-e5b1b41a.0
@@ -8,3 +8,3 @@ import type { BaseGeneratedSchema, SchemaContext } from '../Client'; | ||
*/ | ||
export declare const setCache: <TData extends GeneratedSchemaObject<Record<string, any>>>(accessor: TData, data: Partial<TData>) => void; | ||
export declare const setCache: <TData extends GeneratedSchemaObject>(accessor: TData, data: Partial<TData>) => void; | ||
/** | ||
@@ -16,2 +16,2 @@ * Use another accessor like a fragment, this function takes all children from | ||
*/ | ||
export declare const assignSelections: <TData extends GeneratedSchemaObject<Record<string, any>>>(source: TData | null, target: TData | null) => void; | ||
export declare const assignSelections: <TData extends GeneratedSchemaObject>(source: TData | null, target: TData | null) => void; |
@@ -9,5 +9,5 @@ import type { CacheNode } from '../Cache'; | ||
*/ | ||
export declare const resolve: (accessor: GeneratedSchemaObject, selection: Selection, __type: Type['__type']) => string | number | boolean | CacheNode[] | GeneratedSchemaObject<Record<string, any>> | { | ||
export declare const resolve: (accessor: GeneratedSchemaObject, selection: Selection, __type: Type['__type']) => string | number | boolean | CacheNode[] | GeneratedSchemaObject | { | ||
[k: string]: boolean; | ||
} | GeneratedSchemaObject<Record<string, any>>[] | null | undefined; | ||
} | GeneratedSchemaObject[] | null | undefined; | ||
export declare const createUnionAccessor: ({ context, cache, possibleTypes, selection, }: Omit<Meta, "type"> & { | ||
@@ -21,5 +21,5 @@ possibleTypes: readonly string[]; | ||
}; | ||
export declare const createObjectAccessor: <TSchemaType extends GeneratedSchemaObject<Record<string, any>>>(meta: Meta) => GeneratedSchemaObject<Record<string, any>>; | ||
export declare const createObjectAccessor: <TSchemaType extends GeneratedSchemaObject>(meta: Meta) => GeneratedSchemaObject; | ||
/** Recursively replace proxy accessors with its actual cached value. */ | ||
export declare const deepMetadata: (input: any) => any; | ||
export declare const createArrayAccessor: <TSchemaType extends GeneratedSchemaObject<Record<string, any>>[]>(meta: Meta) => TSchemaType; | ||
export declare const createArrayAccessor: <TSchemaType extends GeneratedSchemaObject[]>(meta: Meta) => TSchemaType; |
@@ -6,5 +6,5 @@ import { type BaseGeneratedSchema, type FetchOptions } from '.'; | ||
import { type Selection } from '../Selection'; | ||
import { SchemaContext } from './context'; | ||
import { type SchemaContext } from './context'; | ||
import { type Debugger } from './debugger'; | ||
import { Unsubscribe } from './resolveSelections'; | ||
import { type Unsubscribe } from './resolveSelections'; | ||
export type CreateResolversOptions = { | ||
@@ -70,12 +70,4 @@ cache: Cache; | ||
export type DataResult<TData = unknown> = TData extends undefined ? TData : TData extends void ? unknown : TData; | ||
export type ResolveOptions = { | ||
export type CreateResolverOptions = { | ||
/** | ||
* Awaits resolution it the query results in a fetch. Specify `false` to | ||
* immediately return the current cache, placeholder data will be returned on | ||
* a partial or complete cache miss. | ||
* | ||
* @default true | ||
*/ | ||
awaitsFetch?: boolean; | ||
/** | ||
* Defines how a query should fetch from the cache and network. | ||
@@ -90,5 +82,3 @@ * | ||
* GQty creates a temporary cache at query-level which immediately expires. | ||
* - `reload`: Always fetch, updates on response. | ||
* - `no-cache`: Same as `reload`, for GraphQL does not support conditional | ||
* requests. | ||
* - `no-cache`: Always fetch, updates on response. | ||
* - `force-cache`: Serves the cached contents regardless of staleness. It | ||
@@ -104,30 +94,20 @@ * fetches on cache miss or a stale cache, updates cache on response. | ||
cachePolicy?: RequestCache; | ||
/** Custom GraphQL extensions to be exposed to the query fetcher. */ | ||
extensions?: Record<string, unknown>; | ||
retryPolicy?: RetryOptions; | ||
onFetch?: (fetchPromise: Promise<unknown>) => void; | ||
onSelect?: SchemaContext['select']; | ||
operationName?: string; | ||
}; | ||
export type SubscribeOptions = { | ||
export type ResolveOptions = CreateResolverOptions & { | ||
/** | ||
* Defines how a query should fetch from the cache and network. | ||
* Awaits resolution it the query results in a fetch. Specify `false` to | ||
* immediately return the current cache, placeholder data will be returned on | ||
* a partial or complete cache miss. | ||
* | ||
* - `default`: Serves the cached contents when it is fresh, and if they are | ||
* stale within `staleWhileRevalidate` window, fetches in the background and | ||
* updates the cache. Or simply fetches on cache stale or cache miss. During | ||
* SWR, a successful fetch will not notify cache updates. New contents are | ||
* served on next query. | ||
* - `no-store`: Always fetch and does not update on response. | ||
* GQty creates a temporary cache at query-level which immediately expires. | ||
* - `no-cache`: Always fetch, updates on response. | ||
* - `force-cache`: Serves the cached contents regardless of staleness. It | ||
* fetches on cache miss or a stale cache, updates cache on response. | ||
* - `only-if-cached`: Serves the cached contents regardless of staleness, | ||
* throws a network error on cache miss. | ||
* | ||
* _It takes effort to make sure the above stays true for all supported | ||
* frameworks, please consider sponsoring so we can dedicate even more time on | ||
* this._ | ||
* @default true | ||
*/ | ||
cachePolicy?: RequestCache; | ||
retryPolicy?: RetryOptions; | ||
awaitsFetch?: boolean; | ||
onFetch?: (fetchPromise: Promise<unknown>) => void; | ||
}; | ||
export type SubscribeOptions = CreateResolverOptions & { | ||
/** | ||
@@ -142,3 +122,2 @@ * Intercept errors thrown from the underlying subscription client or query | ||
onError?: (error: unknown) => void; | ||
onSelect?: SchemaContext['select']; | ||
/** | ||
@@ -150,4 +129,3 @@ * Called when a subscription is established, receives an unsubscribe | ||
onSubscribe?: (unsubscribe: Unsubscribe) => void; | ||
operationName?: string; | ||
}; | ||
export declare const createResolvers: <TSchema extends BaseGeneratedSchema>({ cache: clientCache, debugger: debug, depthLimit, fetchOptions, fetchOptions: { cachePolicy: defaultCachePolicy, retryPolicy: defaultRetryPoliy, }, scalars, schema, parentContext, }: CreateResolversOptions) => Resolvers<TSchema>; |
@@ -29,2 +29,3 @@ 'use strict'; | ||
cachePolicy = defaultCachePolicy, | ||
extensions, | ||
onSelect, | ||
@@ -74,29 +75,28 @@ onSubscribe, | ||
pendingSelections, | ||
new Promise((resolve2, reject) => { | ||
queueMicrotask(() => { | ||
var _a; | ||
const selections2 = new Set( | ||
[ | ||
...(_a = batching.getSelectionsSet(clientCache, selectionsCacheKey)) != null ? _a : [] | ||
].flatMap((selections3) => [...selections3]) | ||
Promise.resolve().then(() => { | ||
var _a; | ||
const selections2 = new Set( | ||
[ | ||
...(_a = batching.getSelectionsSet(clientCache, selectionsCacheKey)) != null ? _a : [] | ||
].flatMap((selections3) => [...selections3]) | ||
); | ||
pendingQueries.delete(pendingSelections); | ||
batching.delSelectionsSet(clientCache, selectionsCacheKey); | ||
return resolveSelections.fetchSelections(selections2, { | ||
cache: context$1.cache, | ||
debugger: debug, | ||
extensions, | ||
fetchOptions: { | ||
...fetchOptions, | ||
cachePolicy, | ||
retryPolicy | ||
}, | ||
operationName | ||
}).then((results) => { | ||
updateCaches.updateCaches( | ||
results, | ||
cachePolicy !== "no-store" && context$1.cache !== clientCache ? [context$1.cache, clientCache] : [context$1.cache], | ||
{ skipNotify: !context$1.notifyCacheUpdate } | ||
); | ||
pendingQueries.delete(pendingSelections); | ||
batching.delSelectionsSet(clientCache, selectionsCacheKey); | ||
resolveSelections.fetchSelections(selections2, { | ||
cache: context$1.cache, | ||
debugger: debug, | ||
fetchOptions: { | ||
...fetchOptions, | ||
cachePolicy, | ||
retryPolicy | ||
}, | ||
operationName | ||
}).then((results) => { | ||
updateCaches.updateCaches( | ||
results, | ||
cachePolicy !== "no-store" && context$1.cache !== clientCache ? [context$1.cache, clientCache] : [context$1.cache], | ||
{ skipNotify: !context$1.notifyCacheUpdate } | ||
); | ||
return results; | ||
}).then(resolve2, reject); | ||
return results; | ||
}); | ||
@@ -144,3 +144,5 @@ }) | ||
} | ||
promises.push(resolve()); | ||
if (selections.size > 0) { | ||
promises.push(resolve()); | ||
} | ||
} | ||
@@ -154,3 +156,3 @@ for (const selection of subscriptionSelections) { | ||
subscriptionSelections, | ||
({ data, error, extensions }) => { | ||
({ data, error, extensions: extensions2 }) => { | ||
if (error) { | ||
@@ -161,3 +163,3 @@ onError == null ? void 0 : onError(error); | ||
updateCaches.updateCaches( | ||
[{ data, error, extensions }], | ||
[{ data, error, extensions: extensions2 }], | ||
cachePolicy !== "no-store" && context$1.cache !== clientCache ? [context$1.cache, clientCache] : [context$1.cache], | ||
@@ -171,2 +173,3 @@ { skipNotify: !context$1.notifyCacheUpdate } | ||
debugger: debug, | ||
extensions, | ||
fetchOptions: { | ||
@@ -173,0 +176,0 @@ ...fetchOptions, |
import { type ExecutionResult } from 'graphql'; | ||
import { Constructor } from 'type-fest'; | ||
import { type Constructor } from 'type-fest'; | ||
import { type CloseEvent, type WebSocket } from 'ws'; | ||
@@ -12,2 +12,3 @@ import { type FetchOptions } from '.'; | ||
debugger?: Debugger; | ||
extensions?: Record<string, unknown>; | ||
fetchOptions: FetchOptions; | ||
@@ -23,3 +24,3 @@ operationName?: string; | ||
}; | ||
export declare const fetchSelections: <TData extends Record<string, unknown> = Record<string, unknown>>(selections: Set<Selection>, { cache, debugger: debug, fetchOptions, operationName, }: FetchSelectionsOptions) => Promise<FetchResult<TData>[]>; | ||
export declare const fetchSelections: <TData extends Record<string, unknown> = Record<string, unknown>>(selections: Set<Selection>, { cache, debugger: debug, extensions: customExtensions, fetchOptions, operationName, }: FetchSelectionsOptions) => Promise<FetchResult<TData>[]>; | ||
export type SubscribeSelectionOptions = FetchSelectionsOptions & { | ||
@@ -31,3 +32,3 @@ onComplete?: () => void; | ||
export type Unsubscribe = () => void; | ||
export declare const subscribeSelections: <TData extends Record<string, unknown> = Record<string, unknown>>(selections: Set<Selection>, fn: SubscriptionCallback<TData>, { cache, debugger: debug, fetchOptions: { subscriber }, operationName, onSubscribe, onComplete, }: SubscribeSelectionOptions) => Unsubscribe; | ||
export declare const subscribeSelections: <TData extends Record<string, unknown> = Record<string, unknown>>(selections: Set<Selection>, fn: SubscriptionCallback<TData>, { cache, debugger: debug, extensions: customExtensions, fetchOptions: { subscriber }, operationName, onSubscribe, onComplete, }: SubscribeSelectionOptions) => Unsubscribe; | ||
export declare const isCloseEvent: (input: unknown, wsImpl: Constructor<WebSocket>) => input is CloseEvent; |
@@ -32,2 +32,3 @@ 'use strict'; | ||
debugger: debug, | ||
extensions: customExtensions, | ||
fetchOptions, | ||
@@ -51,3 +52,3 @@ operationName | ||
operationName: operationName2, | ||
extensions: { type, hash } | ||
extensions: { ...customExtensions, type, hash } | ||
}; | ||
@@ -80,2 +81,3 @@ const { data, errors, extensions } = await query.dedupePromise( | ||
debugger: debug, | ||
extensions: customExtensions, | ||
fetchOptions: { subscriber }, | ||
@@ -106,3 +108,3 @@ operationName, | ||
operationName: operationName2, | ||
extensions: { type, hash } | ||
extensions: { ...customExtensions, type, hash } | ||
}; | ||
@@ -109,0 +111,0 @@ let subscriptionId; |
{ | ||
"name": "gqty", | ||
"version": "3.0.0-alpha-e4462058.0", | ||
"version": "3.0.0-alpha-e5b1b41a.0", | ||
"description": "gqty client without queries", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
274450
7886