@graphql-codegen/visitor-plugin-common 3.0.2-rc-20230306161408-e2cafbb63 → 3.0.2-rc-20230306165103-4a4ac35a8

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.
@@ -125,7 +125,6 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
125
125
  if (typeName.startsWith('__') || (shouldInclude && !shouldInclude(schemaType))) {
126
126
  return prev;
127
127
  }
128
- let shouldApplyOmit = false;
129
128
  const isRootType = this._rootTypeNames.has(typeName);
130
129
  const isMapped = this.config.mappers[typeName];
131
130
  const isScalar = this.config.scalars[typeName];
@@ -134,7 +133,7 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
134
133
  prev[typeName] = applyWrapper(this.config.rootValueType.type);
135
134
  return prev;
136
135
  }
137
- if (isMapped && this.config.mappers[typeName].type) {
136
+ if (isMapped && this.config.mappers[typeName].type && !hasPlaceholder(this.config.mappers[typeName].type)) {
138
137
  this.markMapperAsUsed(typeName);
139
138
  prev[typeName] = applyWrapper(this.config.mappers[typeName].type);
140
139
  }
@@ -173,27 +172,27 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
173
172
  prev[typeName] = this.convertName(typeName, { useTypesPrefix: this.config.enumPrefix }, true);
174
173
  }
175
174
  else {
176
- shouldApplyOmit = true;
177
175
  prev[typeName] = this.convertName(typeName, {}, true);
178
- }
179
- if (shouldApplyOmit && prev[typeName] !== 'any' && (0, graphql_1.isObjectType)(schemaType)) {
180
- const relevantFields = this.getRelevantFieldsToOmit({
181
- schemaType,
182
- getTypeToUse,
183
- shouldInclude,
184
- });
185
- if (relevantFields.length > 0) {
186
- // Puts ResolverTypeWrapper on top of an entire type
187
- prev[typeName] = applyWrapper(this.replaceFieldsInType(prev[typeName], relevantFields));
188
- }
189
- else {
190
- // We still want to use ResolverTypeWrapper, even if we don't touch any fields
191
- prev[typeName] = applyWrapper(prev[typeName]);
176
+ if (prev[typeName] !== 'any' && (0, graphql_1.isObjectType)(schemaType)) {
177
+ const relevantFields = this.getRelevantFieldsToOmit({
178
+ schemaType,
179
+ getTypeToUse,
180
+ shouldInclude,
181
+ });
182
+ // If relevantFields, puts ResolverTypeWrapper on top of an entire type
183
+ let internalType = relevantFields.length > 0 ? this.replaceFieldsInType(prev[typeName], relevantFields) : prev[typeName];
184
+ if (isMapped) {
185
+ // replace the placeholder with the actual type
186
+ if (hasPlaceholder(internalType)) {
187
+ internalType = replacePlaceholder(internalType, typeName);
188
+ }
189
+ if (this.config.mappers[typeName].type && hasPlaceholder(this.config.mappers[typeName].type)) {
190
+ internalType = replacePlaceholder(this.config.mappers[typeName].type, internalType);
191
+ }
192
+ }
193
+ prev[typeName] = applyWrapper(internalType);
192
194
  }
193
195
  }
194
- if (isMapped && hasPlaceholder(prev[typeName])) {
195
- prev[typeName] = replacePlaceholder(prev[typeName], typeName);
196
- }
197
196
  if (!isMapped && hasDefaultMapper && hasPlaceholder(this.config.defaultMapper.type)) {
198
197
  const originalTypeName = isScalar ? this._getScalar(typeName) : prev[typeName];
199
198
  if ((0, graphql_1.isUnionType)(schemaType)) {
@@ -121,7 +121,6 @@ export class BaseResolversVisitor extends BaseVisitor {
121
121
  if (typeName.startsWith('__') || (shouldInclude && !shouldInclude(schemaType))) {
122
122
  return prev;
123
123
  }
124
- let shouldApplyOmit = false;
125
124
  const isRootType = this._rootTypeNames.has(typeName);
126
125
  const isMapped = this.config.mappers[typeName];
127
126
  const isScalar = this.config.scalars[typeName];
@@ -130,7 +129,7 @@ export class BaseResolversVisitor extends BaseVisitor {
130
129
  prev[typeName] = applyWrapper(this.config.rootValueType.type);
131
130
  return prev;
132
131
  }
133
- if (isMapped && this.config.mappers[typeName].type) {
132
+ if (isMapped && this.config.mappers[typeName].type && !hasPlaceholder(this.config.mappers[typeName].type)) {
134
133
  this.markMapperAsUsed(typeName);
135
134
  prev[typeName] = applyWrapper(this.config.mappers[typeName].type);
136
135
  }
@@ -169,27 +168,27 @@ export class BaseResolversVisitor extends BaseVisitor {
169
168
  prev[typeName] = this.convertName(typeName, { useTypesPrefix: this.config.enumPrefix }, true);
170
169
  }
171
170
  else {
172
- shouldApplyOmit = true;
173
171
  prev[typeName] = this.convertName(typeName, {}, true);
174
- }
175
- if (shouldApplyOmit && prev[typeName] !== 'any' && isObjectType(schemaType)) {
176
- const relevantFields = this.getRelevantFieldsToOmit({
177
- schemaType,
178
- getTypeToUse,
179
- shouldInclude,
180
- });
181
- if (relevantFields.length > 0) {
182
- // Puts ResolverTypeWrapper on top of an entire type
183
- prev[typeName] = applyWrapper(this.replaceFieldsInType(prev[typeName], relevantFields));
184
- }
185
- else {
186
- // We still want to use ResolverTypeWrapper, even if we don't touch any fields
187
- prev[typeName] = applyWrapper(prev[typeName]);
172
+ if (prev[typeName] !== 'any' && isObjectType(schemaType)) {
173
+ const relevantFields = this.getRelevantFieldsToOmit({
174
+ schemaType,
175
+ getTypeToUse,
176
+ shouldInclude,
177
+ });
178
+ // If relevantFields, puts ResolverTypeWrapper on top of an entire type
179
+ let internalType = relevantFields.length > 0 ? this.replaceFieldsInType(prev[typeName], relevantFields) : prev[typeName];
180
+ if (isMapped) {
181
+ // replace the placeholder with the actual type
182
+ if (hasPlaceholder(internalType)) {
183
+ internalType = replacePlaceholder(internalType, typeName);
184
+ }
185
+ if (this.config.mappers[typeName].type && hasPlaceholder(this.config.mappers[typeName].type)) {
186
+ internalType = replacePlaceholder(this.config.mappers[typeName].type, internalType);
187
+ }
188
+ }
189
+ prev[typeName] = applyWrapper(internalType);
188
190
  }
189
191
  }
190
- if (isMapped && hasPlaceholder(prev[typeName])) {
191
- prev[typeName] = replacePlaceholder(prev[typeName], typeName);
192
- }
193
192
  if (!isMapped && hasDefaultMapper && hasPlaceholder(this.config.defaultMapper.type)) {
194
193
  const originalTypeName = isScalar ? this._getScalar(typeName) : prev[typeName];
195
194
  if (isUnionType(schemaType)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/visitor-plugin-common",
3
- "version": "3.0.2-rc-20230306161408-e2cafbb63",
3
+ "version": "3.0.2-rc-20230306165103-4a4ac35a8",
4
4
  "peerDependencies": {
5
5
  "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"
6
6
  },