@graphql-tools/utils 10.2.2 → 10.2.3-alpha-20240701111359-9253c8dd99a17b5005fae00a79418ad4a44ca80b

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.
@@ -177,11 +177,39 @@ function visitFieldValue(value, returnType, fieldNodes, schema, fragments, varia
177
177
  }
178
178
  else if ((0, graphql_1.isAbstractType)(nullableType)) {
179
179
  const finalType = schema.getType(value.__typename);
180
- const { fields: collectedFields } = (0, collectFields_js_1.collectSubFields)(schema, fragments, variableValues, finalType, fieldNodes);
180
+ let { fields: collectedFields, patches } = (0, collectFields_js_1.collectSubFields)(schema, fragments, variableValues, finalType, fieldNodes);
181
+ if (patches.length) {
182
+ collectedFields = new Map(collectedFields);
183
+ for (const patch of patches) {
184
+ for (const [responseKey, fields] of patch.fields) {
185
+ const existingFields = collectedFields.get(responseKey);
186
+ if (existingFields) {
187
+ existingFields.push(...fields);
188
+ }
189
+ else {
190
+ collectedFields.set(responseKey, fields);
191
+ }
192
+ }
193
+ }
194
+ }
181
195
  return visitObjectValue(value, finalType, collectedFields, schema, fragments, variableValues, resultVisitorMap, pathIndex, errors, errorInfo);
182
196
  }
183
197
  else if ((0, graphql_1.isObjectType)(nullableType)) {
184
- const { fields: collectedFields } = (0, collectFields_js_1.collectSubFields)(schema, fragments, variableValues, nullableType, fieldNodes);
198
+ let { fields: collectedFields, patches } = (0, collectFields_js_1.collectSubFields)(schema, fragments, variableValues, nullableType, fieldNodes);
199
+ if (patches.length) {
200
+ collectedFields = new Map(collectedFields);
201
+ for (const patch of patches) {
202
+ for (const [responseKey, fields] of patch.fields) {
203
+ const existingFields = collectedFields.get(responseKey);
204
+ if (existingFields) {
205
+ existingFields.push(...fields);
206
+ }
207
+ else {
208
+ collectedFields.set(responseKey, fields);
209
+ }
210
+ }
211
+ }
212
+ }
185
213
  return visitObjectValue(value, nullableType, collectedFields, schema, fragments, variableValues, resultVisitorMap, pathIndex, errors, errorInfo);
186
214
  }
187
215
  const typeVisitorMap = resultVisitorMap?.[nullableType.name];
@@ -171,11 +171,39 @@ function visitFieldValue(value, returnType, fieldNodes, schema, fragments, varia
171
171
  }
172
172
  else if (isAbstractType(nullableType)) {
173
173
  const finalType = schema.getType(value.__typename);
174
- const { fields: collectedFields } = collectSubFields(schema, fragments, variableValues, finalType, fieldNodes);
174
+ let { fields: collectedFields, patches } = collectSubFields(schema, fragments, variableValues, finalType, fieldNodes);
175
+ if (patches.length) {
176
+ collectedFields = new Map(collectedFields);
177
+ for (const patch of patches) {
178
+ for (const [responseKey, fields] of patch.fields) {
179
+ const existingFields = collectedFields.get(responseKey);
180
+ if (existingFields) {
181
+ existingFields.push(...fields);
182
+ }
183
+ else {
184
+ collectedFields.set(responseKey, fields);
185
+ }
186
+ }
187
+ }
188
+ }
175
189
  return visitObjectValue(value, finalType, collectedFields, schema, fragments, variableValues, resultVisitorMap, pathIndex, errors, errorInfo);
176
190
  }
177
191
  else if (isObjectType(nullableType)) {
178
- const { fields: collectedFields } = collectSubFields(schema, fragments, variableValues, nullableType, fieldNodes);
192
+ let { fields: collectedFields, patches } = collectSubFields(schema, fragments, variableValues, nullableType, fieldNodes);
193
+ if (patches.length) {
194
+ collectedFields = new Map(collectedFields);
195
+ for (const patch of patches) {
196
+ for (const [responseKey, fields] of patch.fields) {
197
+ const existingFields = collectedFields.get(responseKey);
198
+ if (existingFields) {
199
+ existingFields.push(...fields);
200
+ }
201
+ else {
202
+ collectedFields.set(responseKey, fields);
203
+ }
204
+ }
205
+ }
206
+ }
179
207
  return visitObjectValue(value, nullableType, collectedFields, schema, fragments, variableValues, resultVisitorMap, pathIndex, errors, errorInfo);
180
208
  }
181
209
  const typeVisitorMap = resultVisitorMap?.[nullableType.name];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/utils",
3
- "version": "10.2.2",
3
+ "version": "10.2.3-alpha-20240701111359-9253c8dd99a17b5005fae00a79418ad4a44ca80b",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {