From c58e241e03ca82f359420e0b91907088e0259bca Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Wed, 11 Aug 2021 10:34:44 +1200 Subject: [PATCH] BUGFIX: Replace graceful failure of field access on dataobjects --- src/Scaffolding/Scaffolders/DataObjectScaffolder.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Scaffolding/Scaffolders/DataObjectScaffolder.php b/src/Scaffolding/Scaffolders/DataObjectScaffolder.php index 62a29872a..90ab65ffc 100644 --- a/src/Scaffolding/Scaffolders/DataObjectScaffolder.php +++ b/src/Scaffolding/Scaffolders/DataObjectScaffolder.php @@ -665,10 +665,13 @@ protected function createFields(Manager $manager) } $resolver = function ($obj, $args, $context, $info) { - /** - * @var DataObject $obj - */ - $field = StaticSchema::inst()->accessField($obj, $info->fieldName); + /* @var DataObject $obj */ + try { + $field = StaticSchema::inst()->accessField($obj, $info->fieldName); + } catch (InvalidArgumentException $e) { + // Gracefully fail when field doesn't exist + return null; + } // return the raw field value, or checks like `is_numeric()` fail if ($field instanceof DBField && $field->isInternalGraphQLType()) { return $field->getValue();