···11+---
22+'@urql/exchange-persisted': major
33+---
44+55+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.
+4-4
docs/advanced/persistence-and-uploads.md
···6161});
6262```
63636464-As we can see, typically it's recommended to set `preferGetForPersistedQueries` to `true` to force
6565-all persisted queries to use GET requests instead of POST so that CDNs can do their job.
6666-It does so by setting the `preferGetMethod` option to `'force'` when it's
6767-updating operations.
6464+As we can see, typically it's recommended to set `preferGetForPersistedQueries` to `true`
6565+to encourage persisted queries to use GET requests instead of POST so that CDNs can do their job.
6666+When set to `true` or `'within-url-limit'`, persisted queries will use GET requests if the
6767+resulting URL doesn't exceed the 2048 character limit.
68686969The `fetchExchange` can see the modifications that the `persistedExchange` is
7070making to operations, and understands to leave out the `query` from any request
···1717 CombinedError,
1818 Exchange,
1919 Operation,
2020+ OperationContext,
2021} from '@urql/core';
21222223import { hash } from './sha256';
···29303031/** Input parameters for the {@link persistedExchange}. */
3132export interface PersistedExchangeOptions {
3232- /** Enforces GET method requests to be made for Persisted Queries.
3333+ /** Controls whether GET method requests will be made for Persisted Queries.
3334 *
3435 * @remarks
3535- * When enabled, the `persistedExchange` will set
3636+ * When set to `true` or `'within-url-limit'`, the `persistedExchange`
3737+ * will use GET requests on persisted queries when the request URL
3838+ * doesn't exceed the 2048 character limit.
3939+ *
4040+ * When set to `force`, the `persistedExchange` will set
3641 * `OperationContext.preferGetMethod` to `'force'` on persisted queries,
3742 * which will force requests to be made using a GET request.
3843 *
3939- * This is frequently used to make GraphQL requests more cacheable
4040- * on CDNs.
4444+ * GET requests are frequently used to make GraphQL requests more
4545+ * cacheable on CDNs.
4146 *
4242- * @defaultValue `true` - enabled
4747+ * @defaultValue `undefined` - disabled
4348 */
4444- preferGetForPersistedQueries?: boolean;
4949+ preferGetForPersistedQueries?: OperationContext['preferGetMethod'];
4550 /** Enforces non-automatic persisted queries by ignoring APQ errors.
4651 *
4752 * @remarks
···118123 ({ forward }) => {
119124 if (!options) options = {};
120125121121- const preferGetForPersistedQueries = !!options.preferGetForPersistedQueries;
126126+ const preferGetForPersistedQueries = options.preferGetForPersistedQueries;
122127 const enforcePersistedQueries = !!options.enforcePersistedQueries;
123128 const hashFn = options.generateHash || hash;
124129 const enableForMutation = !!options.enableForMutation;
···163168 persistedOperation.kind === 'query' &&
164169 preferGetForPersistedQueries
165170 ) {
166166- persistedOperation.context.preferGetMethod = 'force';
171171+ persistedOperation.context.preferGetMethod =
172172+ preferGetForPersistedQueries;
167173 }
168174 }
169175