Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@urql/exchange-persisted

Package Overview
Dependencies
Maintainers
6
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@urql/exchange-persisted - npm Package Compare versions

Comparing version 0.0.0-canary-20230425131626 to 0.0.0-canary-20230428150104

11

CHANGELOG.md
# @urql/exchange-persisted-fetch
## 0.0.0-canary-20230425131626
## 0.0.0-canary-20230428150104
### Major Changes
- Update the `preferGetForPersistedQueries` option to include the `'force'` and `'within-url-limit'` values from the Client's `preferGetMethod` option. The default value of `true` no longer sets `OperationContext`'s `preferGetMethod` setting to `'force'`. Instead, the value of `preferGetForPersistedQueries` carries through to the `OperationContext`'s `preferGetMethod` setting for persisted queries
Submitted by [@NWRichmond](https://github.com/NWRichmond) (See [#3192](https://github.com/urql-graphql/urql/pull/3192))
## 3.0.1
### Patch Changes

@@ -9,4 +16,2 @@

Submitted by [@kitten](https://github.com/kitten) (See [#3180](https://github.com/urql-graphql/urql/pull/3180))
- Updated dependencies (See [#3180](https://github.com/urql-graphql/urql/pull/3180))
- @urql/core@0.0.0-canary-20230425131626

@@ -13,0 +18,0 @@ ## 3.0.0

@@ -1,18 +0,22 @@

import { TypedDocumentNode, Exchange } from '@urql/core';
import { OperationContext, TypedDocumentNode, Exchange } from '@urql/core';
/** Input parameters for the {@link persistedExchange}. */
interface PersistedExchangeOptions {
/** Enforces GET method requests to be made for Persisted Queries.
/** Controls whether GET method requests will be made for Persisted Queries.
*
* @remarks
* When enabled, the `persistedExchange` will set
* When set to `true` or `'within-url-limit'`, the `persistedExchange`
* will use GET requests on persisted queries when the request URL
* doesn't exceed the 2048 character limit.
*
* When set to `force`, the `persistedExchange` will set
* `OperationContext.preferGetMethod` to `'force'` on persisted queries,
* which will force requests to be made using a GET request.
*
* This is frequently used to make GraphQL requests more cacheable
* on CDNs.
* GET requests are frequently used to make GraphQL requests more
* cacheable on CDNs.
*
* @defaultValue `true` - enabled
* @defaultValue `undefined` - disabled
*/
preferGetForPersistedQueries?: boolean;
preferGetForPersistedQueries?: OperationContext['preferGetMethod'];
/** Enforces non-automatic persisted queries by ignoring APQ errors.

@@ -19,0 +23,0 @@ *

@@ -77,3 +77,3 @@ Object.defineProperty(exports, '__esModule', {

if (!options) options = {};
var preferGetForPersistedQueries = !!options.preferGetForPersistedQueries;
var preferGetForPersistedQueries = options.preferGetForPersistedQueries;
var enforcePersistedQueries = !!options.enforcePersistedQueries;

@@ -102,3 +102,3 @@ var hashFn = options.generateHash || hash;

if (persistedOperation.kind === 'query' && preferGetForPersistedQueries) {
persistedOperation.context.preferGetMethod = 'force';
persistedOperation.context.preferGetMethod = preferGetForPersistedQueries;
}

@@ -105,0 +105,0 @@ }

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

Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("wonka"),t=require("@urql/core"),n="undefined"!=typeof window?window.crypto:"undefined"!=typeof self?self.crypto:null,s=async r=>{if(n&&n.subtle){var t=await n.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(r));return new Uint8Array(t).reduce(((e,r)=>e+r.toString(16).padStart(2,"0")),"")}return await(async()=>{if(!e)try{e=new Function("require",'return require("crypto")')(require)}catch(r){try{e=new Function('return import("crypto")')()}catch(e){}}return e})()?(await e).createHash("sha256").update(r).digest("hex"):""};exports.persistedExchange=e=>({forward:n})=>{e||(e={});var i=!!e.preferGetForPersistedQueries,o=!!e.enforcePersistedQueries,a=e.generateHash||s,u=!!e.enableForMutation,p=!0,d=e=>p&&!e.context.persistAttempt&&(u&&"mutation"===e.kind||"query"===e.kind);return e=>{var s=r.makeSubject(),u=r.filter((e=>!d(e)))(e),c=r.mergeMap(r.fromPromise)(r.map((async e=>{var r=t.makeOperation(e.kind,e,{...e.context,persistAttempt:!0}),n=await a(t.stringifyDocument(e.query),e.query);return n&&(r.extensions={...r.extensions,persistedQuery:{version:1,sha256Hash:n}},"query"===r.kind&&i&&(r.context.preferGetMethod="force")),r}))(r.filter(d)(e)));return r.filter((e=>!!e))(r.map((e=>{if(!o&&e.operation.extensions&&e.operation.extensions.persistedQuery){if(e.error&&e.error.graphQLErrors.some((e=>"PersistedQueryNotSupported"===e.message))){p=!1;var r=t.makeOperation(e.operation.kind,e.operation);return r.extensions&&delete r.extensions.persistedQuery,s.next(r),null}if(e.error&&e.error.graphQLErrors.some((e=>"PersistedQueryNotFound"===e.message))){var n=t.makeOperation(e.operation.kind,e.operation);return n.extensions={...n.extensions,persistedQuery:{...(n.extensions||{}).persistedQuery,miss:!0}},s.next(n),null}}return e}))(n(r.merge([c,u,s.source]))))}};
Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("wonka"),t=require("@urql/core"),n="undefined"!=typeof window?window.crypto:"undefined"!=typeof self?self.crypto:null,s=async r=>{if(n&&n.subtle){var t=await n.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(r));return new Uint8Array(t).reduce(((e,r)=>e+r.toString(16).padStart(2,"0")),"")}return await(async()=>{if(!e)try{e=new Function("require",'return require("crypto")')(require)}catch(r){try{e=new Function('return import("crypto")')()}catch(e){}}return e})()?(await e).createHash("sha256").update(r).digest("hex"):""};exports.persistedExchange=e=>({forward:n})=>{e||(e={});var i=e.preferGetForPersistedQueries,o=!!e.enforcePersistedQueries,a=e.generateHash||s,u=!!e.enableForMutation,p=!0,d=e=>p&&!e.context.persistAttempt&&(u&&"mutation"===e.kind||"query"===e.kind);return e=>{var s=r.makeSubject(),u=r.filter((e=>!d(e)))(e),c=r.mergeMap(r.fromPromise)(r.map((async e=>{var r=t.makeOperation(e.kind,e,{...e.context,persistAttempt:!0}),n=await a(t.stringifyDocument(e.query),e.query);return n&&(r.extensions={...r.extensions,persistedQuery:{version:1,sha256Hash:n}},"query"===r.kind&&i&&(r.context.preferGetMethod=i)),r}))(r.filter(d)(e)));return r.filter((e=>!!e))(r.map((e=>{if(!o&&e.operation.extensions&&e.operation.extensions.persistedQuery){if(e.error&&e.error.graphQLErrors.some((e=>"PersistedQueryNotSupported"===e.message))){p=!1;var r=t.makeOperation(e.operation.kind,e.operation);return r.extensions&&delete r.extensions.persistedQuery,s.next(r),null}if(e.error&&e.error.graphQLErrors.some((e=>"PersistedQueryNotFound"===e.message))){var n=t.makeOperation(e.operation.kind,e.operation);return n.extensions={...n.extensions,persistedQuery:{...(n.extensions||{}).persistedQuery,miss:!0}},s.next(n),null}}return e}))(n(r.merge([c,u,s.source]))))}};
//# sourceMappingURL=urql-exchange-persisted.min.js.map
{
"name": "@urql/exchange-persisted",
"version": "0.0.0-canary-20230425131626",
"version": "0.0.0-canary-20230428150104",
"description": "An exchange that allows for persisted queries support when fetching queries",

@@ -40,3 +40,3 @@ "sideEffects": false,

"dependencies": {
"@urql/core": "0.0.0-canary-20230425131626",
"@urql/core": ">=4.0.0",
"wonka": "^6.3.2"

@@ -46,3 +46,3 @@ },

"graphql": "^16.0.0",
"@urql/core": "0.0.0-canary-20230425131626"
"@urql/core": "4.0.7"
},

@@ -49,0 +49,0 @@ "publishConfig": {

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