Comparing version 3.2.1 to 3.2.2-canary-20241030084036.8a8ba96a67f2b79a53e49800389c7c57a8640208
@@ -5,4 +5,3 @@ import type { BaseGeneratedSchema } from '..'; | ||
import { type LegacySelection } from './selection'; | ||
export interface LegacyFetchOptions extends Omit<RequestInit, 'body'> { | ||
} | ||
export type LegacyFetchOptions = Omit<RequestInit, 'body'>; | ||
export interface LegacyResolved { | ||
@@ -9,0 +8,0 @@ <T = unknown>(fn: () => T, opts?: LegacyResolveOptions<T>): Promise<T>; |
@@ -13,2 +13,3 @@ 'use strict'; | ||
const resolveSelections = require('./resolveSelections.js'); | ||
const subscriber = require('./subscriber.js'); | ||
const updateCaches = require('./updateCaches.js'); | ||
@@ -86,2 +87,3 @@ | ||
const { accessor } = index.createSchemaAccessor(context$1); | ||
let activePromise; | ||
const resolve = async () => { | ||
@@ -141,3 +143,3 @@ if (selections.size === 0) { | ||
updateCaches.updateCaches(results, [...targetCaches], { | ||
skipNotify: !context$1.notifyCacheUpdate | ||
skipNotify: promiseDropped() || !context$1.notifyCacheUpdate | ||
}); | ||
@@ -159,7 +161,4 @@ correlatedCaches.delete(resolverCache); | ||
const currentPromise = pendingQueries.get(pendingSelections)(); | ||
const promiseDropped = () => { | ||
var _a; | ||
const activePromise = (_a = pendingQueries.get(pendingSelections)) == null ? void 0 : _a(); | ||
return activePromise && currentPromise !== activePromise; | ||
}; | ||
activePromise = currentPromise; | ||
const promiseDropped = () => activePromise !== void 0 && currentPromise !== activePromise; | ||
currentPromise.then( | ||
@@ -177,2 +176,3 @@ () => { | ||
context$1.reset(); | ||
activePromise = void 0; | ||
}); | ||
@@ -182,2 +182,3 @@ } | ||
}; | ||
const subscriber$1 = subscriber.isWsClient(fetchOptions.subscriber) ? subscriber.createSubscriber(fetchOptions.subscriber) : fetchOptions.subscriber; | ||
const subscribe = ({ | ||
@@ -256,3 +257,4 @@ onComplete, | ||
cachePolicy, | ||
retryPolicy | ||
retryPolicy, | ||
subscriber: subscriber$1 | ||
}, | ||
@@ -259,0 +261,0 @@ operationName, |
import type { ExecutionResult } from 'graphql'; | ||
import type { Client as SseClient } from 'graphql-sse'; | ||
import type { CloseEvent } from 'ws'; | ||
@@ -8,2 +9,6 @@ import type { FetchOptions } from '.'; | ||
import type { Debugger } from './debugger'; | ||
import { type GQtyWsClient } from './subscriber'; | ||
export type ResolverFetchOptions = Omit<FetchOptions, 'subscriber'> & { | ||
subscriber?: SseClient | GQtyWsClient; | ||
}; | ||
export type FetchSelectionsOptions = { | ||
@@ -13,3 +18,3 @@ cache?: Cache; | ||
extensions?: Record<string, unknown>; | ||
fetchOptions: FetchOptions; | ||
fetchOptions: ResolverFetchOptions; | ||
operationName?: string; | ||
@@ -16,0 +21,0 @@ }; |
@@ -9,2 +9,3 @@ 'use strict'; | ||
const QueryBuilder = require('../QueryBuilder.js'); | ||
const subscriber = require('./subscriber.js'); | ||
const retry = require('../Error/retry.js'); | ||
@@ -63,3 +64,3 @@ | ||
extensions: customExtensions, | ||
fetchOptions: { subscriber }, | ||
fetchOptions: { subscriber: subscriber$1 }, | ||
operationName, | ||
@@ -80,3 +81,3 @@ onSubscribe, | ||
if (!hash) throw new index.GQtyError(`Expected query hash.`); | ||
if (type === "subscription" && !subscriber) { | ||
if (type === "subscription" && !subscriber$1) { | ||
throw new index.GQtyError(`Missing subscriber for subscriptions.`); | ||
@@ -91,16 +92,8 @@ } | ||
let subscriptionId; | ||
if (isWsClient(subscriber)) { | ||
if (subscriber.isWsClient(subscriber$1)) { | ||
if (onSubscribe) { | ||
const unsub = subscriber.on("message", (message) => { | ||
switch (message.type) { | ||
case "connection_ack": { | ||
unsub(); | ||
onSubscribe(); | ||
break; | ||
} | ||
} | ||
}); | ||
subscriber$1.onSubscribe(onSubscribe); | ||
} | ||
if (debug) { | ||
const unsub = subscriber.on("message", (message) => { | ||
const unsub = subscriber$1.on("message", (message) => { | ||
var _a; | ||
@@ -126,7 +119,5 @@ switch (message.type) { | ||
} | ||
} else if (isSseClient(subscriber)) { | ||
} else { | ||
subscriptionId = "EventSource"; | ||
onSubscribe == null ? void 0 : onSubscribe(); | ||
} else { | ||
throw new index.GQtyError(`Please specify a subscriber for subscriptions.`); | ||
} | ||
@@ -166,3 +157,3 @@ const next = ({ data, errors, extensions }) => { | ||
return new Promise((complete) => { | ||
dispose = subscriber == null ? void 0 : subscriber.subscribe( | ||
dispose = subscriber$1 == null ? void 0 : subscriber$1.subscribe( | ||
queryPayload, | ||
@@ -312,6 +303,2 @@ { | ||
}; | ||
const isWsClient = (client) => { | ||
return client !== void 0 && typeof client.on === "function"; | ||
}; | ||
const isSseClient = (client) => client !== void 0 && !isWsClient(client); | ||
@@ -318,0 +305,0 @@ exports.fetchSelections = fetchSelections; |
{ | ||
"name": "gqty", | ||
"version": "3.2.1", | ||
"version": "3.2.2-canary-20241030084036.8a8ba96a67f2b79a53e49800389c7c57a8640208", | ||
"description": "The No-GraphQL Client for TypeScript", | ||
@@ -23,3 +23,3 @@ "sideEffects": false, | ||
"dependencies": { | ||
"debounce-microtasks": "^0.1.7", | ||
"debounce-microtasks": "^0.1.8", | ||
"flatted": "^3.3.1", | ||
@@ -26,0 +26,0 @@ "frail-map": "^1.0.10", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
294751
171
8285
1
Updateddebounce-microtasks@^0.1.8