From 290abb804f9ab62ff91a855b40f4b2317124856b Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Wed, 24 Feb 2021 00:07:48 +1300 Subject: [PATCH] MINOR: Remove exclude directive from mutation input types --- src/Schema/DataObject/FieldReconciler.php | 26 +++++++---------------- src/Schema/Type/ModelType.php | 2 -- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/Schema/DataObject/FieldReconciler.php b/src/Schema/DataObject/FieldReconciler.php index 04933ac75..6c380e519 100644 --- a/src/Schema/DataObject/FieldReconciler.php +++ b/src/Schema/DataObject/FieldReconciler.php @@ -6,7 +6,6 @@ use SilverStripe\GraphQL\Schema\Exception\SchemaBuilderException; use SilverStripe\GraphQL\Schema\Schema; use SilverStripe\GraphQL\Schema\Type\ModelType; -use SilverStripe\ORM\DataObject; trait FieldReconciler { @@ -26,28 +25,19 @@ private function reconcileFields( Schema::assertValidConfig($configFields); foreach ($configFields as $fieldName => $bool) { if ($bool === false) { - continue; + $fields = array_filter($fields, function ($field) use ($fieldName) { + return $field !== $fieldName; + }); + } elseif ($fieldName === Schema::ALL) { + $fields = array_merge($fields, array_keys($modelType->getFields())); + } else { + $fields[] = $fieldName; } - $fields[] = $fieldName; } } else { $fields = array_keys($modelType->getFields()); } - $configExclude = $config['exclude'] ?? null; - $excluded = []; - if ($configExclude) { - Schema::assertValidConfig($configExclude); - foreach ($configExclude as $fieldName => $bool) { - if ($bool === false) { - continue; - } - $excluded[] = $fieldName; - } - $includedFields = array_diff($fields, $excluded); - } else { - $includedFields = $fields; - } - return $includedFields; + return $fields; } } diff --git a/src/Schema/Type/ModelType.php b/src/Schema/Type/ModelType.php index f951842f8..6b0302115 100644 --- a/src/Schema/Type/ModelType.php +++ b/src/Schema/Type/ModelType.php @@ -3,8 +3,6 @@ namespace SilverStripe\GraphQL\Schema\Type; -use SilverStripe\Core\Injector\Injector; -use SilverStripe\GraphQL\Dev\Build; use SilverStripe\GraphQL\Schema\Exception\SchemaBuilderException; use SilverStripe\GraphQL\Schema\Field\Field; use SilverStripe\GraphQL\Schema\Field\ModelAware;