Open
Description
The code snippet that shows how $builder->compose
can be used to load the currentUser
is broken. The current_user
data producer produces an AccountInterface
instance, but the entity_load
id
field requires a string or an int.
The current incorrect snippet is the following part.
$builder->compose(
$builder->produce('current_user'),
$builder->produce('entity_load')
->map('type', $builder->fromValue('user'))
->map('id', $builder->fromParent())
);
For a query
query {
currentUser { uuid }
}
It causes the following output
{
"data": {
"currentUser": null
},
"extensions": [
{
"message": "Object of class Drupal\\Core\\Session\\UserSession could not be converted to string",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"currentUser"
]
}
]
}