@graphql-codegen/typescript-urql-graphcache 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +6 -9
- package/esm/index.js +6 -9
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -174,10 +174,7 @@ function getOptimisticUpdatersConfig(schema, convertName, config) {
|
|
|
174
174
|
return null;
|
|
175
175
|
}
|
|
176
176
|
function getImports(config) {
|
|
177
|
-
return
|
|
178
|
-
`import { ${config.offlineExchange ? 'offlineExchange' : 'cacheExchange'} } from '@urql/exchange-graphcache';`,
|
|
179
|
-
`${config.useTypeImports ? 'import type' : 'import'} { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver } from '@urql/exchange-graphcache';\n`,
|
|
180
|
-
].join('\n');
|
|
177
|
+
return `${config.useTypeImports ? 'import type' : 'import'} { ${config.offlineExchange ? 'offlineExchange' : 'cacheExchange'}, Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver } from '@urql/exchange-graphcache';\n`;
|
|
181
178
|
}
|
|
182
179
|
const plugin = (schema, _documents, config) => {
|
|
183
180
|
const convertName = (0, visitor_plugin_common_1.convertFactory)(config);
|
|
@@ -192,20 +189,20 @@ const plugin = (schema, _documents, config) => {
|
|
|
192
189
|
return {
|
|
193
190
|
prepend: [imports],
|
|
194
191
|
content: [
|
|
195
|
-
`export type WithTypename<T extends { __typename?: any }> = Partial<T> & { __typename: NonNullable<T['__typename']> };`,
|
|
192
|
+
`export type WithTypename<T extends { __typename?: ${config.defaultScalarType || 'any'} }> = Partial<T> & { __typename: NonNullable<T['__typename']> };`,
|
|
196
193
|
keys,
|
|
197
194
|
'export type GraphCacheResolvers = {\n' + resolvers.join(',\n') + '\n};',
|
|
198
195
|
'export type GraphCacheOptimisticUpdaters = ' +
|
|
199
|
-
(optimisticUpdaters ? '{\n ' + optimisticUpdaters.join(',\n ') + '\n};' : '
|
|
196
|
+
(optimisticUpdaters ? '{\n ' + optimisticUpdaters.join(',\n ') + '\n};' : 'object;'),
|
|
200
197
|
'export type GraphCacheUpdaters = {\n' +
|
|
201
198
|
` ${(queryType && queryType.name) || 'Mutation'}?: ` +
|
|
202
|
-
(queryUpdaters ? `{\n ${queryUpdaters.join(',\n ')}\n }` : '
|
|
199
|
+
(queryUpdaters ? `{\n ${queryUpdaters.join(',\n ')}\n }` : 'object') +
|
|
203
200
|
',\n' +
|
|
204
201
|
` ${(mutationType && mutationType.name) || 'Mutation'}?: ` +
|
|
205
|
-
(mutationUpdaters ? `{\n ${mutationUpdaters.join(',\n ')}\n }` : '
|
|
202
|
+
(mutationUpdaters ? `{\n ${mutationUpdaters.join(',\n ')}\n }` : 'object') +
|
|
206
203
|
',\n' +
|
|
207
204
|
` ${(subscriptionType && subscriptionType.name) || 'Subscription'}?: ` +
|
|
208
|
-
(subscriptionUpdaters ? `{\n ${subscriptionUpdaters.join(',\n ')}\n }` : '
|
|
205
|
+
(subscriptionUpdaters ? `{\n ${subscriptionUpdaters.join(',\n ')}\n }` : 'object') +
|
|
209
206
|
',\n' +
|
|
210
207
|
`${typeUpdateResolvers.join(',\n')}` +
|
|
211
208
|
',\n};',
|
package/esm/index.js
CHANGED
|
@@ -171,10 +171,7 @@ function getOptimisticUpdatersConfig(schema, convertName, config) {
|
|
|
171
171
|
return null;
|
|
172
172
|
}
|
|
173
173
|
function getImports(config) {
|
|
174
|
-
return
|
|
175
|
-
`import { ${config.offlineExchange ? 'offlineExchange' : 'cacheExchange'} } from '@urql/exchange-graphcache';`,
|
|
176
|
-
`${config.useTypeImports ? 'import type' : 'import'} { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver } from '@urql/exchange-graphcache';\n`,
|
|
177
|
-
].join('\n');
|
|
174
|
+
return `${config.useTypeImports ? 'import type' : 'import'} { ${config.offlineExchange ? 'offlineExchange' : 'cacheExchange'}, Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver } from '@urql/exchange-graphcache';\n`;
|
|
178
175
|
}
|
|
179
176
|
export const plugin = (schema, _documents, config) => {
|
|
180
177
|
const convertName = convertFactory(config);
|
|
@@ -189,20 +186,20 @@ export const plugin = (schema, _documents, config) => {
|
|
|
189
186
|
return {
|
|
190
187
|
prepend: [imports],
|
|
191
188
|
content: [
|
|
192
|
-
`export type WithTypename<T extends { __typename?: any }> = Partial<T> & { __typename: NonNullable<T['__typename']> };`,
|
|
189
|
+
`export type WithTypename<T extends { __typename?: ${config.defaultScalarType || 'any'} }> = Partial<T> & { __typename: NonNullable<T['__typename']> };`,
|
|
193
190
|
keys,
|
|
194
191
|
'export type GraphCacheResolvers = {\n' + resolvers.join(',\n') + '\n};',
|
|
195
192
|
'export type GraphCacheOptimisticUpdaters = ' +
|
|
196
|
-
(optimisticUpdaters ? '{\n ' + optimisticUpdaters.join(',\n ') + '\n};' : '
|
|
193
|
+
(optimisticUpdaters ? '{\n ' + optimisticUpdaters.join(',\n ') + '\n};' : 'object;'),
|
|
197
194
|
'export type GraphCacheUpdaters = {\n' +
|
|
198
195
|
` ${(queryType && queryType.name) || 'Mutation'}?: ` +
|
|
199
|
-
(queryUpdaters ? `{\n ${queryUpdaters.join(',\n ')}\n }` : '
|
|
196
|
+
(queryUpdaters ? `{\n ${queryUpdaters.join(',\n ')}\n }` : 'object') +
|
|
200
197
|
',\n' +
|
|
201
198
|
` ${(mutationType && mutationType.name) || 'Mutation'}?: ` +
|
|
202
|
-
(mutationUpdaters ? `{\n ${mutationUpdaters.join(',\n ')}\n }` : '
|
|
199
|
+
(mutationUpdaters ? `{\n ${mutationUpdaters.join(',\n ')}\n }` : 'object') +
|
|
203
200
|
',\n' +
|
|
204
201
|
` ${(subscriptionType && subscriptionType.name) || 'Subscription'}?: ` +
|
|
205
|
-
(subscriptionUpdaters ? `{\n ${subscriptionUpdaters.join(',\n ')}\n }` : '
|
|
202
|
+
(subscriptionUpdaters ? `{\n ${subscriptionUpdaters.join(',\n ')}\n }` : 'object') +
|
|
206
203
|
',\n' +
|
|
207
204
|
`${typeUpdateResolvers.join(',\n')}` +
|
|
208
205
|
',\n};',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-urql-graphcache",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating a generic to be used in graphcache cache config",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@urql/exchange-graphcache": "^5.2.0 || ^6.0.0 || ^7.0.0",
|