GraphQL Auth on predicates

:grimacing:

work arounds to situations like this do indeed create additional problems that need even more workarounds.

type User @auth(
  update: { OR: [
    # Rule to let users update the user if the Administration status is == 0
    { rule: """
      query ($USERNAME: String!) {
        queryUser(filter: { username: { eq: $USERNAME } }) {
          adminFields(filter: { status: { eq: 0 } }) {
            status
          }
        }
      }
      """ },
    # Rule to let admin role update all users
    { rule: "{$ROLE: {eq:\"Admin\"}}" }
  ] }
) {
    username: String! @id
    nickname: String
    adminFields: Administration!
}
type Administration {
    status: Int! @search
}

Note this is not the most efficient method and it would be better if we could do:

1 Like