From 90570dc0e24c3fddd2f5a6b3386794566293ff0d Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Wed, 11 Aug 2021 12:26:21 +1200 Subject: [PATCH] BUGFIX: Replace graceful failure of field access on dataobjects (#399) * BUGFIX: Replace graceful failure of field access on dataobjects * Revise per steve feedback --- src/Scaffolding/Scaffolders/DataObjectScaffolder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Scaffolding/Scaffolders/DataObjectScaffolder.php b/src/Scaffolding/Scaffolders/DataObjectScaffolder.php index 62a29872a..f4b9cd0ce 100644 --- a/src/Scaffolding/Scaffolders/DataObjectScaffolder.php +++ b/src/Scaffolding/Scaffolders/DataObjectScaffolder.php @@ -665,9 +665,10 @@ protected function createFields(Manager $manager) } $resolver = function ($obj, $args, $context, $info) { - /** - * @var DataObject $obj - */ + $accessor = StaticSchema::inst()->getFieldAccessor(); + if (!$accessor || !$accessor->getObjectFieldName($obj, $info->fieldName)) { + return null; + } $field = StaticSchema::inst()->accessField($obj, $info->fieldName); // return the raw field value, or checks like `is_numeric()` fail if ($field instanceof DBField && $field->isInternalGraphQLType()) {