@@ -276,14 +276,9 @@ function getOptimisticUpdatersConfig(
276276}
277277
278278function getImports ( config : UrqlGraphCacheConfig ) : string {
279- return [
280- `import { ${
281- config . offlineExchange ? 'offlineExchange' : 'cacheExchange'
282- } } from '@urql/exchange-graphcache';`,
283- `${
284- config . useTypeImports ? 'import type' : 'import'
285- } { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver } from '@urql/exchange-graphcache';\n`,
286- ] . join ( '\n' ) ;
279+ return `${ config . useTypeImports ? 'import type' : 'import' } { ${
280+ config . offlineExchange ? 'offlineExchange' : 'cacheExchange'
281+ } , Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver } from '@urql/exchange-graphcache';\n`;
287282}
288283
289284export const plugin : PluginFunction < UrqlGraphCacheConfig , Types . ComplexPluginOutput > = (
@@ -305,24 +300,24 @@ export const plugin: PluginFunction<UrqlGraphCacheConfig, Types.ComplexPluginOut
305300 return {
306301 prepend : [ imports ] ,
307302 content : [
308- `export type WithTypename<T extends { __typename?: any }> = Partial<T> & { __typename: NonNullable<T['__typename']> };` ,
303+ `export type WithTypename<T extends { __typename?: ${ config . defaultScalarType || ' any' } }> = Partial<T> & { __typename: NonNullable<T['__typename']> };` ,
309304
310305 keys ,
311306
312307 'export type GraphCacheResolvers = {\n' + resolvers . join ( ',\n' ) + '\n};' ,
313308
314309 'export type GraphCacheOptimisticUpdaters = ' +
315- ( optimisticUpdaters ? '{\n ' + optimisticUpdaters . join ( ',\n ' ) + '\n};' : '{} ;' ) ,
310+ ( optimisticUpdaters ? '{\n ' + optimisticUpdaters . join ( ',\n ' ) + '\n};' : 'object ;' ) ,
316311
317312 'export type GraphCacheUpdaters = {\n' +
318313 ` ${ ( queryType && queryType . name ) || 'Mutation' } ?: ` +
319- ( queryUpdaters ? `{\n ${ queryUpdaters . join ( ',\n ' ) } \n }` : '{} ' ) +
314+ ( queryUpdaters ? `{\n ${ queryUpdaters . join ( ',\n ' ) } \n }` : 'object ' ) +
320315 ',\n' +
321316 ` ${ ( mutationType && mutationType . name ) || 'Mutation' } ?: ` +
322- ( mutationUpdaters ? `{\n ${ mutationUpdaters . join ( ',\n ' ) } \n }` : '{} ' ) +
317+ ( mutationUpdaters ? `{\n ${ mutationUpdaters . join ( ',\n ' ) } \n }` : 'object ' ) +
323318 ',\n' +
324319 ` ${ ( subscriptionType && subscriptionType . name ) || 'Subscription' } ?: ` +
325- ( subscriptionUpdaters ? `{\n ${ subscriptionUpdaters . join ( ',\n ' ) } \n }` : '{} ' ) +
320+ ( subscriptionUpdaters ? `{\n ${ subscriptionUpdaters . join ( ',\n ' ) } \n }` : 'object ' ) +
326321 ',\n' +
327322 `${ typeUpdateResolvers . join ( ',\n' ) } ` +
328323 ',\n};' ,
0 commit comments