diff --git a/dev-test/githunt/types.urql.tsx b/dev-test/githunt/types.urql.tsx index 954f55b0a..1314f48ad 100644 --- a/dev-test/githunt/types.urql.tsx +++ b/dev-test/githunt/types.urql.tsx @@ -1,11 +1,11 @@ import { IntrospectionQuery } from 'graphql'; import gql from 'graphql-tag'; import * as Urql from 'urql'; -import { offlineExchange } from '@urql/exchange-graphcache'; import { OptimisticMutationResolver as GraphCacheOptimisticMutationResolver, Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, + offlineExchange, } from '@urql/exchange-graphcache'; export type Maybe = T | null; diff --git a/packages/plugins/typescript/urql-graphcache/src/index.ts b/packages/plugins/typescript/urql-graphcache/src/index.ts index f5ef5f1b0..59df668b4 100644 --- a/packages/plugins/typescript/urql-graphcache/src/index.ts +++ b/packages/plugins/typescript/urql-graphcache/src/index.ts @@ -276,12 +276,9 @@ function getOptimisticUpdatersConfig( } function getImports(config: UrqlGraphCacheConfig): string { - return [ - "import { offlineExchange } from '@urql/exchange-graphcache';", - `${ - config.useTypeImports ? 'import type' : 'import' - } { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver } from '@urql/exchange-graphcache';\n`, - ].join('\n'); + return `${ + config.useTypeImports ? 'import type' : 'import' + } { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver, offlineExchange } from '@urql/exchange-graphcache';\n`; } export const plugin: PluginFunction = ( diff --git a/packages/plugins/typescript/urql-graphcache/tests/__snapshots__/urql.spec.ts.snap b/packages/plugins/typescript/urql-graphcache/tests/__snapshots__/urql.spec.ts.snap index d5db0c0fa..64f258ef0 100644 --- a/packages/plugins/typescript/urql-graphcache/tests/__snapshots__/urql.spec.ts.snap +++ b/packages/plugins/typescript/urql-graphcache/tests/__snapshots__/urql.spec.ts.snap @@ -1,9 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`urql graphcache Should correctly name GraphCacheResolvers & GraphCacheOptimisticUpdaters with nonstandard mutationType names 1`] = ` -"import { offlineExchange } from '@urql/exchange-graphcache'; -import { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver } from '@urql/exchange-graphcache'; - +import { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver, offlineExchange } from '@urql/exchange-graphcache'; export type WithTypename = Partial & { __typename: NonNullable }; export type GraphCacheKeysConfig = { diff --git a/packages/plugins/typescript/urql-graphcache/tests/urql.spec.ts b/packages/plugins/typescript/urql-graphcache/tests/urql.spec.ts index 16632258b..5886391ac 100644 --- a/packages/plugins/typescript/urql-graphcache/tests/urql.spec.ts +++ b/packages/plugins/typescript/urql-graphcache/tests/urql.spec.ts @@ -166,8 +166,7 @@ describe('urql graphcache', () => { const result = mergeOutputs([await plugin(schema, [], { useTypeImports: true })]); expect(result).toBeSimilarStringTo(`\ -import { offlineExchange } from '@urql/exchange-graphcache'; -import type { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver } from '@urql/exchange-graphcache'; +import type { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver, offlineExchange } from '@urql/exchange-graphcache'; `); });