Socket
Socket
Sign inDemoInstall

@urql/core

Package Overview
Dependencies
Maintainers
31
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@urql/core - npm Package Compare versions

Comparing version 1.14.1 to 1.15.0

12

CHANGELOG.md
# @urql/core
## 1.15.0
### Minor Changes
- Improve the Suspense implementation, which fixes edge-cases when Suspense is used with subscriptions, partially disabled, or _used on the client-side_. It has now been ensured that client-side suspense functions without the deprecated `suspenseExchange` and uncached results are loaded consistently. As part of this work, the `Client` itself does now never throw Suspense promises anymore, which is functionality that either way has no place outside of the React/Preact bindings, by [@kitten](https://github.com/kitten) (See [#1123](https://github.com/FormidableLabs/urql/pull/1123))
### Patch Changes
- Use `Record` over `object` type for subscription operation variables. The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)), by [@enisdenjo](https://github.com/enisdenjo) (See [#1119](https://github.com/FormidableLabs/urql/pull/1119))
- Add support for `TypedDocumentNode` to infer the type of the `OperationResult` and `Operation` for all methods, functions, and hooks that either directly or indirectly accept a `DocumentNode`. See [`graphql-typed-document-node` and the corresponding blog post for more information.](https://github.com/dotansimha/graphql-typed-document-node), by [@kitten](https://github.com/kitten) (See [#1113](https://github.com/FormidableLabs/urql/pull/1113))
- Refactor `useSource` hooks which powers `useQuery` and `useSubscription` to improve various edge case behaviour. This will not change the behaviour of these hooks dramatically but avoid unnecessary state updates when any updates are obviously equivalent and the hook will furthermore improve continuation from mount to effects, which will fix cases where the state between the mounting and effect phase may slightly change, by [@kitten](https://github.com/kitten) (See [#1104](https://github.com/FormidableLabs/urql/pull/1104))
## 1.14.1

@@ -4,0 +16,0 @@

21

dist/types/client.d.ts
import { Source, Subscription } from 'wonka';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import { DocumentNode } from 'graphql';
import { Exchange, GraphQLRequest, Operation, OperationContext, OperationResult, OperationType, RequestPolicy, PromisifiedSource, DebugEvent } from './types';
import { DocumentNode } from 'graphql';
/** Options for configuring the URQL [client]{@link Client}. */

@@ -46,3 +47,3 @@ export interface ClientOptions {

createOperationContext: (opts?: Partial<OperationContext> | undefined) => OperationContext;
createRequestOperation: (kind: OperationType, request: GraphQLRequest, opts?: Partial<OperationContext> | undefined) => Operation;
createRequestOperation: <Data = any, Variables = object>(kind: OperationType, request: GraphQLRequest<Data, Variables>, opts?: Partial<OperationContext> | undefined) => Operation<Data, Variables>;
/** Counts up the active operation key and dispatches the operation */

@@ -53,11 +54,11 @@ private onOperationStart;

/** Executes an Operation by sending it through the exchange pipeline It returns an observable that emits all related exchange results and keeps track of this observable's subscribers. A teardown signal will be emitted when no subscribers are listening anymore. */
executeRequestOperation(operation: Operation): Source<OperationResult>;
query<Data = any, Variables extends object = {}>(query: DocumentNode | string, variables?: Variables, context?: Partial<OperationContext>): PromisifiedSource<OperationResult<Data>>;
readQuery<Data = any, Variables extends object = {}>(query: DocumentNode | string, variables?: Variables, context?: Partial<OperationContext>): OperationResult<Data> | null;
executeQuery: <Data = any>(query: GraphQLRequest, opts?: Partial<OperationContext> | undefined) => Source<OperationResult<Data>>;
subscription<Data = any, Variables extends object = {}>(query: DocumentNode | string, variables?: Variables, context?: Partial<OperationContext>): Source<OperationResult<Data>>;
executeSubscription: (query: GraphQLRequest, opts?: Partial<OperationContext> | undefined) => Source<OperationResult>;
mutation<Data = any, Variables extends object = {}>(query: DocumentNode | string, variables?: Variables, context?: Partial<OperationContext>): PromisifiedSource<OperationResult<Data>>;
executeMutation: <Data = any>(query: GraphQLRequest, opts?: Partial<OperationContext> | undefined) => Source<OperationResult<Data>>;
executeRequestOperation<Data = any, Variables = object>(operation: Operation<Data, Variables>): Source<OperationResult<Data, Variables>>;
query<Data = any, Variables extends object = {}>(query: DocumentNode | TypedDocumentNode<Data, Variables> | string, variables?: Variables, context?: Partial<OperationContext>): PromisifiedSource<OperationResult<Data, Variables>>;
readQuery<Data = any, Variables extends object = {}>(query: DocumentNode | TypedDocumentNode<Data, Variables> | string, variables?: Variables, context?: Partial<OperationContext>): OperationResult<Data, Variables> | null;
executeQuery: <Data = any, Variables = object>(query: GraphQLRequest<Data, Variables>, opts?: Partial<OperationContext> | undefined) => Source<OperationResult<Data, Variables>>;
subscription<Data = any, Variables extends object = {}>(query: DocumentNode | TypedDocumentNode<Data, Variables> | string, variables?: Variables, context?: Partial<OperationContext>): Source<OperationResult<Data, Variables>>;
executeSubscription: <Data = any, Variables = object>(query: GraphQLRequest<Data, Variables>, opts?: Partial<OperationContext> | undefined) => Source<OperationResult<Data, Variables>>;
mutation<Data = any, Variables extends object = {}>(query: DocumentNode | TypedDocumentNode<Data, Variables> | string, variables?: Variables, context?: Partial<OperationContext>): PromisifiedSource<OperationResult<Data, Variables>>;
executeMutation: <Data = any, Variables = object>(query: GraphQLRequest<Data, Variables>, opts?: Partial<OperationContext> | undefined) => Source<OperationResult<Data, Variables>>;
}
export {};

@@ -15,3 +15,3 @@ import { Exchange, ExecutionResult, OperationContext } from '../types';

query: string;
variables?: object;
variables?: Record<string, unknown>;
key: string;

@@ -18,0 +18,0 @@ context: OperationContext;

@@ -0,1 +1,2 @@

export { TypedDocumentNode } from '@graphql-typed-document-node/core';
export * from './client';

@@ -2,0 +3,0 @@ export * from './exchanges';

import { Operation, OperationResult } from '../types';
export declare const makeFetchSource: (operation: Operation, url: string, fetchOptions: RequestInit) => import("wonka").Source<OperationResult<any>>;
export declare const makeFetchSource: (operation: Operation, url: string, fetchOptions: RequestInit) => import("wonka").Source<OperationResult<any, any>>;

@@ -0,1 +1,2 @@

import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import { DocumentNode } from 'graphql';

@@ -16,7 +17,7 @@ import { Source } from 'wonka';

/** A Graphql query, mutation, or subscription. */
export interface GraphQLRequest {
export interface GraphQLRequest<Data = any, Variables = object> {
/** Unique identifier of the request. */
key: number;
query: DocumentNode;
variables?: object;
query: DocumentNode | TypedDocumentNode<Data, Variables>;
variables?: Variables;
}

@@ -44,3 +45,3 @@ /** Metadata that is only available in development for devtools. */

/** A [query]{@link Query} or [mutation]{@link Mutation} with additional metadata for use during transmission. */
export interface Operation extends GraphQLRequest {
export interface Operation<Data = any, Variables = any> extends GraphQLRequest<Data, Variables> {
readonly kind: OperationType;

@@ -52,5 +53,5 @@ context: OperationContext;

/** Resulting data from an [operation]{@link Operation}. */
export interface OperationResult<Data = any> {
export interface OperationResult<Data = any, Variables = any> {
/** The [operation]{@link Operation} which has been executed. */
operation: Operation;
operation: Operation<Data, Variables>;
/** The data returned from the Graphql server. */

@@ -57,0 +58,0 @@ data?: Data;

@@ -5,3 +5,2 @@ export * from './error';

export * from './typenames';
export * from './toSuspenseSource';
export * from './stringifyVariables';

@@ -8,0 +7,0 @@ export * from './maskTypename';

import { GraphQLRequest, Operation, OperationContext, OperationType } from '../types';
declare function makeOperation(kind: OperationType, request: GraphQLRequest, context: OperationContext): Operation;
declare function makeOperation(kind: OperationType, request: Operation, context?: OperationContext): Operation;
declare function makeOperation<Data = any, Variables = object>(kind: OperationType, request: GraphQLRequest<Data, Variables>, context: OperationContext): Operation<Data, Variables>;
declare function makeOperation<Data = any, Variables = object>(kind: OperationType, request: Operation<Data, Variables>, context?: OperationContext): Operation<Data, Variables>;
export { makeOperation };
/** Spreads the provided metadata to the source operation's meta property in context. */
export declare const addMetadata: (operation: Operation, meta: OperationContext['meta']) => Operation;
export declare const addMetadata: (operation: Operation, meta: OperationContext['meta']) => Operation<any, any>;

@@ -0,4 +1,5 @@

import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import { DocumentNode } from 'graphql';
import { GraphQLRequest } from '../types';
export declare const createRequest: (q: string | DocumentNode, vars?: object | undefined) => GraphQLRequest;
export declare const createRequest: <Data = any, Variables = object>(q: string | DocumentNode | TypedDocumentNode<Data, Variables>, vars?: Variables | undefined) => GraphQLRequest<Data, Variables>;
/**

@@ -5,0 +6,0 @@ * Finds the Name value from the OperationDefinition of a Document

import { DocumentNode } from 'graphql';
export declare const collectTypesFromResponse: (response: object) => string[];
export declare const formatDocument: (node: DocumentNode) => DocumentNode;
export declare const formatDocument: <T extends DocumentNode>(node: T) => T;

@@ -81,3 +81,3 @@ "use strict";

function _ref3$2(a) {
function _ref2$3(a) {
a.data = maskTypename(a.data);

@@ -122,14 +122,2 @@ return a;

return b;
}, toSuspenseSource = function(a) {
return function(b) {
var c = wonka.share(a), d = !1, f = !1;
wonka.onPush((function() {
return d = !0;
}))(wonka.takeWhile((function() {
return !f;
}))(c))(b);
if (!d) {
throw f = !0, b(0), wonka.toPromise(wonka.take(1)(c));
}
};
}, maskTypename = function(a) {

@@ -182,3 +170,3 @@ return a && "object" == typeof a ? Object.keys(a).reduce((function(b, c) {

for (var a; a = g.shift(); ) {
delete k[a];
delete h[a];
}

@@ -190,3 +178,3 @@ }

function d(a) {
return deserializeResult(a, k[a.key]);
return deserializeResult(a, h[a.key]);
}

@@ -196,18 +184,18 @@ function f(a) {

}
function h(a) {
function k(a) {
var b = a.operation;
shouldSkip(b) || (a = serializeResult(a), k[b.key] = a);
shouldSkip(b) || (a = serializeResult(a), h[b.key] = a);
}
var k = {}, g = [], e = function(a) {
var h = {}, g = [], e = function(a) {
g.push(a.operation.key);
1 === g.length && Promise.resolve().then(b);
}, m = function(a) {
return !shouldSkip(a) && void 0 !== k[a.key];
return !shouldSkip(a) && void 0 !== h[a.key];
}, l = function(b) {
var k = b.client, q = b.forward;
var h = b.client, q = b.forward;
return function(b) {
var l = a && "boolean" == typeof a.isClient ? !!a.isClient : !k.suspense, g = wonka.share(b);
var l = a && "boolean" == typeof a.isClient ? !!a.isClient : !h.suspense, g = wonka.share(b);
b = q(wonka.filter(c)(g));
g = wonka.map(d)(wonka.filter(f)(g));
l ? g = wonka.tap(e)(g) : b = wonka.tap(h)(b);
l ? g = wonka.tap(e)(g) : b = wonka.tap(k)(b);
return wonka.merge([ b, g ]);

@@ -217,6 +205,6 @@ };

l.restoreData = function(a) {
return fetchSource._extends(k, a);
return fetchSource._extends(h, a);
};
l.extractData = function() {
return fetchSource._extends({}, k);
return fetchSource._extends({}, h);
};

@@ -244,3 +232,3 @@ a && a.initialState && l.restoreData(a.initialState);

});
"cache-and-network" === a.context.requestPolicy && (b.stale = !0, reexecuteOperation(k, a));
"cache-and-network" === a.context.requestPolicy && (b.stale = !0, reexecuteOperation(h, a));
return b;

@@ -257,5 +245,5 @@ }

}
var m, l, p, n, h = a.forward, k = a.client, g = a.dispatchDebug, e = new Map;
var m, l, p, n, k = a.forward, h = a.client, g = a.dispatchDebug, e = new Map;
a = Object.create(null);
m = _ref$1, l = afterMutation(e, a, k, g), p = afterQuery(e, a), n = function(a) {
m = _ref$1, l = afterMutation(e, a, h, g), p = afterQuery(e, a), n = function(a) {
var c = a.context.requestPolicy;

@@ -267,3 +255,3 @@ return "query" === a.kind && "network-only" !== c && ("cache-only" === c || e.has(a.key));

a = wonka.map(b)(wonka.filter(c)(e));
e = wonka.tap(d)(h(wonka.filter(_ref5)(wonka.map(_ref6)(wonka.merge([ wonka.map(m)(wonka.filter(f)(e)), wonka.filter(_ref8)(e) ])))));
e = wonka.tap(d)(k(wonka.filter(_ref5)(wonka.map(_ref6)(wonka.merge([ wonka.map(m)(wonka.filter(f)(e)), wonka.filter(_ref8)(e) ])))));
return wonka.merge([ a, e ]);

@@ -307,3 +295,3 @@ };

return function(c) {
var d = c.operation, f = c.data, h = d.context.additionalTypenames;
var d = c.operation, f = c.data, k = d.context.additionalTypenames;
null != f && (a.set(d.key, {

@@ -313,3 +301,3 @@ operation: d,

error: c.error
}), collectTypesFromResponse(c.data).concat(h || []).forEach((function(a) {
}), collectTypesFromResponse(c.data).concat(k || []).forEach((function(a) {
(b[a] || (b[a] = new Set)).add(d.key);

@@ -341,17 +329,17 @@ })));

}
function k() {
l || (l = !0, "subscription" === a.kind && f.reexecuteOperation(makeOperation("teardown", a, a.context)),
h());
function h() {
k || (k = !0, "subscription" === a.kind && f.reexecuteOperation(makeOperation("teardown", a, a.context)),
m());
}
var m, g = c.next, h = c.complete, l = !1;
var l, g = c.next, m = c.complete, k = !1;
Promise.resolve().then((function() {
l || (m = b.subscribe({
k || (l = b.subscribe({
next: d,
error: e,
complete: k
complete: h
}));
}));
return function() {
l = !0;
m && m.unsubscribe();
k = !0;
l && l.unsubscribe();
};

@@ -397,3 +385,3 @@ }));

return !e;
}, h = function(a) {
}, k = function(a) {
d.delete(a.operation.key);

@@ -403,3 +391,3 @@ };

a = wonka.filter(f)(a);
return wonka.tap(h)(b(a));
return wonka.tap(k)(b(a));
};

@@ -409,7 +397,7 @@ }, fetchExchange = function(a) {

return function(a) {
var h, d = wonka.share(a);
var k, d = wonka.share(a);
a = wonka.mergeMap((function(a) {
var b = a.key, e = wonka.filter((function(a) {
return "teardown" === a.kind && a.key === b;
}))(d), f = fetchSource.makeFetchBody(a), h = fetchSource.makeFetchURL(a, f), k = fetchSource.makeFetchOptions(a, f);
}))(d), f = fetchSource.makeFetchBody(a), k = fetchSource.makeFetchURL(a, f), h = fetchSource.makeFetchOptions(a, f);
"production" !== process.env.NODE_ENV && c({

@@ -420,4 +408,4 @@ type: "fetchRequest",

data: {
url: h,
fetchOptions: k
url: k,
fetchOptions: h
},

@@ -433,4 +421,4 @@ source: "fetchExchange"

data: {
url: h,
fetchOptions: k,
url: k,
fetchOptions: h,
value: d || b

@@ -440,6 +428,6 @@ },

});
}))(wonka.takeUntil(e)(fetchSource.makeFetchSource(a, h, k)));
}))(wonka.takeUntil(e)(fetchSource.makeFetchSource(a, k, h)));
}))(wonka.filter(_ref$2)(d));
h = b(wonka.filter(_ref2$2)(d));
return wonka.merge([ a, h ]);
k = b(wonka.filter(_ref2$2)(d));
return wonka.merge([ a, k ]);
};

@@ -497,6 +485,7 @@ }, fallbackExchange = function(a) {

}, Client = function(a) {
var d, f, h, k, g, c = this;
var d, f, k, h, g, c = this;
this.activeOperations = Object.create(null);
this.queue = [];
this.createOperationContext = function(a) {
a || (a = {});
return fetchSource._extends({}, {

@@ -508,3 +497,4 @@ url: c.url,

}, a, {
requestPolicy: (a || {}).requestPolicy || c.requestPolicy
suspense: a.suspense || !1 !== a.suspense && c.suspense,
requestPolicy: a.requestPolicy || c.requestPolicy
});

@@ -517,6 +507,3 @@ };

a = c.createRequestOperation("query", a, b);
var e = c.executeRequestOperation(a);
return (a = a.context.pollInterval) ? wonka.switchMap((function d() {
return e;
}))(wonka.merge([ wonka.fromValue(0), wonka.interval(a) ])) : e;
return c.executeRequestOperation(a);
};

@@ -536,5 +523,5 @@ this.executeSubscription = function(a, b) {

if ("production" !== process.env.NODE_ENV) {
f = (d = wonka.makeSubject()).next, h = d.source;
f = (d = wonka.makeSubject()).next, k = d.source;
this.subscribeToDebugTarget = function b(a) {
return wonka.subscribe(a)(h);
return wonka.subscribe(a)(k);
};

@@ -551,3 +538,3 @@ d = f;

f = wonka.makeSubject();
k = f.next;
h = f.next;
this.operations$ = f.source;

@@ -557,4 +544,4 @@ g = !1;

g = !0;
for (a && k(a); a = c.queue.shift(); ) {
k(a);
for (a && h(a); a = c.queue.shift(); ) {
h(a);
}

@@ -587,24 +574,30 @@ g = !1;

var b = a.key, c = this.activeOperations[b] || 0;
0 >= (this.activeOperations[b] = 0 >= c ? 0 : c - 1) && this.dispatchOperation(makeOperation("teardown", a, a.context));
if (0 >= (this.activeOperations[b] = 0 >= c ? 0 : c - 1)) {
for (b = this.queue.length - 1; 0 <= b; b--) {
this.queue[b].key === a.key && this.queue.splice(b, 1);
}
this.dispatchOperation(makeOperation("teardown", a, a.context));
}
};
Client.prototype.executeRequestOperation = function(a) {
var k, c = this, d = a.key, f = a.kind, h = wonka.filter((function(a) {
return a.operation.key === d;
var k, h, d = this, f = wonka.filter((function(b) {
return b.operation.key === a.key;
}))(this.results$);
this.maskTypename && (h = wonka.map(_ref3$2)(h));
if ("mutation" === f) {
this.maskTypename && (f = wonka.map(_ref2$3)(f));
if ("mutation" === a.kind) {
return wonka.take(1)(wonka.onStart((function b() {
return c.dispatchOperation(a);
}))(h));
return d.dispatchOperation(a);
}))(f));
}
k = wonka.filter((function(a) {
return "teardown" === a.kind && a.key === d;
}))(this.operations$);
h = wonka.onEnd((function() {
c.onOperationEnd(a);
k = wonka.filter((function(b) {
return "teardown" === b.kind && b.key === a.key;
}))(this.operations$), h = wonka.onEnd((function() {
d.onOperationEnd(a);
}))(wonka.onStart((function() {
c.onOperationStart(a);
}))(wonka.takeUntil(k)(h)));
return !1 !== a.context.suspense && this.suspense && "query" === f ? toSuspenseSource(h) : h;
d.onOperationStart(a);
}))(wonka.takeUntil(k)(f)));
return "query" === a.kind && a.context.pollInterval ? wonka.switchMap((function c() {
return h;
}))(wonka.merge([ wonka.fromValue(0), wonka.interval(a.context.pollInterval) ])) : h;
};

@@ -611,0 +604,0 @@

@@ -1,2 +0,2 @@

"use strict";var e=require("./0cc80063.min.js"),t=require("wonka"),r=require("graphql"),n=function(e,t){if(void 0===t&&(t=[]),Array.isArray(e))e.forEach((function(e){n(e,t)}));else if("object"==typeof e&&null!==e)for(var r in e)"__typename"===r&&"string"==typeof e[r]?t.push(e[r]):n(e[r],t);return t};function o(e,t,r){return r.indexOf(e)===t}var i=function(e){return n(e).filter(o)};function u(e){return e.kind===r.Kind.FIELD&&"__typename"===e.name.value}var a=function(t){if(t.selectionSet&&!t.selectionSet.selections.some(u))return e._extends({},t,{selectionSet:e._extends({},t.selectionSet,{selections:t.selectionSet.selections.concat([{kind:r.Kind.FIELD,name:{kind:r.Kind.NAME,value:"__typename"}}])})})},c=function(e){var t=r.visit(e,{Field:a,InlineFragment:a});return t.__key=e.__key,t},s=function(e){return e&&"object"==typeof e?Object.keys(e).reduce((function(t,r){var n=e[r];return"__typename"===r?Object.defineProperty(t,"__typename",{enumerable:!1,value:n}):t[r]=Array.isArray(n)?n.map(s):n&&"object"==typeof n&&"__typename"in n?s(n):n,t}),{}):e};function f(e){return e.toPromise=function(){return t.toPromise(t.take(1)(e))},e}function p(e,t,r){return r||(r=t.context),{key:t.key,query:t.query,variables:t.variables,kind:e,context:r,get operationName(){return this.kind}}}var h=function(t,r){return p(t.kind,t,e._extends({},t.context,{meta:e._extends({},t.context.meta,r)}))},d=function(){},l=function(e){return"subscription"!==(e=e.kind)&&"query"!==e};function y(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}var k=function(e){return"mutation"!==(e=e.kind)&&"query"!==e};function v(e){var t=p(e.kind,e);return t.query=c(e.query),t}function m(e){return"query"!==e.kind||"cache-only"!==e.context.requestPolicy}function x(e){return h(e,{cacheOutcome:"miss"})}function q(e){return k(e)}var g=function(r){function n(t){var r=s.get(t.key);return r=e._extends({},r,{operation:h(t,{cacheOutcome:r?"hit":"miss"})}),"cache-and-network"===t.context.requestPolicy&&(r.stale=!0,b(c,t)),r}function o(e){return!k(e)&&y(e)}function i(e){e.operation&&"mutation"===e.operation.kind?d(e):e.operation&&"query"===e.operation.kind&&l(e)}function u(e){return!k(e)&&!y(e)}var a=r.forward,c=r.client;r=r.dispatchDebug;var s=new Map,f=Object.create(null),p=v,d=O(s,f,c,r),l=E(s,f),y=function(e){var t=e.context.requestPolicy;return"query"===e.kind&&"network-only"!==t&&("cache-only"===t||s.has(e.key))};return function(e){var r=t.share(e);return e=t.map(n)(t.filter(o)(r)),r=t.tap(i)(a(t.filter(m)(t.map(x)(t.merge([t.map(p)(t.filter(u)(r)),t.filter(q)(r)]))))),t.merge([e,r])}},b=function(t,r){return t.reexecuteOperation(p(r.kind,r,e._extends({},r.context,{requestPolicy:"network-only"})))},O=function(e,t,r,n){function o(t){if(e.has(t)){var n=e.get(t).operation;e.delete(t),b(r,n)}}return function(e){function r(e){n.add(e)}var n=new Set,u=e.operation.context.additionalTypenames;(e=i(e.data).concat(u||[])).forEach((function(e){(e=t[e]||(t[e]=new Set)).forEach(r),e.clear()})),n.forEach(o)}},E=function(e,t){return function(r){var n=r.operation,o=r.data,u=n.context.additionalTypenames;null!=o&&(e.set(n.key,{operation:n,data:o,error:r.error}),i(r.data).concat(u||[]).forEach((function(e){(t[e]||(t[e]=new Set)).add(n.key)})))}},w=function(e){var r=e.forward,n=new Set,o=function(e){var t=e.key;return"teardown"===(e=e.kind)?(n.delete(t),!0):"query"!==e&&"subscription"!==e||(e=n.has(t),n.add(t),!e)},i=function(e){n.delete(e.operation.key)};return function(e){return e=t.filter(o)(e),t.tap(i)(r(e))}};function _(e){return"query"===e.kind||"mutation"===e.kind}function S(e){return"query"!==e.kind&&"mutation"!==e.kind}var R=function(r){var n=r.forward;return function(r){var o=t.share(r);r=t.mergeMap((function(r){var n=r.key,i=t.filter((function(e){return"teardown"===e.kind&&e.key===n}))(o),u=e.makeFetchBody(r),a=e.makeFetchURL(r,u);return u=e.makeFetchOptions(r,u),t.onPush((function(e){}))(t.takeUntil(i)(e.makeFetchSource(r,a,u)))}))(t.filter(_)(o));var i=n(t.filter(S)(o));return t.merge([r,i])}};function P(){return!1}var M=function(e){function r(e){}return function(e){return t.filter(P)(t.tap(r)(e))}},Q=M(),j=function(e){return function(t){var r=t.client;return e.reduceRight((function(e,t){return t({client:r,forward:e,dispatchDebug:function(e){}})}),t.forward)}},C=[w,g,R],D=function(r){var n=this;this.activeOperations=Object.create(null),this.queue=[],this.createOperationContext=function(t){return e._extends({},{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod},t,{requestPolicy:(t||{}).requestPolicy||n.requestPolicy})},this.createRequestOperation=function(e,t,r){return p(e,t,n.createOperationContext(r))},this.executeQuery=function(e,r){e=n.createRequestOperation("query",e,r);var o=n.executeRequestOperation(e);return(e=e.context.pollInterval)?t.switchMap((function(){return o}))(t.merge([t.fromValue(0),t.interval(e)])):o},this.executeSubscription=function(e,t){return e=n.createRequestOperation("subscription",e,t),n.executeRequestOperation(e)},this.executeMutation=function(e,t){return e=n.createRequestOperation("mutation",e,t),n.executeRequestOperation(e)};var o=d;this.url=r.url,this.fetchOptions=r.fetchOptions,this.fetch=r.fetch,this.suspense=!!r.suspense,this.requestPolicy=r.requestPolicy||"cache-first",this.preferGetMethod=!!r.preferGetMethod,this.maskTypename=!!r.maskTypename;var i=t.makeSubject(),u=i.next;this.operations$=i.source;var a=!1;this.dispatchOperation=function(e){for(a=!0,e&&u(e);e=n.queue.shift();)u(e);a=!1},this.reexecuteOperation=function(e){("mutation"===e.kind||0<(n.activeOperations[e.key]||0))&&(n.queue.push(e),a||Promise.resolve().then(n.dispatchOperation))},r=j(void 0!==r.exchanges?r.exchanges:C),this.results$=t.share(r({client:this,dispatchDebug:o,forward:M()})(this.operations$)),t.publish(this.results$)};function L(e){return e.data=s(e.data),e}D.prototype.onOperationStart=function(e){var t=e.key;this.activeOperations[t]=(this.activeOperations[t]||0)+1,this.dispatchOperation(e)},D.prototype.onOperationEnd=function(e){var t=e.key,r=this.activeOperations[t]||0;0>=(this.activeOperations[t]=0>=r?0:r-1)&&this.dispatchOperation(p("teardown",e,e.context))},D.prototype.executeRequestOperation=function(e){var r=this,n=e.key,o=e.kind,i=t.filter((function(e){return e.operation.key===n}))(this.results$);if(this.maskTypename&&(i=t.map(L)(i)),"mutation"===o)return t.take(1)(t.onStart((function(){return r.dispatchOperation(e)}))(i));var u=t.filter((function(e){return"teardown"===e.kind&&e.key===n}))(this.operations$);return i=t.onEnd((function(){r.onOperationEnd(e)}))(t.onStart((function(){r.onOperationStart(e)}))(t.takeUntil(u)(i))),!1!==e.context.suspense&&this.suspense&&"query"===o?function(e){return function(r){var n=t.share(e),o=!1,i=!1;if(t.onPush((function(){return o=!0}))(t.takeWhile((function(){return!i}))(n))(r),!o)throw i=!0,r(0),t.toPromise(t.take(1)(n))}}(i):i},D.prototype.query=function(t,r,n){return n&&"boolean"==typeof n.suspense||(n=e._extends({},n,{suspense:!1})),f(this.executeQuery(e.createRequest(t,r),n))},D.prototype.readQuery=function(r,n,o){var i=null;return t.subscribe((function(e){i=e}))(this.executeQuery(e.createRequest(r,n),o)).unsubscribe(),i},D.prototype.subscription=function(t,r,n){return this.executeSubscription(e.createRequest(t,r),n)},D.prototype.mutation=function(t,r,n){return f(this.executeMutation(e.createRequest(t,r),n))},exports.CombinedError=e.CombinedError,exports.createRequest=e.createRequest,exports.makeErrorResult=e.makeErrorResult,exports.makeResult=e.makeResult,exports.stringifyVariables=e.stringifyVariables,exports.Client=D,exports.cacheExchange=g,exports.composeExchanges=j,exports.createClient=function(e){return new D(e)},exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=w,exports.defaultExchanges=C,exports.errorExchange=function(e){function r(e){var t=e.error;e=e.operation,t&&n(t,e)}var n=e.onError;return function(e){var n=e.forward;return function(e){return t.tap(r)(n(e))}}},exports.fallbackExchangeIO=Q,exports.fetchExchange=R,exports.formatDocument=c,exports.makeOperation=p,exports.maskTypename=s,exports.ssrExchange=function(r){function n(){for(var e;e=s.shift();)delete c[e]}function o(e){return!p(e)}function i(t){return function(t,r){var n=r.error;return{operation:t,data:(r=r.data)?JSON.parse(r):void 0,extensions:void 0,error:n?new e.CombinedError({networkError:n.networkError?Error(n.networkError):void 0,graphQLErrors:n.graphQLErrors&&n.graphQLErrors.length?n.graphQLErrors:void 0}):void 0}}(t,c[t.key])}function u(e){return p(e)}function a(e){var t=e.operation;l(t)||(e=function(e){var t=e.error;return e={data:JSON.stringify(e.data),error:void 0},t&&(e.error={graphQLErrors:t.graphQLErrors.map(y),networkError:t.networkError?""+t.networkError:void 0}),e}(e),c[t.key]=e)}var c={},s=[],f=function(e){s.push(e.operation.key),1===s.length&&Promise.resolve().then(n)},p=function(e){return!l(e)&&void 0!==c[e.key]},h=function(e){var n=e.client,c=e.forward;return function(e){var s=r&&"boolean"==typeof r.isClient?!!r.isClient:!n.suspense,p=t.share(e);return e=c(t.filter(o)(p)),p=t.map(i)(t.filter(u)(p)),s?p=t.tap(f)(p):e=t.tap(a)(e),t.merge([e,p])}};return h.restoreData=function(t){return e._extends(c,t)},h.extractData=function(){return e._extends({},c)},r&&r.initialState&&h.restoreData(r.initialState),h},exports.subscriptionExchange=function(n){function o(e){return"subscription"===(e=e.kind)||!!u&&("query"===e||"mutation"===e)}var i=n.forwardSubscription,u=n.enableAllOperations;return function(n){function u(e){return!f(e)}var a=n.client,c=n.forward,s=function(n){var o=i({key:n.key.toString(36),query:r.print(n.query),variables:n.variables,context:e._extends({},n.context)});return t.make((function(t){function r(t){return s(e.makeResult(n,t))}function i(t){return s(e.makeErrorResult(n,t))}function u(){h||(h=!0,"subscription"===n.kind&&a.reexecuteOperation(p("teardown",n,n.context)),f())}var c,s=t.next,f=t.complete,h=!1;return Promise.resolve().then((function(){h||(c=o.subscribe({next:r,error:i,complete:u}))})),function(){h=!0,c&&c.unsubscribe()}}))},f=o;return function(e){var r=t.share(e);e=t.mergeMap((function(e){var n=e.key,o=t.filter((function(e){return"teardown"===e.kind&&e.key===n}))(r);return t.takeUntil(o)(s(e))}))(t.filter(f)(r));var n=c(t.filter(u)(r));return t.merge([e,n])}}};
"use strict";var e=require("./0cc80063.min.js"),t=require("wonka"),r=require("graphql"),n=function(e,t){if(void 0===t&&(t=[]),Array.isArray(e))e.forEach((function(e){n(e,t)}));else if("object"==typeof e&&null!==e)for(var r in e)"__typename"===r&&"string"==typeof e[r]?t.push(e[r]):n(e[r],t);return t};function o(e,t,r){return r.indexOf(e)===t}var i=function(e){return n(e).filter(o)};function u(e){return e.kind===r.Kind.FIELD&&"__typename"===e.name.value}var a=function(t){if(t.selectionSet&&!t.selectionSet.selections.some(u))return e._extends({},t,{selectionSet:e._extends({},t.selectionSet,{selections:t.selectionSet.selections.concat([{kind:r.Kind.FIELD,name:{kind:r.Kind.NAME,value:"__typename"}}])})})},c=function(e){var t=r.visit(e,{Field:a,InlineFragment:a});return t.__key=e.__key,t},s=function(e){return e&&"object"==typeof e?Object.keys(e).reduce((function(t,r){var n=e[r];return"__typename"===r?Object.defineProperty(t,"__typename",{enumerable:!1,value:n}):t[r]=Array.isArray(n)?n.map(s):n&&"object"==typeof n&&"__typename"in n?s(n):n,t}),{}):e};function f(e){return e.toPromise=function(){return t.toPromise(t.take(1)(e))},e}function p(e,t,r){return r||(r=t.context),{key:t.key,query:t.query,variables:t.variables,kind:e,context:r,get operationName(){return this.kind}}}var l=function(t,r){return p(t.kind,t,e._extends({},t.context,{meta:e._extends({},t.context.meta,r)}))},h=function(){},d=function(e){return"subscription"!==(e=e.kind)&&"query"!==e};function y(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}var k=function(e){return"mutation"!==(e=e.kind)&&"query"!==e};function v(e){var t=p(e.kind,e);return t.query=c(e.query),t}function x(e){return"query"!==e.kind||"cache-only"!==e.context.requestPolicy}function m(e){return l(e,{cacheOutcome:"miss"})}function q(e){return k(e)}var g=function(r){function n(t){var r=s.get(t.key);return r=e._extends({},r,{operation:l(t,{cacheOutcome:r?"hit":"miss"})}),"cache-and-network"===t.context.requestPolicy&&(r.stale=!0,b(c,t)),r}function o(e){return!k(e)&&y(e)}function i(e){e.operation&&"mutation"===e.operation.kind?h(e):e.operation&&"query"===e.operation.kind&&d(e)}function u(e){return!k(e)&&!y(e)}var a=r.forward,c=r.client;r=r.dispatchDebug;var s=new Map,f=Object.create(null),p=v,h=O(s,f,c,r),d=E(s,f),y=function(e){var t=e.context.requestPolicy;return"query"===e.kind&&"network-only"!==t&&("cache-only"===t||s.has(e.key))};return function(e){var r=t.share(e);return e=t.map(n)(t.filter(o)(r)),r=t.tap(i)(a(t.filter(x)(t.map(m)(t.merge([t.map(p)(t.filter(u)(r)),t.filter(q)(r)]))))),t.merge([e,r])}},b=function(t,r){return t.reexecuteOperation(p(r.kind,r,e._extends({},r.context,{requestPolicy:"network-only"})))},O=function(e,t,r,n){function o(t){if(e.has(t)){var n=e.get(t).operation;e.delete(t),b(r,n)}}return function(e){function r(e){n.add(e)}var n=new Set,u=e.operation.context.additionalTypenames;(e=i(e.data).concat(u||[])).forEach((function(e){(e=t[e]||(t[e]=new Set)).forEach(r),e.clear()})),n.forEach(o)}},E=function(e,t){return function(r){var n=r.operation,o=r.data,u=n.context.additionalTypenames;null!=o&&(e.set(n.key,{operation:n,data:o,error:r.error}),i(r.data).concat(u||[]).forEach((function(e){(t[e]||(t[e]=new Set)).add(n.key)})))}},w=function(e){var r=e.forward,n=new Set,o=function(e){var t=e.key;return"teardown"===(e=e.kind)?(n.delete(t),!0):"query"!==e&&"subscription"!==e||(e=n.has(t),n.add(t),!e)},i=function(e){n.delete(e.operation.key)};return function(e){return e=t.filter(o)(e),t.tap(i)(r(e))}};function _(e){return"query"===e.kind||"mutation"===e.kind}function S(e){return"query"!==e.kind&&"mutation"!==e.kind}var R=function(r){var n=r.forward;return function(r){var o=t.share(r);r=t.mergeMap((function(r){var n=r.key,i=t.filter((function(e){return"teardown"===e.kind&&e.key===n}))(o),u=e.makeFetchBody(r),a=e.makeFetchURL(r,u);return u=e.makeFetchOptions(r,u),t.onPush((function(e){}))(t.takeUntil(i)(e.makeFetchSource(r,a,u)))}))(t.filter(_)(o));var i=n(t.filter(S)(o));return t.merge([r,i])}};function P(){return!1}var M=function(e){function r(e){}return function(e){return t.filter(P)(t.tap(r)(e))}},Q=M(),j=function(e){return function(t){var r=t.client;return e.reduceRight((function(e,t){return t({client:r,forward:e,dispatchDebug:function(e){}})}),t.forward)}},C=[w,g,R],D=function(r){var n=this;this.activeOperations=Object.create(null),this.queue=[],this.createOperationContext=function(t){return t||(t={}),e._extends({},{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod},t,{suspense:t.suspense||!1!==t.suspense&&n.suspense,requestPolicy:t.requestPolicy||n.requestPolicy})},this.createRequestOperation=function(e,t,r){return p(e,t,n.createOperationContext(r))},this.executeQuery=function(e,t){return e=n.createRequestOperation("query",e,t),n.executeRequestOperation(e)},this.executeSubscription=function(e,t){return e=n.createRequestOperation("subscription",e,t),n.executeRequestOperation(e)},this.executeMutation=function(e,t){return e=n.createRequestOperation("mutation",e,t),n.executeRequestOperation(e)};var o=h;this.url=r.url,this.fetchOptions=r.fetchOptions,this.fetch=r.fetch,this.suspense=!!r.suspense,this.requestPolicy=r.requestPolicy||"cache-first",this.preferGetMethod=!!r.preferGetMethod,this.maskTypename=!!r.maskTypename;var i=t.makeSubject(),u=i.next;this.operations$=i.source;var a=!1;this.dispatchOperation=function(e){for(a=!0,e&&u(e);e=n.queue.shift();)u(e);a=!1},this.reexecuteOperation=function(e){("mutation"===e.kind||0<(n.activeOperations[e.key]||0))&&(n.queue.push(e),a||Promise.resolve().then(n.dispatchOperation))},r=j(void 0!==r.exchanges?r.exchanges:C),this.results$=t.share(r({client:this,dispatchDebug:o,forward:M()})(this.operations$)),t.publish(this.results$)};function L(e){return e.data=s(e.data),e}D.prototype.onOperationStart=function(e){var t=e.key;this.activeOperations[t]=(this.activeOperations[t]||0)+1,this.dispatchOperation(e)},D.prototype.onOperationEnd=function(e){var t=e.key,r=this.activeOperations[t]||0;if(0>=(this.activeOperations[t]=0>=r?0:r-1)){for(t=this.queue.length-1;0<=t;t--)this.queue[t].key===e.key&&this.queue.splice(t,1);this.dispatchOperation(p("teardown",e,e.context))}},D.prototype.executeRequestOperation=function(e){var r=this,n=t.filter((function(t){return t.operation.key===e.key}))(this.results$);if(this.maskTypename&&(n=t.map(L)(n)),"mutation"===e.kind)return t.take(1)(t.onStart((function(){return r.dispatchOperation(e)}))(n));var o=t.filter((function(t){return"teardown"===t.kind&&t.key===e.key}))(this.operations$),i=t.onEnd((function(){r.onOperationEnd(e)}))(t.onStart((function(){r.onOperationStart(e)}))(t.takeUntil(o)(n)));return"query"===e.kind&&e.context.pollInterval?t.switchMap((function(){return i}))(t.merge([t.fromValue(0),t.interval(e.context.pollInterval)])):i},D.prototype.query=function(t,r,n){return n&&"boolean"==typeof n.suspense||(n=e._extends({},n,{suspense:!1})),f(this.executeQuery(e.createRequest(t,r),n))},D.prototype.readQuery=function(r,n,o){var i=null;return t.subscribe((function(e){i=e}))(this.executeQuery(e.createRequest(r,n),o)).unsubscribe(),i},D.prototype.subscription=function(t,r,n){return this.executeSubscription(e.createRequest(t,r),n)},D.prototype.mutation=function(t,r,n){return f(this.executeMutation(e.createRequest(t,r),n))},exports.CombinedError=e.CombinedError,exports.createRequest=e.createRequest,exports.makeErrorResult=e.makeErrorResult,exports.makeResult=e.makeResult,exports.stringifyVariables=e.stringifyVariables,exports.Client=D,exports.cacheExchange=g,exports.composeExchanges=j,exports.createClient=function(e){return new D(e)},exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=w,exports.defaultExchanges=C,exports.errorExchange=function(e){function r(e){var t=e.error;e=e.operation,t&&n(t,e)}var n=e.onError;return function(e){var n=e.forward;return function(e){return t.tap(r)(n(e))}}},exports.fallbackExchangeIO=Q,exports.fetchExchange=R,exports.formatDocument=c,exports.makeOperation=p,exports.maskTypename=s,exports.ssrExchange=function(r){function n(){for(var e;e=s.shift();)delete c[e]}function o(e){return!p(e)}function i(t){return function(t,r){var n=r.error;return{operation:t,data:(r=r.data)?JSON.parse(r):void 0,extensions:void 0,error:n?new e.CombinedError({networkError:n.networkError?Error(n.networkError):void 0,graphQLErrors:n.graphQLErrors&&n.graphQLErrors.length?n.graphQLErrors:void 0}):void 0}}(t,c[t.key])}function u(e){return p(e)}function a(e){var t=e.operation;d(t)||(e=function(e){var t=e.error;return e={data:JSON.stringify(e.data),error:void 0},t&&(e.error={graphQLErrors:t.graphQLErrors.map(y),networkError:t.networkError?""+t.networkError:void 0}),e}(e),c[t.key]=e)}var c={},s=[],f=function(e){s.push(e.operation.key),1===s.length&&Promise.resolve().then(n)},p=function(e){return!d(e)&&void 0!==c[e.key]},l=function(e){var n=e.client,c=e.forward;return function(e){var s=r&&"boolean"==typeof r.isClient?!!r.isClient:!n.suspense,p=t.share(e);return e=c(t.filter(o)(p)),p=t.map(i)(t.filter(u)(p)),s?p=t.tap(f)(p):e=t.tap(a)(e),t.merge([e,p])}};return l.restoreData=function(t){return e._extends(c,t)},l.extractData=function(){return e._extends({},c)},r&&r.initialState&&l.restoreData(r.initialState),l},exports.subscriptionExchange=function(n){function o(e){return"subscription"===(e=e.kind)||!!u&&("query"===e||"mutation"===e)}var i=n.forwardSubscription,u=n.enableAllOperations;return function(n){function u(e){return!f(e)}var a=n.client,c=n.forward,s=function(n){var o=i({key:n.key.toString(36),query:r.print(n.query),variables:n.variables,context:e._extends({},n.context)});return t.make((function(t){function r(t){return s(e.makeResult(n,t))}function i(t){return s(e.makeErrorResult(n,t))}function u(){l||(l=!0,"subscription"===n.kind&&a.reexecuteOperation(p("teardown",n,n.context)),f())}var c,s=t.next,f=t.complete,l=!1;return Promise.resolve().then((function(){l||(c=o.subscribe({next:r,error:i,complete:u}))})),function(){l=!0,c&&c.unsubscribe()}}))},f=o;return function(e){var r=t.share(e);e=t.mergeMap((function(e){var n=e.key,o=t.filter((function(e){return"teardown"===e.kind&&e.key===n}))(r);return t.takeUntil(o)(s(e))}))(t.filter(f)(r));var n=c(t.filter(u)(r));return t.merge([e,n])}}};
//# sourceMappingURL=urql-core.min.js.map
{
"name": "@urql/core",
"version": "1.14.1",
"version": "1.15.0",
"description": "The shared core for the highly customizable and versatile GraphQL client",

@@ -66,2 +66,3 @@ "sideEffects": false,

"dependencies": {
"@graphql-typed-document-node/core": "^3.1.0",
"wonka": "^4.0.14"

@@ -68,0 +69,0 @@ },

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc