Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: use nullish coalescing for get method preference (#3812)

authored by

Jonas Thelemann and committed by
GitHub
cddc86dd 1457b74c

+13 -7
+6
.changeset/twenty-cows-roll.md
··· 1 + --- 2 + '@urql/exchange-persisted': patch 3 + '@urql/core': patch 4 + --- 5 + 6 + Use nullish coalescing for `preferGetMethod` and `preferGetForPersistedQueries` so that `false` is kept if set.
+1 -1
exchanges/persisted/src/persistedExchange.test.ts
··· 174 174 expect(operations[0]).not.toHaveProperty('extensions.persistedQuery'); 175 175 }); 176 176 177 - it.each([true, 'force', 'within-url-limit'] as const)( 177 + it.each([true, false, 'force', 'within-url-limit'] as const)( 178 178 'sets `context.preferGetMethod` to %s when `options.preferGetForPersistedQueries` is %s', 179 179 async preferGetMethodValue => { 180 180 const { exchangeArgs } = makeExchangeArgs();
+4 -5
exchanges/persisted/src/persistedExchange.ts
··· 138 138 if (!options) options = {}; 139 139 140 140 const preferGetForPersistedQueries = 141 - options.preferGetForPersistedQueries || 'within-url-limit'; 141 + options.preferGetForPersistedQueries != null 142 + ? options.preferGetForPersistedQueries 143 + : 'within-url-limit'; 142 144 const enforcePersistedQueries = !!options.enforcePersistedQueries; 143 145 const hashFn = options.generateHash || hash; 144 146 const enableForMutation = !!options.enableForMutation; ··· 170 172 sha256Hash, 171 173 }, 172 174 }; 173 - if ( 174 - persistedOperation.kind === 'query' && 175 - preferGetForPersistedQueries 176 - ) { 175 + if (persistedOperation.kind === 'query') { 177 176 persistedOperation.context.preferGetMethod = 178 177 preferGetForPersistedQueries; 179 178 }
+2 -1
packages/core/src/client.ts
··· 549 549 fetchSubscriptions: opts.fetchSubscriptions, 550 550 fetchOptions: opts.fetchOptions, 551 551 fetch: opts.fetch, 552 - preferGetMethod: opts.preferGetMethod || 'within-url-limit', 552 + preferGetMethod: 553 + opts.preferGetMethod != null ? opts.preferGetMethod : 'within-url-limit', 553 554 requestPolicy: opts.requestPolicy || 'cache-first', 554 555 }; 555 556