Skip to content

Commit

Permalink
MINOR: Remove exclude directive from mutation input types
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Carlino committed Feb 23, 2021
1 parent 4011f0d commit 290abb8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
26 changes: 8 additions & 18 deletions src/Schema/DataObject/FieldReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
}
}
2 changes: 0 additions & 2 deletions src/Schema/Type/ModelType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 290abb8

Please sign in to comment.