GraphQL公共指令

问题描述 投票:2回答:1

这是我的架构。

Query {
    me: User @isAuthenticated
}

当我添加@isAuthenticated时,它是在服务器端处理的,但在GraphQL Playground中,该指令不显示。我有一些基于角色的访问系统,并且我想公开显示所有角色指令,以便API用户可以了解哪个查询需要哪个角色。

graphql apollo apollo-server graphql-playground
1个回答
1
投票

Schema指令可用于转换模式或向其添加功能,但不能用于向客户端公开任何类型的元数据。关于如何实现这种功能的讨论正在进行中here。目前,最好的办法是利用描述。

"""
**Required roles**: `ADMIN` 
"""
Query {
  me: User @isAuthenticated
}
© www.soinside.com 2019 - 2024. All rights reserved.