diff --git a/src/stitching/defaultMergedResolver.ts b/src/stitching/defaultMergedResolver.ts index cbf754a03a8..5e5ca3822ea 100644 --- a/src/stitching/defaultMergedResolver.ts +++ b/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'; @@ -20,7 +20,8 @@ const defaultMergedResolver: GraphQLFieldResolver = (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]; }