Say I have a schema something like this:
type Approval {
id: ID!
approvedAt: DateTime!
}
type Author @auth(
query: {
rule: """
query {
queryAuthor(filter: { has: approval }) {
id
}
}
"""
}
) {
id: ID!
posts: [Post!] @hasInverse(field: author)
approval: Approval
}
# Posts can only be viewed by author, for example
type Post @auth(
query: {
rule: """
query ($USER: String!) {
queryPost {
author(filter: { id: { eq: $USER } }) {
id
}
}
}
"""
}
) {
id: ID!
author: Author! @hasInverse(field: posts)
text: String!
}
This is an extremely simplified version of what I’m actually working with, which also uses interfaces
& inherited auth rules, etc. So my question is about intended behavior.
If I make a post with an approved author, the @auth
directive on Post
works as expected if I query
as someone other than author:
query QueryPost {
queryPost {
id
}
}
# returns { "post": [] }
But if I access the Post
through Author
:
query QueryPostThroughAuthor {
queryAuthor {
posts {
text
}
}
}
the query returns
{
"queryAuthor": {
"posts": [{
"text": "Myforbiddentext"
}]
}
}
showing the forbidden post! Is this intended? I assumed that auth rules would apply even for nested records. Does giving access to a record then give access to everything linked to it in the graph? Or am I maybe doing something wrong?