Bongo
Bongo

Reputation: 384

How to hide graphQL fields in Netflix DGS framework?

How can you hide a graghQL field in DGS framework. E.g. 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]
}

Upvotes: 0

Views: 368

Answers (1)

Tiago Ferrer
Tiago Ferrer

Reputation: 46

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.

@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";
    }
}

Upvotes: 1

Related Questions