@graphql-tools/utils
Advanced tools
Comparing version 10.2.2 to 10.2.3-alpha-20240701104621-6e67f50844f7f4cbd61964900403a66232ead248
@@ -180,7 +180,35 @@ "use strict"; | ||
const finalType = schema.getType(value.__typename); | ||
const { fields: collectedFields } = (0, collectFields_js_1.collectSubFields)(schema, fragments, variableValues, finalType, fieldNodes); | ||
let { fields: collectedFields, patches } = (0, collectFields_js_1.collectSubFields)(schema, fragments, variableValues, finalType, fieldNodes); | ||
if (patches.length) { | ||
collectedFields = new Map(collectedFields); | ||
for (const patch of patches) { | ||
for (const [responseKey, fields] of patch.fields) { | ||
const existingFields = collectedFields.get(responseKey); | ||
if (existingFields) { | ||
existingFields.push(...fields); | ||
} | ||
else { | ||
collectedFields.set(responseKey, fields); | ||
} | ||
} | ||
} | ||
} | ||
return visitObjectValue(value, finalType, collectedFields, schema, fragments, variableValues, resultVisitorMap, pathIndex, errors, errorInfo); | ||
} | ||
else if ((0, graphql_1.isObjectType)(nullableType)) { | ||
const { fields: collectedFields } = (0, collectFields_js_1.collectSubFields)(schema, fragments, variableValues, nullableType, fieldNodes); | ||
let { fields: collectedFields, patches } = (0, collectFields_js_1.collectSubFields)(schema, fragments, variableValues, nullableType, fieldNodes); | ||
if (patches.length) { | ||
collectedFields = new Map(collectedFields); | ||
for (const patch of patches) { | ||
for (const [responseKey, fields] of patch.fields) { | ||
const existingFields = collectedFields.get(responseKey); | ||
if (existingFields) { | ||
existingFields.push(...fields); | ||
} | ||
else { | ||
collectedFields.set(responseKey, fields); | ||
} | ||
} | ||
} | ||
} | ||
return visitObjectValue(value, nullableType, collectedFields, schema, fragments, variableValues, resultVisitorMap, pathIndex, errors, errorInfo); | ||
@@ -187,0 +215,0 @@ } |
@@ -174,7 +174,35 @@ import { getNullableType, isAbstractType, isListType, isObjectType, Kind, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, } from 'graphql'; | ||
const finalType = schema.getType(value.__typename); | ||
const { fields: collectedFields } = collectSubFields(schema, fragments, variableValues, finalType, fieldNodes); | ||
let { fields: collectedFields, patches } = collectSubFields(schema, fragments, variableValues, finalType, fieldNodes); | ||
if (patches.length) { | ||
collectedFields = new Map(collectedFields); | ||
for (const patch of patches) { | ||
for (const [responseKey, fields] of patch.fields) { | ||
const existingFields = collectedFields.get(responseKey); | ||
if (existingFields) { | ||
existingFields.push(...fields); | ||
} | ||
else { | ||
collectedFields.set(responseKey, fields); | ||
} | ||
} | ||
} | ||
} | ||
return visitObjectValue(value, finalType, collectedFields, schema, fragments, variableValues, resultVisitorMap, pathIndex, errors, errorInfo); | ||
} | ||
else if (isObjectType(nullableType)) { | ||
const { fields: collectedFields } = collectSubFields(schema, fragments, variableValues, nullableType, fieldNodes); | ||
let { fields: collectedFields, patches } = collectSubFields(schema, fragments, variableValues, nullableType, fieldNodes); | ||
if (patches.length) { | ||
collectedFields = new Map(collectedFields); | ||
for (const patch of patches) { | ||
for (const [responseKey, fields] of patch.fields) { | ||
const existingFields = collectedFields.get(responseKey); | ||
if (existingFields) { | ||
existingFields.push(...fields); | ||
} | ||
else { | ||
collectedFields.set(responseKey, fields); | ||
} | ||
} | ||
} | ||
} | ||
return visitObjectValue(value, nullableType, collectedFields, schema, fragments, variableValues, resultVisitorMap, pathIndex, errors, errorInfo); | ||
@@ -181,0 +209,0 @@ } |
{ | ||
"name": "@graphql-tools/utils", | ||
"version": "10.2.2", | ||
"version": "10.2.3-alpha-20240701104621-6e67f50844f7f4cbd61964900403a66232ead248", | ||
"description": "Common package containing utils and types for GraphQL tools", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
503582
10905
2