简体   繁体   English

如何在 Netflix DGS 框架中隐藏 graphQL 字段?

[英]How to hide graphQL fields in Netflix DGS framework?

How can you hide a graghQL field in DGS framework.如何在 DGS 框架中隐藏 graghQL 字段。 Eg as below, what can you use so that title cannot be fetched or isn't visible to the client?例如,您可以使用什么来使标题无法获取或对客户端不可见?

type Show {
  title: String
  actors: [Actor]
}

I don't think that is possible.我不认为这是可能的。 However, you can set authentication roles by field, which means that only clients with specific roles are going to be able to fetch data from it.但是,您可以按字段设置身份验证角色,这意味着只有具有特定角色的客户端才能从中获取数据。

I am attaching a sample from DGS documentation of how you can do it.我附上了 DGS 文档中的示例,说明如何执行此操作。

@DgsComponent
public class SecurityExampleFetchers {
    @DgsData(parentType = "Query", field = "hello")
    public String hello() {
        return "Hello to everyone";
    }      

    @Secured("admin")
    @DgsData(parentType = "Query", field = "secureGroup")
    public String secureGroup() {
        return "Hello to admins only";
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM