api-platform / api-platform/core

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

Abierto
#8,038 1 comentario 0 reacciones 0 asignados Ver en GitHub
doctrine filters GraphQL
Lenguaje dominante
PHP
Estrellas
2.6k
Forks
980
Merge medio
2 d 4 h
PR fusionados (30 d)
49

Descripción

**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"
]
}
}
]
}
}
},
...
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.