Skip to content

Commit 722abad

Browse files
authoredMar 30, 2022
fix(addResolversToSchema): continue processing all types and fields in edge cases (#4355)
* don't break * add changeset
1 parent 95417ac commit 722abad

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
 

‎.changeset/dull-eyes-work.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@graphql-tools/schema': patch
3+
---
4+
5+
Fix `addResolversToSchema` bug where type or field processing would be aborted prematurely.
6+
7+
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.
8+
9+
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.

‎packages/schema/src/addResolversToSchema.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function addResolversToSchema(
7777

7878
if (type == null) {
7979
if (requireResolversToMatchSchema === 'ignore') {
80-
break;
80+
continue;
8181
}
8282

8383
throw new Error(`"${typeName}" defined in resolvers, but not in schema`);
@@ -235,7 +235,7 @@ function addResolversToExistingSchema(
235235
if (fieldName.startsWith('__')) {
236236
// this is for isTypeOf and resolveType and all the other stuff.
237237
type[fieldName.substring(2)] = resolverValue[fieldName];
238-
break;
238+
continue;
239239
}
240240

241241
const fields = type.getFields();

0 commit comments

Comments
 (0)
Please sign in to comment.