Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(addResolversToSchema): continue processing all types and fields i…
…n edge cases (#4355)

* don't break

* add changeset
  • Loading branch information
yaacovCR committed Mar 30, 2022
1 parent 95417ac commit 722abad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .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.
4 changes: 2 additions & 2 deletions packages/schema/src/addResolversToSchema.ts
Expand Up @@ -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`);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 722abad

Please sign in to comment.