Skip to content

Commit

Permalink
fix(delegate): do not forward non-nullability errors to the gateway (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan authored Dec 3, 2024
1 parent 1d6fa42 commit 9ce705c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/slow-cars-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/delegate': patch
---

Do not show internal non-nullability errors in the gateway
13 changes: 12 additions & 1 deletion packages/delegate/src/mergeFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,18 @@ export function handleResolverResult(
for (const [responseKey, fieldNodes] of fields) {
const combinedPath = [...path, responseKey];
if (resolverResult instanceof GraphQLError) {
nullResult[responseKey] = relocatedError(resolverResult, combinedPath);
if (
resolverResult.message.includes(
'Cannot return null for non-nullable field',
)
) {
nullResult[responseKey] = null;
} else {
nullResult[responseKey] = relocatedError(
resolverResult,
combinedPath,
);
}
} else if (resolverResult instanceof Error) {
nullResult[responseKey] = locatedError(
resolverResult,
Expand Down
2 changes: 1 addition & 1 deletion packages/stitch/tests/mergeFailures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ describe('merge failures', () => {
data: { thing: null },
errors: [
createGraphQLError(
'Cannot return null for non-nullable field Thing.id.',
'Cannot return null for non-nullable field Thing.description.',
),
],
};
Expand Down

0 comments on commit 9ce705c

Please sign in to comment.