Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: default merged resolver behavior for nullable fields #1172

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/stitching/defaultMergedResolver.ts
@@ -1,4 +1,4 @@
import { GraphQLFieldResolver, responsePathAsArray } from 'graphql';
import { GraphQLFieldResolver, GraphQLNonNull, responsePathAsArray } from 'graphql';
import { locatedError } from 'graphql/error';
import { getErrorsFromParent, annotateWithChildrenErrors } from './errors';
import { getResponseKeyFromInfo } from './getResponseKeyFromInfo';
Expand All @@ -20,7 +20,8 @@ const defaultMergedResolver: GraphQLFieldResolver<any, any> = (parent, args, con

let result = parent[responseKey];

if (result == null) {
// Only replace the aliased result with the parent result if the field is non-nullable
if (result == null && info.returnType instanceof GraphQLNonNull) {
result = parent[info.fieldName];
}

Expand Down