@graphql-codegen/typescript-urql-graphcache 2.4.3 → 2.4.4

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 CHANGED
@@ -49,7 +49,10 @@ function constructType(typeNode, schema, convertName, config, nullable = true, a
49
49
  ? `Maybe<Scalars['${type.name}']${allowString ? ' | string' : ''}>`
50
50
  : `Scalars['${type.name}']${allowString ? ' | string' : ''}`;
51
51
  }
52
- const tsTypeName = convertName(typeNode.name, { prefix: config.typesPrefix, suffix: config.typesSuffix });
52
+ const tsTypeName = convertName(typeNode.name, {
53
+ prefix: config.typesPrefix,
54
+ suffix: config.typesSuffix,
55
+ });
53
56
  if ((0, graphql_1.isUnionType)(type) || (0, graphql_1.isInputObjectType)(type) || (0, graphql_1.isObjectType)(type)) {
54
57
  const finalType = `WithTypename<${tsTypeName}>${allowString ? ' | string' : ''}`;
55
58
  return nullable ? `Maybe<${finalType}>` : finalType;
@@ -66,7 +69,9 @@ function constructType(typeNode, schema, convertName, config, nullable = true, a
66
69
  });
67
70
  return `WithTypename<${tsPossibleTypeName}>`;
68
71
  });
69
- const finalType = allowString ? possibleTypes.join(' | ') + ' | string' : possibleTypes.join(' | ');
72
+ const finalType = allowString
73
+ ? possibleTypes.join(' | ') + ' | string'
74
+ : possibleTypes.join(' | ');
70
75
  return nullable ? `Maybe<${finalType}>` : finalType;
71
76
  }
72
77
  throw new Error(`Unhandled type ${type}`);
@@ -107,7 +112,10 @@ function getResolversConfig(schema, convertName, config) {
107
112
  return resolvers;
108
113
  }
109
114
  function getRootUpdatersConfig(schema, convertName, config) {
110
- const [mutationUpdaters, subscriptionUpdaters] = [schema.getMutationType(), schema.getSubscriptionType()].map(rootType => {
115
+ const [mutationUpdaters, subscriptionUpdaters] = [
116
+ schema.getMutationType(),
117
+ schema.getSubscriptionType(),
118
+ ].map(rootType => {
111
119
  if (rootType) {
112
120
  const updaters = [];
113
121
  Object.values(rootType.getFields()).forEach(field => {
@@ -140,15 +148,16 @@ function getOptimisticUpdatersConfig(schema, convertName, config) {
140
148
  })
141
149
  : 'Record<string, never>';
142
150
  const outputType = constructType(field.type, schema, convertName, config);
143
- optimistic.push(`${field.name}?: GraphCacheOptimisticMutationResolver<` + `${argsName}, ` + `${outputType}>`);
151
+ optimistic.push(`${field.name}?: GraphCacheOptimisticMutationResolver<` +
152
+ `${argsName}, ` +
153
+ `${outputType}>`);
144
154
  });
145
155
  return optimistic;
146
156
  }
147
157
  return null;
148
158
  }
149
159
  function getImports(config) {
150
- return (`${config.useTypeImports ? 'import type' : 'import'} { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver, StorageAdapter as GraphCacheStorageAdapter } from '@urql/exchange-graphcache';\n` +
151
- `${config.useTypeImports ? 'import type' : 'import'} { IntrospectionData } from '@urql/exchange-graphcache/dist/types/ast';`);
160
+ return `${config.useTypeImports ? 'import type' : 'import'} { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver, StorageAdapter as GraphCacheStorageAdapter, CacheExchangeOpts } from '@urql/exchange-graphcache';\n`;
152
161
  }
153
162
  const plugin = (schema, _documents, config) => {
154
163
  const convertName = (0, visitor_plugin_common_1.convertFactory)(config);
@@ -173,7 +182,7 @@ const plugin = (schema, _documents, config) => {
173
182
  (subscriptionUpdaters ? `{\n ${subscriptionUpdaters.join(',\n ')}\n }` : '{}') +
174
183
  ',\n};',
175
184
  'export type GraphCacheConfig = {\n' +
176
- ' schema?: IntrospectionData,\n' +
185
+ " schema?: CacheExchangeOpts['schema'],\n" +
177
186
  ' updates?: GraphCacheUpdaters,\n' +
178
187
  ' keys?: GraphCacheKeysConfig,\n' +
179
188
  ' optimistic?: GraphCacheOptimisticUpdaters,\n' +
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isWrappingType, GraphQLObjectType, isListType, isNonNullType, isScalarType, isUnionType, isInputObjectType, isObjectType, isEnumType, isInterfaceType, } from 'graphql';
1
+ import { GraphQLObjectType, isEnumType, isInputObjectType, isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, isUnionType, isWrappingType, } from 'graphql';
2
2
  import { convertFactory } from '@graphql-codegen/visitor-plugin-common';
3
3
  const unwrapType = (type) => isWrappingType(type) ? unwrapType(type.ofType) : type || null;
4
4
  const getObjectTypes = (schema) => {
@@ -46,7 +46,10 @@ function constructType(typeNode, schema, convertName, config, nullable = true, a
46
46
  ? `Maybe<Scalars['${type.name}']${allowString ? ' | string' : ''}>`
47
47
  : `Scalars['${type.name}']${allowString ? ' | string' : ''}`;
48
48
  }
49
- const tsTypeName = convertName(typeNode.name, { prefix: config.typesPrefix, suffix: config.typesSuffix });
49
+ const tsTypeName = convertName(typeNode.name, {
50
+ prefix: config.typesPrefix,
51
+ suffix: config.typesSuffix,
52
+ });
50
53
  if (isUnionType(type) || isInputObjectType(type) || isObjectType(type)) {
51
54
  const finalType = `WithTypename<${tsTypeName}>${allowString ? ' | string' : ''}`;
52
55
  return nullable ? `Maybe<${finalType}>` : finalType;
@@ -63,7 +66,9 @@ function constructType(typeNode, schema, convertName, config, nullable = true, a
63
66
  });
64
67
  return `WithTypename<${tsPossibleTypeName}>`;
65
68
  });
66
- const finalType = allowString ? possibleTypes.join(' | ') + ' | string' : possibleTypes.join(' | ');
69
+ const finalType = allowString
70
+ ? possibleTypes.join(' | ') + ' | string'
71
+ : possibleTypes.join(' | ');
67
72
  return nullable ? `Maybe<${finalType}>` : finalType;
68
73
  }
69
74
  throw new Error(`Unhandled type ${type}`);
@@ -104,7 +109,10 @@ function getResolversConfig(schema, convertName, config) {
104
109
  return resolvers;
105
110
  }
106
111
  function getRootUpdatersConfig(schema, convertName, config) {
107
- const [mutationUpdaters, subscriptionUpdaters] = [schema.getMutationType(), schema.getSubscriptionType()].map(rootType => {
112
+ const [mutationUpdaters, subscriptionUpdaters] = [
113
+ schema.getMutationType(),
114
+ schema.getSubscriptionType(),
115
+ ].map(rootType => {
108
116
  if (rootType) {
109
117
  const updaters = [];
110
118
  Object.values(rootType.getFields()).forEach(field => {
@@ -137,15 +145,16 @@ function getOptimisticUpdatersConfig(schema, convertName, config) {
137
145
  })
138
146
  : 'Record<string, never>';
139
147
  const outputType = constructType(field.type, schema, convertName, config);
140
- optimistic.push(`${field.name}?: GraphCacheOptimisticMutationResolver<` + `${argsName}, ` + `${outputType}>`);
148
+ optimistic.push(`${field.name}?: GraphCacheOptimisticMutationResolver<` +
149
+ `${argsName}, ` +
150
+ `${outputType}>`);
141
151
  });
142
152
  return optimistic;
143
153
  }
144
154
  return null;
145
155
  }
146
156
  function getImports(config) {
147
- return (`${config.useTypeImports ? 'import type' : 'import'} { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver, StorageAdapter as GraphCacheStorageAdapter } from '@urql/exchange-graphcache';\n` +
148
- `${config.useTypeImports ? 'import type' : 'import'} { IntrospectionData } from '@urql/exchange-graphcache/dist/types/ast';`);
157
+ return `${config.useTypeImports ? 'import type' : 'import'} { Resolver as GraphCacheResolver, UpdateResolver as GraphCacheUpdateResolver, OptimisticMutationResolver as GraphCacheOptimisticMutationResolver, StorageAdapter as GraphCacheStorageAdapter, CacheExchangeOpts } from '@urql/exchange-graphcache';\n`;
149
158
  }
150
159
  export const plugin = (schema, _documents, config) => {
151
160
  const convertName = convertFactory(config);
@@ -170,7 +179,7 @@ export const plugin = (schema, _documents, config) => {
170
179
  (subscriptionUpdaters ? `{\n ${subscriptionUpdaters.join(',\n ')}\n }` : '{}') +
171
180
  ',\n};',
172
181
  'export type GraphCacheConfig = {\n' +
173
- ' schema?: IntrospectionData,\n' +
182
+ " schema?: CacheExchangeOpts['schema'],\n" +
174
183
  ' updates?: GraphCacheUpdaters,\n' +
175
184
  ' keys?: GraphCacheKeysConfig,\n' +
176
185
  ' optimistic?: GraphCacheOptimisticUpdaters,\n' +
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-urql-graphcache",
3
- "version": "2.4.3",
3
+ "version": "2.4.4",
4
4
  "description": "GraphQL Code Generator plugin for generating a generic to be used in graphcache cache config",
5
5
  "peerDependencies": {
6
+ "@urql/exchange-graphcache": "^4.1.1 || ^5.0.0",
6
7
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
7
- "graphql-tag": "^2.0.0",
8
- "@urql/exchange-graphcache": "^4.1.1 || ^5.0.0"
8
+ "graphql-tag": "^2.0.0"
9
9
  },
10
10
  "dependencies": {
11
- "@graphql-codegen/plugin-helpers": "^2.7.2",
11
+ "@graphql-codegen/plugin-helpers": "^3.0.0",
12
12
  "@graphql-codegen/visitor-plugin-common": "2.13.1",
13
13
  "auto-bind": "~4.0.0",
14
- "change-case-all": "1.0.14",
14
+ "change-case-all": "1.0.15",
15
15
  "tslib": "~2.4.0"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "https://github.com/dotansimha/graphql-code-generator.git",
19
+ "url": "https://github.com/dotansimha/graphql-code-generator-community.git",
20
20
  "directory": "packages/plugins/typescript/urql-graphcache"
21
21
  },
22
22
  "license": "MIT",
@@ -2,4 +2,4 @@ import { RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-c
2
2
  /**
3
3
  * @description This plugin generates a generic for the `@urql/exchange-graphcache` (https://github.com/FormidableLabs/urql/exchanges/graphcache) config.
4
4
  */
5
- export declare type UrqlGraphCacheConfig = RawClientSideBasePluginConfig & {};
5
+ export type UrqlGraphCacheConfig = RawClientSideBasePluginConfig & {};
@@ -2,4 +2,4 @@ import { RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-c
2
2
  /**
3
3
  * @description This plugin generates a generic for the `@urql/exchange-graphcache` (https://github.com/FormidableLabs/urql/exchanges/graphcache) config.
4
4
  */
5
- export declare type UrqlGraphCacheConfig = RawClientSideBasePluginConfig & {};
5
+ export type UrqlGraphCacheConfig = RawClientSideBasePluginConfig & {};