Skip to content

Commit

Permalink
BUGFIX: Replace graceful failure of field access on dataobjects
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Carlino committed Aug 10, 2021
1 parent 877eb23 commit c58e241
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Scaffolding/Scaffolders/DataObjectScaffolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c58e241

Please sign in to comment.