@urql/exchange-persisted
Advanced tools
Comparing version 0.0.0-canary-20230317001715 to 0.0.0-canary-20230317070130
# @urql/exchange-persisted-fetch | ||
## 0.0.0-canary-20230317001715 | ||
## 0.0.0-canary-20230317070130 | ||
@@ -16,4 +16,6 @@ ### Major Changes | ||
Submitted by [@kitten](https://github.com/kitten) (See [#3052](https://github.com/urql-graphql/urql/pull/3052)) | ||
- Add TSDocs for all exchanges, documenting API internals | ||
Submitted by [@kitten](https://github.com/kitten) (See [#3072](https://github.com/urql-graphql/urql/pull/3072)) | ||
- Updated dependencies (See [#3033](https://github.com/urql-graphql/urql/pull/3033), [#3054](https://github.com/urql-graphql/urql/pull/3054), [#3053](https://github.com/urql-graphql/urql/pull/3053), [#3060](https://github.com/urql-graphql/urql/pull/3060), [#3039](https://github.com/urql-graphql/urql/pull/3039), [#3061](https://github.com/urql-graphql/urql/pull/3061), [#3055](https://github.com/urql-graphql/urql/pull/3055), [#3059](https://github.com/urql-graphql/urql/pull/3059), [#3055](https://github.com/urql-graphql/urql/pull/3055), [#3057](https://github.com/urql-graphql/urql/pull/3057), [#3050](https://github.com/urql-graphql/urql/pull/3050), [#3062](https://github.com/urql-graphql/urql/pull/3062), [#3051](https://github.com/urql-graphql/urql/pull/3051), [#3043](https://github.com/urql-graphql/urql/pull/3043), [#3063](https://github.com/urql-graphql/urql/pull/3063), [#3054](https://github.com/urql-graphql/urql/pull/3054), [#3058](https://github.com/urql-graphql/urql/pull/3058), and [#3062](https://github.com/urql-graphql/urql/pull/3062)) | ||
- @urql/core@0.0.0-canary-20230317001715 | ||
- @urql/core@0.0.0-canary-20230317070130 | ||
@@ -20,0 +22,0 @@ ## 2.1.0 |
import { Exchange } from '@urql/core'; | ||
import { DocumentNode } from 'graphql'; | ||
/** Input parameters for the {@link persistedExchange}. */ | ||
interface PersistedExchangeOptions { | ||
/** Enforces GET method requests to be made for Persisted Queries. | ||
* | ||
* @remarks | ||
* When enabled, 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. | ||
* | ||
* @defaultValue `true` - enabled | ||
*/ | ||
preferGetForPersistedQueries?: boolean; | ||
/** Enforces non-automatic persisted queries by ignoring APQ errors. | ||
* | ||
* @remarks | ||
* When enabled, the `persistedExchange` will ignore `PersistedQueryNotFound` | ||
* and `PersistedQueryNotSupported` errors and assume that all persisted | ||
* queries are already known to the API. | ||
* | ||
* This is used to switch from Automatic Persisted Queries to | ||
* Persisted Queries. This is commonly used to obfuscate GraphQL | ||
* APIs. | ||
*/ | ||
enforcePersistedQueries?: boolean; | ||
generateHash?: (query: string, document: DocumentNode) => Promise<string>; | ||
/** Custom hashing function for persisted queries. | ||
* | ||
* @remarks | ||
* By default, `persistedExchange` will create a SHA-256 hash for | ||
* persisted queries automatically. If you're instead generating | ||
* hashes at compile-time, or need to use a custom SHA-256 function, | ||
* you may pass one here. | ||
* | ||
* Hint: The default SHA-256 function uses the WebCrypto API. This | ||
* API is unavailable on React Native, which may require you to | ||
* pass a custom function here. | ||
*/ | ||
generateHash?(query: string, document: DocumentNode): Promise<string>; | ||
/** Enables persisted queries to be used for mutations. | ||
* | ||
* @remarks | ||
* When enabled, the `persistedExchange` will also use the persisted queries | ||
* logic for mutation operations. | ||
* | ||
* This is disabled by default, but often used on APIs that obfuscate | ||
* their GraphQL APIs. | ||
*/ | ||
enableForMutation?: boolean; | ||
} | ||
/** Exchange factory that adds support for Persisted Queries. | ||
* | ||
* @param options - A {@link PersistedExchangeOptions} configuration object. | ||
* @returns the created persisted queries {@link Exchange}. | ||
* | ||
* @remarks | ||
* The `persistedExchange` adds support for (Automatic) Persisted Queries | ||
* to any `fetchExchange`, `subscriptionExchange`, or other API exchanges | ||
* following it. | ||
* | ||
* It does so by adding the `persistedQuery` extensions field to GraphQL | ||
* requests and handles `PersistedQueryNotFound` and | ||
* `PersistedQueryNotSupported` errors. | ||
* | ||
* @example | ||
* ```ts | ||
* import { Client, cacheExchange, fetchExchange } from '@urql/core'; | ||
* import { persistedExchange } from '@urql/exchange-persisted'; | ||
* | ||
* const client = new Client({ | ||
* url: 'URL', | ||
* exchanges: [ | ||
* cacheExchange, | ||
* persistedExchange({ | ||
* preferGetForPersistedQueries: true, | ||
* }), | ||
* fetchExchange | ||
* ], | ||
* }); | ||
* ``` | ||
*/ | ||
declare const persistedExchange: (options?: PersistedExchangeOptions) => Exchange; | ||
export { PersistedExchangeOptions, persistedExchange }; |
@@ -39,2 +39,36 @@ Object.defineProperty(exports, '__esModule', { | ||
var isPersistedUnsupported = error => error.graphQLErrors.some(x => x.message === 'PersistedQueryNotSupported'); | ||
/** Input parameters for the {@link persistedExchange}. */ | ||
/** Exchange factory that adds support for Persisted Queries. | ||
* | ||
* @param options - A {@link PersistedExchangeOptions} configuration object. | ||
* @returns the created persisted queries {@link Exchange}. | ||
* | ||
* @remarks | ||
* The `persistedExchange` adds support for (Automatic) Persisted Queries | ||
* to any `fetchExchange`, `subscriptionExchange`, or other API exchanges | ||
* following it. | ||
* | ||
* It does so by adding the `persistedQuery` extensions field to GraphQL | ||
* requests and handles `PersistedQueryNotFound` and | ||
* `PersistedQueryNotSupported` errors. | ||
* | ||
* @example | ||
* ```ts | ||
* import { Client, cacheExchange, fetchExchange } from '@urql/core'; | ||
* import { persistedExchange } from '@urql/exchange-persisted'; | ||
* | ||
* const client = new Client({ | ||
* url: 'URL', | ||
* exchanges: [ | ||
* cacheExchange, | ||
* persistedExchange({ | ||
* preferGetForPersistedQueries: true, | ||
* }), | ||
* fetchExchange | ||
* ], | ||
* }); | ||
* ``` | ||
*/ | ||
var persistedExchange = options => ({ | ||
@@ -41,0 +75,0 @@ forward |
{ | ||
"name": "@urql/exchange-persisted", | ||
"version": "0.0.0-canary-20230317001715", | ||
"version": "0.0.0-canary-20230317070130", | ||
"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-20230317001715", | ||
"@urql/core": "0.0.0-canary-20230317070130", | ||
"wonka": "^6.0.0" | ||
@@ -49,3 +49,3 @@ }, | ||
"graphql": "^16.0.0", | ||
"@urql/core": "0.0.0-canary-20230317001715" | ||
"@urql/core": "0.0.0-canary-20230317070130" | ||
}, | ||
@@ -52,0 +52,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
81433
330
+ Added@urql/core@0.0.0-canary-20230317070130(transitive)
- Removed@urql/core@0.0.0-canary-20230317001715(transitive)