drupal-graphql / drupal-graphql/graphql
Composing data producer example is broken
- Dominant language
- PHP
- Stars
- 287
- Forks
- 198
- PR merge metrics
- No merged PRs in 30d
Description
The [code snippet](https://drupal-graphql.gitbook.io/graphql/data-producers/composing) 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"
]
}
]
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.