diff --git a/.changeset/dull-eyes-work.md b/.changeset/dull-eyes-work.md new file mode 100644 index 0000000000..a4ff051e28 --- /dev/null +++ b/.changeset/dull-eyes-work.md @@ -0,0 +1,9 @@ +--- +'@graphql-tools/schema': patch +--- + +Fix `addResolversToSchema` bug where type or field processing would be aborted prematurely. + +In previous versions, if `requireResolversToMatchSchema` was set to `ignore`, although no error would be thrown for an unexpected resolver type, type processing would still be aborted early. This fix changes the behavior to correctly continue resolver type processing with the next provided type. + +In previous versions, if a resolver field began with double underscores, it would correctly be used for legacy behavior to directly set a type property, but field processing would be aborted early. This fix changes the behavior to correctly continue type processing with the next field. diff --git a/packages/schema/src/addResolversToSchema.ts b/packages/schema/src/addResolversToSchema.ts index 64ce23f082..d1b73ee394 100644 --- a/packages/schema/src/addResolversToSchema.ts +++ b/packages/schema/src/addResolversToSchema.ts @@ -77,7 +77,7 @@ export function addResolversToSchema( if (type == null) { if (requireResolversToMatchSchema === 'ignore') { - break; + continue; } throw new Error(`"${typeName}" defined in resolvers, but not in schema`); @@ -235,7 +235,7 @@ function addResolversToExistingSchema( if (fieldName.startsWith('__')) { // this is for isTypeOf and resolveType and all the other stuff. type[fieldName.substring(2)] = resolverValue[fieldName]; - break; + continue; } const fields = type.getFields();