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(graphcache): Use stringifyDocument in offlineExchange and support extensions (#3094)

authored by

Phil Pluckthun and committed by
GitHub
9f5c9e63 c417be20

+14 -5
+5
.changeset/giant-flies-exercise.md
··· 1 + --- 2 + '@urql/exchange-graphcache': patch 3 + --- 4 + 5 + Use `stringifyDocument` in `offlineExchange` rather than `print` and serialize `operation.extensions` as needed.
+6 -3
exchanges/graphcache/src/offlineExchange.ts
··· 1 1 import { pipe, merge, makeSubject, filter } from 'wonka'; 2 - import { print, SelectionNode } from 'graphql'; 2 + import { SelectionNode } from 'graphql'; 3 3 4 4 import { 5 5 Operation, ··· 7 7 Exchange, 8 8 ExchangeIO, 9 9 CombinedError, 10 + stringifyDocument, 10 11 createRequest, 11 12 makeOperation, 12 13 } from '@urql/core'; ··· 134 135 const operation = failedQueue[i]; 135 136 if (operation.kind === 'mutation') { 136 137 requests.push({ 137 - query: print(operation.query), 138 + query: stringifyDocument(operation.query), 138 139 variables: operation.variables, 140 + extensions: operation.extensions, 139 141 }); 140 142 } 141 143 } ··· 190 192 failedQueue.push( 191 193 client.createRequestOperation( 192 194 'mutation', 193 - createRequest(mutations[i].query, mutations[i].variables) 195 + createRequest(mutations[i].query, mutations[i].variables), 196 + mutations[i].extensions 194 197 ) 195 198 ); 196 199 }
+3 -2
exchanges/graphcache/src/types.ts
··· 1 - import { AnyVariables, TypedDocumentNode } from '@urql/core'; 1 + import { AnyVariables, TypedDocumentNode, RequestExtensions } from '@urql/core'; 2 2 import { GraphQLError, DocumentNode, FragmentDefinitionNode } from 'graphql'; 3 3 import { IntrospectionData } from './ast'; 4 4 ··· 888 888 /** A serialized GraphQL request for offline storage. */ 889 889 export interface SerializedRequest { 890 890 query: string; 891 - variables: AnyVariables; 891 + variables: AnyVariables | undefined; 892 + extensions?: RequestExtensions | undefined; 892 893 } 893 894 894 895 /** Interface for a storage adapter, used by the {@link offlineExchange} for Offline Support.