From c82df7b9f1502eff5acba2f7cd44f7b952c2d4bd Mon Sep 17 00:00:00 2001 From: Luis Aguilar Date: Mon, 17 Aug 2020 07:52:33 -0400 Subject: [PATCH] fix(FederatedSchemaPrinter): Skip printing Mutation type on empty (#12) * fix(FederatedSchemaPrinter): Skip printing Mutation type on empty * fix: Remove specificity Co-authored-by: Katy Ereira Co-authored-by: Katy Ereira --- src/Utils/FederatedSchemaPrinter.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Utils/FederatedSchemaPrinter.php b/src/Utils/FederatedSchemaPrinter.php index 8253d2c..7dbc8c9 100644 --- a/src/Utils/FederatedSchemaPrinter.php +++ b/src/Utils/FederatedSchemaPrinter.php @@ -320,6 +320,10 @@ private static function printScalar(ScalarType $type, array $options): string */ private static function printObject(ObjectType $type, array $options): string { + if (empty($type->getFields())) { + return ''; + } + $interfaces = $type->getInterfaces(); $implementedInterfaces = !empty($interfaces) ? ' implements ' . @@ -331,7 +335,7 @@ private static function printObject(ObjectType $type, array $options): string ) : ''; - $queryExtends = $type->name === 'Query' ? 'extend ' : ''; + $queryExtends = $type->name === 'Query' || $type->name === 'Mutation' ? 'extend ' : ''; return self::printDescription($options, $type) . sprintf(