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(core): Always exclude teardowns from subscriptionExchange (#3206)

authored by

Phil Pluckthun and committed by
GitHub
351d3efd 67c991ff

+20 -9
+5
.changeset/green-geese-switch.md
··· 1 + --- 2 + '@urql/core': patch 3 + --- 4 + 5 + Don't allow `isSubscriptionOperation` option in `subscriptionExchange` to include `teardown` operations, to avoid confusion.
+15 -9
packages/core/src/exchanges/subscription.ts
··· 186 186 }; 187 187 }); 188 188 }; 189 + 189 190 const isSubscriptionOperationFn = 190 191 isSubscriptionOperation || 191 - (operation => { 192 - const { kind } = operation; 193 - return ( 194 - kind === 'subscription' || 195 - (!!enableAllOperations && (kind === 'query' || kind === 'mutation')) 196 - ); 197 - }); 192 + (operation => 193 + operation.kind === 'subscription' || 194 + (!!enableAllOperations && 195 + (operation.kind === 'query' || operation.kind === 'mutation'))); 198 196 199 197 return ops$ => { 200 198 const subscriptionResults$ = pipe( 201 199 ops$, 202 - filter(isSubscriptionOperationFn), 200 + filter( 201 + operation => 202 + operation.kind !== 'teardown' && 203 + isSubscriptionOperationFn(operation) 204 + ), 203 205 mergeMap(operation => { 204 206 const { key } = operation; 205 207 const teardown$ = pipe( ··· 216 218 217 219 const forward$ = pipe( 218 220 ops$, 219 - filter(op => !isSubscriptionOperationFn(op)), 221 + filter( 222 + operation => 223 + operation.kind === 'teardown' || 224 + !isSubscriptionOperationFn(operation) 225 + ), 220 226 forward 221 227 ); 222 228