api-platform / api-platform/core

[GraphQL, SearchFilter] Filter a nested collection doesn't work on iterable property

未關閉
#8,038 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
doctrine filters GraphQL
主要語言
PHP
星號
2.6k
分支
980
平均合併
2 天 2 小時
30 天內合併 PR
51

描述

**API Platform version(s) affected**: 2.6.8

**Description**

Filter nested collection (OneToMany) doesn't work as excerpted, i also tried `children.views`

Note that it works with ORM `string` property, but not with ORM `array` type.

**How to reproduce**

* Entity

```php
// App/Entity/Route
...
#[ApiFilter(SearchFilter::class, strategy: 'partial', properties: ['views'=>'partial'])]
class Route
{
...
#[ORM\Column(type: 'array')]
private array $views = [];

#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
private ?self $parent;

#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
private Collection $children;
}
```

* Query
```graphql
query {
routes(views: [MENU]) {
edges {
node {
id
title
children(views: [MENU]) {
edges {
node {
id
title
}
}
}
}
}
}
}
```

* Result
```json
{
"data": {
"routes": {
"edges": [
{
"node": {
"id": "/api/routes/1468",
"title": "Work Orders",
"views": [
"MENU"
],
"children": {
"edges": [
{
"node": {
"id": "/api/routes/1469",
"title": "Work Order List",
"views": [
"MENU"
]
}
},
{
"node": {
"id": "/api/routes/1470",
"title": "New Work Order",
"views": [
"PAGE_ACTION"
]
}
},
{
"node": {
"id": "/api/routes/1471",
"title": "Edit Work Order",
"views": [
"ENTITY_ACTION"
]
}
},
{
"node": {
"id": "/api/routes/1472",
"title": "Delete Work Order",
"views": [
"ENTITY_ACTION"
]
}
}
]
}
}
},
...
```

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。