Skip to content

Commit

Permalink
fix(graphql,federation,#1051): check for undefined as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mwoelk authored and doug-martin committed Apr 13, 2021
1 parent 5186402 commit 298150a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/federation/graphql-gateway/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const pluckFields = <DTO, Relation>(dto: DTO, fieldMap: ReferencesKeys<DTO, Rela
};

const allFieldsAreNull = <Relation>(fields: Partial<Relation>): boolean => {
return Object.entries(fields).reduce<boolean>((previousNull, [, value]) => previousNull && value === null, true);
return Object.entries(fields).reduce<boolean>(
(previousNull, [, value]) => previousNull && (value === null || value === undefined),
true,
);
};

const ReferencesMixin = <DTO, Relation>(DTOClass: Class<DTO>, reference: ResolverRelationReference<DTO, Relation>) => <
Expand Down

0 comments on commit 298150a

Please sign in to comment.