1
0
Fork 0
mirror of synced 2024-07-04 14:10:33 +12:00

Remove prefixed items from additional data

This commit is contained in:
Jake Barnby 2022-12-08 16:10:49 +13:00
parent fd52cdc45f
commit ddbd03388e
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C

View file

@ -149,7 +149,15 @@ class Mapper
$fields['data'] = [
'type' => Type::string(),
'description' => 'Additional data',
'resolve' => static fn($object, $args, $context, $info) => \json_encode($object, JSON_FORCE_OBJECT),
'resolve' => static function ($object, $args, $context, $info) {
$data = \array_filter(
$object,
fn($key) => !\str_starts_with($key, '_'),
ARRAY_FILTER_USE_KEY
);
return \json_encode($data, JSON_FORCE_OBJECT);
}
];
}