Make a graphql query like the following one
query {
page_home(lang: "es-es") {
data {
header {
id,
name
logo_image {
id,
name
},
menu {
id,
name,
elements {
name
}
}
},
footer {
name,
columns {
id,
name
}
}
}
}
}
The data is returned properly.
Receive an error for every relationship that is marked as required (even though we don't request it).
{
"error": {
"code": null,
"message": "Expected {\"type\":\"[CBannerSlideItem]\",\"resolve\":{}} to be a GraphQL nullable type."
}
}
Afer removing the required, that part works properly.
But then, in the queried part that follows, the elements doesn't return any field and is not of the expected collection type (is of the type CTA that appears in the screenshot. You can discover so by which fields you request even though they are not returned). This also happens with other relationships.
menu {
id,
name,
slice,
elements {
name
}
Response:
{
"data": {
"page_home": {
"data": [
{
"header": {
"id": "1",
"name": "Standard header",
"logo_image": {
"id": "17",
"name": "logo tous"
},
"menu": {
"id": "1",
"name": "Main header menu",
"elements": []
}
},
"footer": {
"name": "Standard footer",
"columns": []
}
}
]
}
}
}

master branchHi, @nachogarcia Can you please give me your data dump along with error log in slack? You can find me hem in http://directus.chat
So it looks like, for example, the O2M fields are not generated quite right. https://github.com/directus/api/blob/5e662f765fad80328a0b9a264a441142d1969e29/src/core/Directus/GraphQL/FieldsConfig.php#L65
case 'o2m':
$relation = $this->getRelation('o2m', $v['collection'], $v['field']);
$temp = [];
$temp['type'] = Types::listOf(Types::userCollection($relation['collection_one']));
$temp['resolve'] = function ($value) use ($relation) {
$data = [];
foreach ($value[$relation['collection_one']] as $v) {
$data[] = $v[$relation['field_many']];
}
return $data;
};
$fields[$v['field']] = $temp;
break;
Maybe we should try something like this.
case 'o2m':
$relation = $this->getRelation('o2m', $v['collection'], $v['field']);
$temp = [];
$temp['type'] = Types::listOf(Types::userCollection($relation['collection_many']));
$temp['resolve'] = function ($value) use ($relation) {
return $value[$relation['collection_many']];
};
$fields[$v['field']] = $temp;
break;
````
The type of the O2M should be the collection that is being referenced, not the collection that owns the reference.
In my particular case, I have the following query.
{
persons {
data {
name,
affiliations {
id,
begin,
end
}
}
}
}
```
Directus wrongly assumes that _affiliations_ should be a list of _persons_, whereas it should be a list of, intuitively enough, _affiliations_.
Most helpful comment
So it looks like, for example, the O2M fields are not generated quite right. https://github.com/directus/api/blob/5e662f765fad80328a0b9a264a441142d1969e29/src/core/Directus/GraphQL/FieldsConfig.php#L65
Maybe we should try something like this.
{
persons {
data {
name,
affiliations {
id,
begin,
end
}
}
}
}
```
Directus wrongly assumes that _affiliations_ should be a list of _persons_, whereas it should be a list of, intuitively enough, _affiliations_.