Symfony 如何使用GraphQL正确获取嵌套集合?

Symfony 如何使用GraphQL正确获取嵌套集合?,symfony,graphql,api-platform.com,Symfony,Graphql,Api Platform.com,我有两个实体: User Book 这两个实体都作为API资源公开(我使用的是DTO) 我希望只允许管理员查看这两个实体的集合,但我还需要能够获取嵌套集合: query { user(id: "/api/users/01F63NKKN7DWYB74K6G5N33DPP") { id books{ edges{ node{ id } } } } } Resul

我有两个实体:

User
Book
这两个实体都作为API资源公开(我使用的是DTO)

我希望只允许管理员查看这两个实体的集合,但我还需要能够获取嵌套集合:

query {
    user(id: "/api/users/01F63NKKN7DWYB74K6G5N33DPP") {
    id
    books{
      edges{
        node{
          id
        }
      }
    }
    }
}

Result: Access Denied.
我可以使用REST获取集合,但是如何使用GraphQL获取集合呢?我很困惑。在这种情况下我能做什么

UPD:


如果安全性被禁用/注释掉,它是否工作?@xadm当然可以
query {
    user(id: "/api/users/01F63NKKN7DWYB74K6G5N33DPP") {
    id
    books{
      edges{
        node{
          id
        }
      }
    }
    }
}

Result: Access Denied.
//src/Dto/UserOutput.php
final class UserOutput
{
    #[Groups(['user:read', 'book:read'])]
    public Ulid $id;

    ...

    /** @var Book[] */
    #[Groups(['user:read'])]
    public iterable $books;
}

//src/Dto/BookOutput.php
final class BookOutput
{
    #[Groups(['book:read', 'user:read'])]
    public Ulid $id;

    #[Groups(['book:read'])]
    public User $user;

    ...
}