The docs state:
- You can add custom queries to the Query type
type Query {
myCustomQuery(...): QueryResultType @custom(...)
}
So presumably if I want to add an auth rule to that custom query I do the following:
type Query @auth(
query: { rule: "{ $ROLE: { eq: \"ADMIN\" } }" }
){
myCustomQuery(...): QueryResultType @custom(...)
}
…and if it were a mutation:
type Mutation @auth(
add: { rule: "{ $ROLE: { eq: \"ADMIN\" } }" }
update: { rule: "{ $ROLE: { eq: \"ADMIN\" } }" }
delete: { rule: "{ $ROLE: { eq: \"ADMIN\" } }" }
){
myCustomMutation(...): MutationResult @custom(...)
}
…??
Or would it actually be:
type Query @auth(
myCustomQuery: { rule: "{ $ROLE: { eq: \"ADMIN\" } }" }
){
myCustomQuery(...): QueryResultType @custom(...)
}
type Mutation @auth(
myCustomMutation: { rule: "{ $ROLE: { eq: \"ADMIN\" } }" }
){
myCustomMutation(...): MutationResult @custom(...)
}
…?
Now what about if I have multiple custom queries/mutations that I want different auth rules for? Would I do it like this?:
type Query @auth(
query: { rule: "{ $ROLE: { eq: \"ADMIN\" } }" }
){
myCustomQuery(...): QueryResultType @custom(...)
}
type Query @auth(
query: { rule: "{ $ROLE: { eq: \"SUPERADMIN\" } }" }
){
mySecondCustomQuery(...): QueryResultType @custom(...)
}
Or like this?:
type Query @auth(
myCustomQuery: { rule: "{ $ROLE: { eq: \"ADMIN\" } }" }
mySecondCustomQuery: { rule: "{ $ROLE: { eq: \"SUPERADMIN\" } }" }
){
myCustomQuery(...): QueryResultType @custom(...)
mySecondCustomQuery(...): QueryResultType @custom(...)
}