Comparing version 3.0.0-alpha-7906fb34.0 to 3.0.0-alpha-7b21563c.0
import { type Cache } from '../Cache'; | ||
import { Selection } from '../Selection'; | ||
export declare const addSelections: (cache: Cache, key: string, value: Set<Selection>) => Set<Set<Selection>>; | ||
export declare const addSelections: (cache: Cache, key: string, selections: Set<Selection>) => Set<Set<Selection>>; | ||
export declare const getSelectionsSet: (cache: Cache, key: string) => Set<Set<Selection>> | undefined; | ||
export declare const delSelectionsSet: (cache: Cache, key: string) => boolean; | ||
export declare const delSelectionSet: (cache: Cache, key: string) => boolean; | ||
export declare const popSelectionsSet: (cache: Cache, key: string) => Set<Set<Selection>> | undefined; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
const pendingSelections = /* @__PURE__ */ new Map(); | ||
const addSelections = (cache, key, value) => { | ||
const addSelections = (cache, key, selections) => { | ||
if (!pendingSelections.has(cache)) { | ||
@@ -15,3 +15,3 @@ pendingSelections.set(cache, /* @__PURE__ */ new Map()); | ||
} | ||
return selectionsByKey.get(key).add(value); | ||
return selectionsByKey.get(key).add(selections); | ||
}; | ||
@@ -22,3 +22,3 @@ const getSelectionsSet = (cache, key) => { | ||
}; | ||
const delSelectionsSet = (cache, key) => { | ||
const delSelectionSet = (cache, key) => { | ||
var _a, _b; | ||
@@ -29,3 +29,3 @@ return (_b = (_a = pendingSelections.get(cache)) == null ? void 0 : _a.delete(key)) != null ? _b : false; | ||
const result = getSelectionsSet(cache, key); | ||
delSelectionsSet(cache, key); | ||
delSelectionSet(cache, key); | ||
return result; | ||
@@ -35,4 +35,4 @@ }; | ||
exports.addSelections = addSelections; | ||
exports.delSelectionsSet = delSelectionsSet; | ||
exports.delSelectionSet = delSelectionSet; | ||
exports.getSelectionsSet = getSelectionsSet; | ||
exports.popSelectionsSet = popSelectionsSet; |
@@ -5,2 +5,8 @@ 'use strict'; | ||
var __defProp = Object.defineProperty; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
var LegacySelectionType = /* @__PURE__ */ ((LegacySelectionType2) => { | ||
@@ -24,5 +30,16 @@ LegacySelectionType2[LegacySelectionType2["Query"] = 0] = "Query"; | ||
}) { | ||
this.cachePath = []; | ||
this.prevSelection = null; | ||
this.currentCofetchSelections = null; | ||
__publicField(this, "id"); | ||
__publicField(this, "key"); | ||
__publicField(this, "type"); | ||
__publicField(this, "operationName"); | ||
__publicField(this, "unions"); | ||
__publicField(this, "args"); | ||
__publicField(this, "argTypes"); | ||
__publicField(this, "alias"); | ||
__publicField(this, "cachePath", []); | ||
__publicField(this, "pathString"); | ||
__publicField(this, "selectionsList"); | ||
__publicField(this, "noIndexSelections"); | ||
__publicField(this, "prevSelection", null); | ||
__publicField(this, "currentCofetchSelections", null); | ||
var _a, _b, _c, _d, _e, _f; | ||
@@ -29,0 +46,0 @@ this.id = id + ""; |
@@ -14,9 +14,6 @@ import type { Cache } from '../Cache'; | ||
export type Debugger = { | ||
dispatch: (event: DebugEvent) => void; | ||
dispatch: (event: DebugEvent) => Promise<void>; | ||
/** Returns an unsubscribe function */ | ||
subscribe: (listener: DebugEventListener) => () => void; | ||
}; | ||
export declare const createDebugger: () => { | ||
dispatch: (event: DebugEvent) => void; | ||
subscribe: (listener: DebugEventListener) => () => boolean; | ||
}; | ||
export declare const createDebugger: () => Debugger; |
@@ -8,4 +8,4 @@ 'use strict'; | ||
return { | ||
dispatch: (event) => { | ||
subs.forEach((sub) => sub(event)); | ||
dispatch: async (event) => { | ||
await Promise.all([...subs].map((sub) => sub(event))); | ||
}, | ||
@@ -12,0 +12,0 @@ subscribe: (listener) => { |
@@ -78,3 +78,5 @@ import { type Client as SseClient } from 'graphql-sse'; | ||
subscribeDebugEvents: ReturnType<typeof createDebugger>['subscribe']; | ||
/** Get the cache instance of this client. */ | ||
readonly cache: Cache; | ||
}; | ||
export declare const createClient: <TSchema extends BaseGeneratedSchema, _ObjectTypesNames extends string = never, _ObjectTypes extends SchemaObjects<TSchema> = never>({ cache, fetchOptions: { fetcher, cachePolicy: fetchPolicy, retryPolicy: defaultRetryPolicy, subscriber, ...fetchOptions }, scalars, schema, __depthLimit, ...legacyOptions }: ClientOptions & LegacyClientOptions) => Client<TSchema>; |
@@ -90,2 +90,5 @@ 'use strict'; | ||
...persistence.createPersistors(cache), | ||
get cache() { | ||
return cache; | ||
}, | ||
...client.createLegacyClient({ | ||
@@ -92,0 +95,0 @@ accessor, |
@@ -81,3 +81,3 @@ 'use strict'; | ||
pendingQueries.delete(pendingSelections); | ||
batching.delSelectionsSet(clientCache, selectionsCacheKey); | ||
batching.delSelectionSet(clientCache, selectionsCacheKey); | ||
return resolveSelections.fetchSelections(selections2, { | ||
@@ -87,7 +87,3 @@ cache: context$1.cache, | ||
extensions, | ||
fetchOptions: { | ||
...fetchOptions, | ||
cachePolicy, | ||
retryPolicy | ||
}, | ||
fetchOptions: { ...fetchOptions, cachePolicy, retryPolicy }, | ||
operationName | ||
@@ -94,0 +90,0 @@ }).then((results) => { |
@@ -47,3 +47,3 @@ 'use strict'; | ||
} | ||
debug == null ? void 0 : debug.dispatch({ | ||
await (debug == null ? void 0 : debug.dispatch({ | ||
cache, | ||
@@ -53,3 +53,3 @@ request: queryPayload, | ||
selections | ||
}); | ||
})); | ||
return result; | ||
@@ -227,4 +227,10 @@ } | ||
} catch (error) { | ||
if (!retryPolicy || !(error instanceof Error)) | ||
if ( | ||
// User doesn't want reties | ||
!retryPolicy || // Let everything unknown through | ||
!(error instanceof Error) || // GQtyErrors are supposed to be terminating | ||
error instanceof index$1.GQtyError | ||
) { | ||
throw error; | ||
} | ||
return new Promise((resolve, reject) => { | ||
@@ -231,0 +237,0 @@ retry.doRetry(retryPolicy, { |
@@ -7,6 +7,14 @@ 'use strict'; | ||
var __defProp = Object.defineProperty; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
class GQtyError extends Error { | ||
constructor(message, { graphQLErrors, otherError } = {}) { | ||
super(message); | ||
this.name = "GQtyError"; | ||
__publicField(this, "name", "GQtyError"); | ||
__publicField(this, "graphQLErrors"); | ||
__publicField(this, "otherError"); | ||
if (graphQLErrors) | ||
@@ -13,0 +21,0 @@ this.graphQLErrors = graphQLErrors; |
{ | ||
"name": "gqty", | ||
"version": "3.0.0-alpha-7906fb34.0", | ||
"version": "3.0.0-alpha-7b21563c.0", | ||
"description": "gqty client without queries", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -8,2 +8,8 @@ 'use strict'; | ||
var __defProp = Object.defineProperty; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
const createSymbol = Symbol(); | ||
@@ -30,4 +36,10 @@ const aliasGenerator = { | ||
this.key = key; | ||
this.cacheKeys = []; | ||
this.children = /* @__PURE__ */ new Map(); | ||
__publicField(this, "alias"); | ||
__publicField(this, "cacheKeys", []); | ||
__publicField(this, "children", /* @__PURE__ */ new Map()); | ||
__publicField(this, "input"); | ||
__publicField(this, "parent"); | ||
__publicField(this, "root"); | ||
/** Indicates current selection being a inteface/union key. */ | ||
__publicField(this, "isUnion"); | ||
var _a, _b, _c; | ||
@@ -52,6 +64,5 @@ if (token !== createSymbol) { | ||
let current = this; | ||
while (current) { | ||
do { | ||
ancestry.unshift(current); | ||
current = current.parent; | ||
} | ||
} while (current = current.parent); | ||
return ancestry; | ||
@@ -58,0 +69,0 @@ } |
@@ -14,5 +14,5 @@ 'use strict'; | ||
const hash = memoize__default["default"]( | ||
(...args) => objectHash__default["default"](args).replace(/^(\d)/, "a$1") | ||
(...args) => objectHash__default["default"](args, { unorderedObjects: false }).replace(/^(\d)/, "a$1") | ||
); | ||
exports.hash = hash; |
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
280398
8038