From 46291c7ad509049caeb32bcf37220b95c26f1a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20W=C3=B6lk?= Date: Fri, 9 Apr 2021 09:27:56 +0200 Subject: [PATCH] fix(graphql,federation,#1051): check for undefined as well --- examples/federation/graphql-gateway/src/app.module.ts | 1 + .../src/resolvers/relations/references-relation.resolver.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/federation/graphql-gateway/src/app.module.ts b/examples/federation/graphql-gateway/src/app.module.ts index bcdcaf514..7e1c55d2b 100644 --- a/examples/federation/graphql-gateway/src/app.module.ts +++ b/examples/federation/graphql-gateway/src/app.module.ts @@ -13,6 +13,7 @@ import { GraphQLGatewayModule } from '@nestjs/graphql'; { name: 'todo-items', url: 'http://localhost:3001/graphql' }, { name: 'sub-tasks', url: 'http://localhost:3002/graphql' }, { name: 'tags', url: 'http://localhost:3003/graphql' }, + { name: 'user', url: 'http://localhost:3004/graphql' }, ], }, }), diff --git a/packages/query-graphql/src/resolvers/relations/references-relation.resolver.ts b/packages/query-graphql/src/resolvers/relations/references-relation.resolver.ts index 0fa2add90..e69cc8fed 100644 --- a/packages/query-graphql/src/resolvers/relations/references-relation.resolver.ts +++ b/packages/query-graphql/src/resolvers/relations/references-relation.resolver.ts @@ -17,7 +17,10 @@ const pluckFields = (dto: DTO, fieldMap: ReferencesKeys(fields: Partial): boolean => { - return Object.entries(fields).reduce((previousNull, [, value]) => previousNull && value === null, true); + return Object.entries(fields).reduce( + (previousNull, [, value]) => previousNull && (value === null || value === undefined), + true, + ); }; const ReferencesMixin = (DTOClass: Class, reference: ResolverRelationReference) => <